-
Notifications
You must be signed in to change notification settings - Fork 93
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 #289 from recurly/create_shipping_address_on_exist…
…ing_account Create shipping addresses on existing accounts and allow updates
- Loading branch information
Showing
6 changed files
with
145 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
|
||
class Recurly_ShippingAddressTest extends Recurly_TestCase | ||
{ | ||
function defaultResponses() { | ||
return array( | ||
array('GET', '/accounts/abcdef1234567890', 'accounts/show-200.xml') | ||
); | ||
} | ||
|
||
public function testCreateShippingAddressOnExistingAccount() { | ||
$account = Recurly_Account::get('abcdef1234567890', $this->client); | ||
$this->client->addResponse('POST', 'https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses', 'shipping_addresses/create-201.xml'); | ||
|
||
$shad = new Recurly_ShippingAddress(); | ||
$shad->nickname = "Home"; | ||
$shad->first_name = "Verena"; | ||
$shad->last_name = "Example"; | ||
$shad->phone = "555-555-5555"; | ||
$shad->email = "[email protected]"; | ||
$shad->address1 = "123 Dolores St."; | ||
$shad->city = "San Francisco"; | ||
$shad->state = "CA"; | ||
$shad->zip = "94110"; | ||
$shad->country = "US"; | ||
|
||
$account->createShippingAddress($shad, $this->client); | ||
|
||
$this->assertEquals($shad->id, 1234567); | ||
} | ||
|
||
public function testUpdateShippingAddress() { | ||
$this->client->addResponse('GET', '/accounts/abcdef1234567890/shipping_addresses', 'shipping_addresses/index-200.xml'); | ||
$this->client->addResponse('PUT', 'https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567', 'shipping_addresses/update-200.xml'); | ||
|
||
$shipping_addresses = Recurly_ShippingAddressList::get('abcdef1234567890', null, $this->client); | ||
|
||
foreach ($shipping_addresses as $shipping_address) { | ||
if ($shipping_address->nickname == 'Home') { | ||
$shipping_address->address1 = "123 NewStreet Ave."; | ||
$shipping_address->update(); | ||
$this->assertEquals($shipping_address->address1, "123 NewStreet Ave."); | ||
} | ||
} | ||
} | ||
|
||
} |
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 201 Created | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shipping_address href="https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567"> | ||
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890" /> | ||
<id type="integer">1234567</id> | ||
<nickname>Home</nickname> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
<company nil="nil"></company> | ||
<email>[email protected]</email> | ||
<vat_number nil="nil"></vat_number> | ||
<address1>123 Dolores St.</address1> | ||
<address2 nil="nil"></address2> | ||
<city>San Francisco</city> | ||
<state>CA</state> | ||
<zip>94110</zip> | ||
<country>US</country> | ||
<phone>555-555-5555</phone> | ||
<created_at type="datetime">2016-12-15T21:01:51Z</created_at> | ||
<updated_at type="datetime">2016-12-15T21:01:51Z</updated_at> | ||
</shipping_address> |
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,26 @@ | ||
HTTP/1.1 200 Created | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shipping_addresses type="array"> | ||
<shipping_address href="https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567"> | ||
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890" /> | ||
<id type="integer">1234567</id> | ||
<nickname>Home</nickname> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
<company nil="nil"></company> | ||
<email>[email protected]</email> | ||
<vat_number nil="nil"></vat_number> | ||
<address1>123 Dolores St.</address1> | ||
<address2 nil="nil"></address2> | ||
<city>San Francisco</city> | ||
<state>CA</state> | ||
<zip>94110</zip> | ||
<country>US</country> | ||
<phone>555-555-5555</phone> | ||
<created_at type="datetime">2016-12-15T21:01:51Z</created_at> | ||
<updated_at type="datetime">2016-12-15T21:01:51Z</updated_at> | ||
</shipping_address> | ||
</shipping_addresses> |
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 Updated | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shipping_address href="https://api.recurly.com/v2/accounts/abcdef1234567890/shipping_addresses/1234567"> | ||
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890" /> | ||
<id type="integer">1234567</id> | ||
<nickname>Home</nickname> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
<company nil="nil"></company> | ||
<email>[email protected]</email> | ||
<vat_number nil="nil"></vat_number> | ||
<address1>123 NewStreet Ave.</address1> | ||
<address2 nil="nil"></address2> | ||
<city>San Francisco</city> | ||
<state>CA</state> | ||
<zip>94110</zip> | ||
<country>US</country> | ||
<phone>555-555-5555</phone> | ||
<created_at type="datetime">2016-12-15T21:01:51Z</created_at> | ||
<updated_at type="datetime">2016-12-15T21:01:51Z</updated_at> | ||
</shipping_address> |
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