-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from bc-ruth/OMNI-1024
OMNI-1024 Expose currencies v2 resource to Client API
- Loading branch information
Showing
4 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Bigcommerce\Api\Resources; | ||
|
||
use Bigcommerce\Api\Resource; | ||
use Bigcommerce\Api\Client; | ||
|
||
/** | ||
* Represents a single currency. | ||
*/ | ||
class Currency extends Resource | ||
{ | ||
protected $ignoreOnCreate = array( | ||
'date_created', | ||
'date_modified', | ||
); | ||
|
||
protected $ignoreOnUpdate = array( | ||
'id', | ||
'date_created', | ||
'date_modified', | ||
); | ||
|
||
public function create() | ||
{ | ||
return Client::createCurrency($this->getCreateFields()); | ||
} | ||
|
||
public function update() | ||
{ | ||
return Client::updateCurrency($this->id, $this->getUpdateFields()); | ||
} | ||
|
||
public function delete() | ||
{ | ||
return Client::deleteCurrency($this->id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
namespace Bigcommerce\Test\Unit\Api\Resources; | ||
|
||
use Bigcommerce\Api\Resources\Currency; | ||
use Bigcommerce\Api\Client; | ||
|
||
class CurrencyTest extends ResourceTestBase | ||
{ | ||
public function testCreatePassesThroughToConnection() | ||
{ | ||
$currency = new Currency((object)array('id' => 1)); | ||
$this->connection->expects($this->once()) | ||
->method('post') | ||
->with($this->basePath . '/currencies', (object)array('id' => 1)); | ||
|
||
$currency->create(); | ||
} | ||
|
||
public function testUpdatePassesThroughToConnection() | ||
{ | ||
$currency = new Currency((object)array('id' => 1)); | ||
$this->connection->expects($this->once()) | ||
->method('put') | ||
->with($this->basePath . '/currencies/1', (object)array()); | ||
|
||
$currency->update(); | ||
} | ||
|
||
public function testDeletePassesThroughToConnection() | ||
{ | ||
$currency = new Currency((object)array('id' => 1)); | ||
$this->connection->expects($this->once()) | ||
->method('delete') | ||
->with($this->basePath . '/currencies/1'); | ||
|
||
$currency->delete(); | ||
} | ||
} |