-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 2.12.9 #442
Merged
Merged
Release 2.12.9 #442
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
91f1de1
Release 2.12.8
joannasese c78808e
Merge pull request #436 from recurly/release_2_12_8
bhelx dc758db
Add item class
joannasese 46bcf1a
Merge pull request #441 from recurly/727-item-catalog
bhelx f3274a3
Release 2.12.9
joannasese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,92 @@ | ||
<?php | ||
|
||
class Recurly_ItemTest extends Recurly_TestCase | ||
{ | ||
function defaultResponses() { | ||
return array( | ||
array('GET', '/items/plastic_gloves', 'items/show-200.xml'), | ||
); | ||
} | ||
|
||
public function testConstructor() { | ||
$client = new Recurly_Client; | ||
$item = new Recurly_Item(null, $client); | ||
|
||
$prop = new ReflectionProperty($item, '_client'); | ||
$prop->setAccessible(true); | ||
|
||
$this->assertSame($client, $prop->getValue($item)); | ||
} | ||
|
||
public function testGetItem() { | ||
$item = Recurly_Item::get('plastic_gloves', $this->client); | ||
|
||
$this->assertInstanceOf('Recurly_Item', $item); | ||
$this->assertEquals('plastic_gloves', $item->item_code); | ||
$this->assertEquals('Awesome Plastic Gloves', $item->name); | ||
$this->assertEquals('Sleek Plastic', $item->description); | ||
} | ||
|
||
public function testNestedCustomFields() { | ||
$item = Recurly_Item::get('plastic_gloves', $this->client); | ||
$item->custom_fields[] = new Recurly_CustomField('size', 'small'); | ||
|
||
$this->assertEquals( | ||
"<?xml version=\"1.0\"?>\n<item><custom_fields><custom_field><name>size</name><value>small</value></custom_field></custom_fields></item>\n", | ||
$item->xml() | ||
); | ||
} | ||
|
||
public function testDelete() { | ||
$this->client->addResponse('DELETE', 'https://api.recurly.com/v2/items/plastic_gloves', 'items/destroy-204.xml'); | ||
|
||
$item = Recurly_Item::get('plastic_gloves', $this->client); | ||
$item->delete(); | ||
} | ||
|
||
public function testDeleteItem() { | ||
$this->client->addResponse('DELETE', '/items/plastic_gloves', 'items/destroy-204.xml'); | ||
|
||
Recurly_Item::deleteItem('plastic_gloves', $this->client); | ||
} | ||
|
||
public function testReactivate() { | ||
$this->client->addResponse('PUT', 'https://api.recurly.com/v2/items/plastic_gloves/reactivate', 'items/reactivate-200.xml'); | ||
|
||
$item = Recurly_Item::get('plastic_gloves', $this->client); | ||
$item->reactivate(); | ||
$this->assertEquals('active', $item->state); | ||
} | ||
|
||
public function testReactivateItem() { | ||
$this->client->addResponse('PUT', '/items/plastic_gloves/reactivate', 'items/reactivate-200.xml'); | ||
|
||
$item = Recurly_Item::reactivateItem('plastic_gloves', $this->client); | ||
$this->assertInstanceOf('Recurly_Item', $item); | ||
$this->assertEquals('active', $item->state); | ||
} | ||
|
||
public function testCreateXml() { | ||
$item = new Recurly_Item(); | ||
$item->item_code = 'little_llama'; | ||
$item->name = 'Little Llama'; | ||
$item->description = 'A description about llamas'; | ||
$item->custom_fields[] = new Recurly_CustomField('size', 'small'); | ||
|
||
$this->assertEquals( | ||
"<?xml version=\"1.0\"?>\n<item><item_code>little_llama</item_code><name>Little Llama</name><description>A description about llamas</description><custom_fields><custom_field><name>size</name><value>small</value></custom_field></custom_fields></item>\n", | ||
$item->xml() | ||
); | ||
} | ||
|
||
public function testUpdateXml() { | ||
$item = Recurly_Item::get('plastic_gloves', $this->client); | ||
$item->description = 'A new description about gloves.'; | ||
|
||
$this->assertEquals( | ||
"<?xml version=\"1.0\"?>\n<item><description>A new description about gloves.</description></item>\n", | ||
$item->xml() | ||
); | ||
} | ||
|
||
} |
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,2 @@ | ||
HTTP/1.1 204 No Content | ||
|
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,25 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/items/plastic_gloves.xml | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<item href="https://api.recurly.com/v2/items/plastic_gloves"> | ||
<item_code>plastic_gloves</item_code> | ||
<name>Awesome Plastic Gloves</name> | ||
<description>Sleek Plastic</description> | ||
<external_sku>awesome-plastic-gloves</external_sku> | ||
<accounting_code>1569273944</accounting_code> | ||
<revenue_schedule_type>never</revenue_schedule_type> | ||
<tax_exempt type="boolean">true</tax_exempt> | ||
<tax_code nil="nil"/> | ||
<state>active</state> | ||
<custom_fields type="array"> | ||
<custom_field> | ||
<name>color</name> | ||
<value>blue</value> | ||
</custom_field> | ||
</custom_fields> | ||
<created_at type="datetime">2019-09-23T21:25:45Z</created_at> | ||
<updated_at type="datetime">2019-09-23T21:25:45Z</updated_at> | ||
<deleted_at nil="nil"/> | ||
</item> |
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,24 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<item href="https://api.recurly.com/v2/items/plastic_gloves"> | ||
<item_code>plastic_gloves</item_code> | ||
<name>Awesome Plastic Gloves</name> | ||
<description>Sleek Plastic</description> | ||
<external_sku>awesome-plastic-gloves</external_sku> | ||
<accounting_code>1569273944</accounting_code> | ||
<revenue_schedule_type>never</revenue_schedule_type> | ||
<tax_exempt type="boolean">true</tax_exempt> | ||
<tax_code nil="nil"/> | ||
<state>active</state> | ||
<custom_fields type="array"> | ||
<custom_field> | ||
<name>color</name> | ||
<value>blue</value> | ||
</custom_field> | ||
</custom_fields> | ||
<created_at type="datetime">2019-09-23T21:25:45Z</created_at> | ||
<updated_at type="datetime">2019-09-23T21:25:45Z</updated_at> | ||
<deleted_at nil="nil"/> | ||
</item> |
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
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
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,77 @@ | ||
<?php | ||
|
||
/** | ||
* Class Recurly Item | ||
* @property string $item_code The unique identifer of the item. | ||
* @property string $name The name of the item. | ||
* @property string $description The description of the item. | ||
* @property string $external_sku Stock keeping unit to link the item to other inventory. | ||
* @property string $accounting_code Accounting code for invoice line items. | ||
* @property string $revenue_schedule_type The revenue schedule type for the item. | ||
* @property string $state The state of the item. | ||
* @property Recurly_CustomFieldList $custom_fields Optional custom fields for the item. | ||
*/ | ||
|
||
class Recurly_Item extends Recurly_Resource | ||
{ | ||
public function __construct($href = null, $client = null) { | ||
parent::__construct($href, $client); | ||
$this->custom_fields = new Recurly_CustomFieldList(); | ||
} | ||
|
||
/** | ||
* @param $itemCode The item code | ||
* @param Recurly_Client $client Optional client for the request, useful for mocking the client | ||
* @return object | ||
* @throws Recurly_Error | ||
*/ | ||
public static function get($itemCode, $client = null) { | ||
return Recurly_Base::_get(Recurly_item::uriForItem($itemCode), $client); | ||
} | ||
|
||
public function create() { | ||
$this->_save(Recurly_Client::POST, Recurly_Client::PATH_ITEMS); | ||
} | ||
|
||
public function update() { | ||
$this->_save(Recurly_Client::PUT, $this->uri()); | ||
} | ||
|
||
public function delete() { | ||
Recurly_Base::_delete($this->uri(), $this->_client); | ||
} | ||
|
||
public static function deleteItem($itemCode, $client = null) { | ||
return Recurly_Base::_delete(Recurly_Item::uriForItem($itemCode), $client); | ||
} | ||
|
||
public function reactivate() { | ||
$this->_save(Recurly_Client::PUT, $this->uri() . '/reactivate'); | ||
} | ||
|
||
public static function reactivateItem($itemCode, $client = null) { | ||
return Recurly_Base::_put(Recurly_Item::uriForItem($itemCode) . '/reactivate', $client); | ||
} | ||
|
||
protected function uri() { | ||
if (!empty($this->_href)) | ||
return $this->getHref(); | ||
else | ||
return Recurly_Item::uriForItem($this->item_code); | ||
} | ||
|
||
protected static function uriForItem($itemCode) { | ||
return Recurly_Client::PATH_ITEMS . '/' . rawurlencode($itemCode); | ||
} | ||
|
||
protected function getNodeName() { | ||
return 'item'; | ||
} | ||
|
||
protected function getWriteableAttributes() { | ||
return array( | ||
'item_code', 'name', 'description', 'external_sku', | ||
'accounting_code', 'revenue', 'state', 'custom_fields' | ||
); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
class Recurly_ItemList extends Recurly_Pager | ||
{ | ||
public static function get($params = null, $client = null) { | ||
$uri = self::_uriWithParams(Recurly_Client::PATH_ITEMS, $params); | ||
return new self($uri, $client); | ||
} | ||
|
||
protected function getNodeName() { | ||
return 'items'; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got pulled in from
v2
branch. We are moving forward releasing all code frommaster
again.