-
Notifications
You must be signed in to change notification settings - Fork 78
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 #233 from recurly/api_version_2_11
API v2.11 changes
- Loading branch information
Showing
8 changed files
with
235 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
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 |
---|---|---|
|
@@ -10,6 +10,18 @@ Content-Type: application/xml; charset=utf-8 | |
<account> | ||
<account_code>testmock</account_code> | ||
<email>[email protected]</email> | ||
<shipping_addresses> | ||
<shipping_address> | ||
<address1>123 Main St</address1> | ||
<city>New Orleans</city> | ||
<country>US</country> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
<nickname>Work</nickname> | ||
<state>LA</state> | ||
<zip>70114</zip> | ||
</shipping_address> | ||
</shipping_addresses> | ||
<billing_info> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
|
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,55 @@ | ||
PUT https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/pause HTTP/1.1 | ||
X-Api-Version: {api-version} | ||
Accept: application/xml | ||
Authorization: Basic YXBpa2V5Og== | ||
User-Agent: {user-agent} | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<subscription> | ||
<remaining_pause_cycles type="integer">1</remaining_pause_cycles> | ||
</subscription> | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<subscription | ||
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab"> | ||
<redemptions href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/redemptions" /> | ||
<uuid>123456789012345678901234567890ab</uuid> | ||
<account href="https://api.recurly.com/v2/accounts/subscribemock"/> | ||
<plan href="https://api.recurly.com/v2/plans/basicplan"> | ||
<plan_code>basicplan</plan_code> | ||
<name>Basic Plan</name> | ||
</plan> | ||
<state>active</state> | ||
<quantity type="integer">1</quantity> | ||
<currency>EUR</currency> | ||
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents> | ||
<activated_at type="datetime">2011-05-27T07:00:00Z</activated_at> | ||
<canceled_at nil="nil"></canceled_at> | ||
<expires_at nil="nil"></expires_at> | ||
<current_period_started_at type="datetime">2011-06-27T07:00:00Z</current_period_started_at> | ||
<current_period_ends_at type="datetime">2010-07-27T07:00:00Z</current_period_ends_at> | ||
<trial_started_at nil="nil"></trial_started_at> | ||
<trial_ends_at nil="nil"></trial_ends_at> | ||
<tax_in_cents type="integer">0</tax_in_cents> | ||
<tax_type>usst</tax_type> | ||
<no_billing_info_reason>plan_free_trial</no_billing_info_reason> | ||
<paused_at type="datetime">2019-07-27T07:00:00Z</paused_at> | ||
<remaining_pause_cycles type="integer">1</remaining_pause_cycles>> | ||
<subscription_add_ons type="array"> | ||
<subscription_add_on> | ||
<add_on_type>usage</add_on_type> | ||
<measured_unit href="https://api.recurly.com/v2/measured_units/123456"/> | ||
<usage href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/add_ons/marketing_emails/usage"/> | ||
<add_on_code>marketing_emails</add_on_code> | ||
<unit_amount_in_cents type="integer">5</unit_amount_in_cents> | ||
<quantity type="integer">1</quantity> | ||
<usage_type>price</usage_type> | ||
<usage_percentage nil="nil"/> | ||
</subscription_add_on> | ||
</subscription_add_ons> | ||
</subscription> |
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,52 @@ | ||
PUT https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/resume HTTP/1.1 | ||
X-Api-Version: {api-version} | ||
Accept: application/xml | ||
Authorization: Basic YXBpa2V5Og== | ||
User-Agent: {user-agent} | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<subscription /> | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
Location: https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<subscription | ||
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab"> | ||
<redemptions href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/redemptions" /> | ||
<uuid>123456789012345678901234567890ab</uuid> | ||
<account href="https://api.recurly.com/v2/accounts/subscribemock"/> | ||
<plan href="https://api.recurly.com/v2/plans/basicplan"> | ||
<plan_code>basicplan</plan_code> | ||
<name>Basic Plan</name> | ||
</plan> | ||
<state>active</state> | ||
<quantity type="integer">1</quantity> | ||
<currency>EUR</currency> | ||
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents> | ||
<activated_at type="datetime">2011-05-27T07:00:00Z</activated_at> | ||
<canceled_at nil="nil"></canceled_at> | ||
<expires_at nil="nil"></expires_at> | ||
<current_period_started_at type="datetime">2011-06-27T07:00:00Z</current_period_started_at> | ||
<current_period_ends_at type="datetime">2010-07-27T07:00:00Z</current_period_ends_at> | ||
<trial_started_at nil="nil"></trial_started_at> | ||
<trial_ends_at nil="nil"></trial_ends_at> | ||
<tax_in_cents type="integer">0</tax_in_cents> | ||
<tax_type>usst</tax_type> | ||
<no_billing_info_reason>plan_free_trial</no_billing_info_reason> | ||
<paused_at type="datetime">2019-07-27T07:00:00Z</paused_at> | ||
<remaining_pause_cycles type="integer">1</remaining_pause_cycles>> | ||
<subscription_add_ons type="array"> | ||
<subscription_add_on> | ||
<add_on_type>usage</add_on_type> | ||
<measured_unit href="https://api.recurly.com/v2/measured_units/123456"/> | ||
<usage href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab/add_ons/marketing_emails/usage"/> | ||
<add_on_code>marketing_emails</add_on_code> | ||
<unit_amount_in_cents type="integer">5</unit_amount_in_cents> | ||
<quantity type="integer">1</quantity> | ||
<usage_type>price</usage_type> | ||
<usage_percentage nil="nil"/> | ||
</subscription_add_on> | ||
</subscription_add_ons> | ||
</subscription> |
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 |
---|---|---|
|
@@ -67,6 +67,18 @@ def test_purchase(self): | |
currency = 'USD', | ||
account = Account( | ||
account_code = account_code, | ||
shipping_addresses = [ | ||
ShippingAddress( | ||
first_name = 'Verena', | ||
last_name = 'Example', | ||
address1 = '123 Main St', | ||
city = 'New Orleans', | ||
state = 'LA', | ||
zip = '70114', | ||
country = 'US', | ||
nickname = 'Work' | ||
) | ||
], | ||
billing_info = BillingInfo( | ||
first_name = 'Verena', | ||
last_name = 'Example', | ||
|
@@ -97,6 +109,8 @@ def test_purchase(self): | |
self.assertIsInstance(collection.charge_invoice, Invoice) | ||
self.assertIsInstance(collection.credit_invoices, list) | ||
self.assertIsInstance(collection.credit_invoices[0], Invoice) | ||
self.assertIsInstance(collection.charge_invoice.line_items[0].shipping_address, | ||
ShippingAddress) | ||
with self.mock_request('purchase/previewed.xml'): | ||
collection = purchase.preview() | ||
self.assertIsInstance(collection, InvoiceCollection) | ||
|
@@ -115,13 +129,15 @@ def test_account(self): | |
|
||
account = Account(account_code=account_code) | ||
account.vat_number = '444444-UK' | ||
account.preferred_locale = 'en-US' | ||
with self.mock_request('account/created.xml'): | ||
account.save() | ||
self.assertEqual(account._url, urljoin(recurly.base_uri(), 'accounts/%s' % account_code)) | ||
self.assertEqual(account.vat_number, '444444-UK') | ||
self.assertEqual(account.vat_location_enabled, True) | ||
self.assertEqual(account.cc_emails, | ||
'[email protected],[email protected]') | ||
self.assertEqual(account.preferred_locale, 'en-US') | ||
|
||
with self.mock_request('account/list-active.xml'): | ||
active = Account.all_active() | ||
|
@@ -1172,6 +1188,19 @@ def test_measured_unit(self): | |
self.assertEqual(measured_unit.description, 'Unit of Marketing Email') | ||
self.assertEqual(measured_unit.id, 123456) | ||
|
||
def test_subscription_pause_resume(self): | ||
with self.mock_request('subscription/show.xml'): | ||
sub = Subscription.get('123456789012345678901234567890ab') | ||
|
||
with self.mock_request('subscription/pause.xml'): | ||
sub.pause(1) | ||
|
||
self.assertIsInstance(sub.paused_at, datetime) | ||
self.assertEqual(sub.remaining_pause_cycles, 1) | ||
|
||
with self.mock_request('subscription/resume.xml'): | ||
sub.resume() | ||
|
||
def test_usage(self): | ||
usage = Usage() | ||
usage.amount = 100 # record 100 emails | ||
|