Skip to content

Commit

Permalink
Merge pull request #73 from recurly/2.2.0
Browse files Browse the repository at this point in the history
bump 2.2.0
  • Loading branch information
dickfickling committed May 20, 2014
2 parents 9836471 + d528731 commit 076b9e6
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Version 2.2.0 May 14, 2014

- Added subscription preview: `subscription.preview()`
- Added tax details to adjustments: `adjustment.tax_details`
- Removed `taxable` support on adjustments
- Added `tax_exempt` to accounts, adjustments and plans
- Added `tax_rate`, `tax_type` to invoices and subscriptions
- Added `tax_in_cents` to subscriptions

## Version 2.1.15 April 8, 2014

- Added token_id support to BillingInfo
Expand Down
26 changes: 24 additions & 2 deletions recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


__version__ = '2.1.15'
__version__ = '2.2.0'

BASE_URI = 'https://%s.recurly.com/v2/'
"""The API endpoint to send requests to."""
Expand Down Expand Up @@ -79,6 +79,7 @@ class Account(Resource):
'last_name',
'company_name',
'vat_number',
'tax_exempt',
'accept_language',
'created_at',
)
Expand Down Expand Up @@ -351,6 +352,19 @@ class Redemption(Resource):
'created_at',
)

class TaxDetail(Resource):

"""A charge's tax breakdown"""

nodename = 'taxdetail'
inherits_currency = True

attributes = (
'name',
'type',
'tax_rate',
'tax_in_cents',
)

class Adjustment(Resource):

Expand All @@ -369,13 +383,15 @@ class Adjustment(Resource):
'tax_in_cents',
'total_in_cents',
'currency',
'taxable',
'tax_exempt',
'tax_details',
'start_date',
'end_date',
'created_at',
'type',
)
xml_attribute_attributes = ('type',)
_classes_for_nodename = {'tax_detail': TaxDetail,}


class Invoice(Resource):
Expand All @@ -396,6 +412,8 @@ class Invoice(Resource):
'vat_number',
'subtotal_in_cents',
'tax_in_cents',
'tax_type',
'tax_rate',
'total_in_cents',
'currency',
'created_at',
Expand Down Expand Up @@ -479,6 +497,9 @@ class Subscription(Resource):
'trial_started_at',
'trial_ends_at',
'unit_amount_in_cents',
'tax_in_cents',
'tax_type',
'tax_rate',
'total_billing_cycles',
'timeframe',
'currency',
Expand Down Expand Up @@ -617,6 +638,7 @@ class Plan(Resource):
'trial_interval_unit',
'accounting_code',
'created_at',
'tax_exempt',
'unit_amount_in_cents',
'setup_fee_in_cents',
)
Expand Down
2 changes: 2 additions & 0 deletions recurly/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ def value_for_element(cls, elem):
log.debug("Converting %r element with type %r", elem.tag, attr_type)
if attr_type == 'integer':
return int(elem.text.strip())
if attr_type == 'float':
return float(elem.text.strip())
if attr_type == 'boolean':
return elem.text.strip() == 'true'
if attr_type == 'datetime':
Expand Down
25 changes: 25 additions & 0 deletions tests/fixtures/account/show-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
GET https://api.recurly.com/v2/accounts/testmock HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<account href="https://api.recurly.com/v2/accounts/testmock">
<adjustments href="https://api.recurly.com/v2/accounts/testmock/adjustments"/>
<billing_info href="https://api.recurly.com/v2/accounts/testmock/billing_info"/>
<invoices href="https://api.recurly.com/v2/accounts/testmock/invoices"/>
<subscriptions href="https://api.recurly.com/v2/accounts/testmock/subscriptions"/>
<transactions href="https://api.recurly.com/v2/accounts/testmock/transactions"/>
<account_code>testmock</account_code>
<username nil="nil"></username>
<email nil="nil"></email>
<first_name nil="nil"></first_name>
<last_name nil="nil"></last_name>
<company_name nil="nil"></company_name>
<accept_language nil="nil"></accept_language>
<tax_exempt type="boolean">true</tax_exempt>
</account>
15 changes: 15 additions & 0 deletions tests/fixtures/adjustment/account-has-adjustments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ X-Records: 1
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
<description>test charge</description>
<account_code>chargemock</account_code>
<tax_in_cents type="integer">5000</tax_in_cents>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
<currency>USD</currency>
<tax_details type="array">
<tax_detail>
<name>california</name>
<type>state</type>
<tax_rate type="float">0.065</tax_rate>
<tax_in_cents type="integer">3000</tax_in_cents>
</tax_detail>
<tax_detail>
<name>san francisco</name>
<type>county</type>
<tax_rate type="float">0.02</tax_rate>
<tax_in_cents type="integer">2000</tax_in_cents>
</tax_detail>
</tax_details>
<start_date type="datetime">2009-11-03T23:27:46Z</start_date>
<end_date nil="nil" type="datetime"></end_date>
<created_at type="datetime">2009-11-03T23:27:46Z</created_at>
Expand Down
23 changes: 23 additions & 0 deletions tests/fixtures/adjustment/show-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GET https://api.recurly.com/v2/accounts/chargemock/adjustments HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8
X-Records: 1

<adjustments type="array">
<adjustment type="charge">
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
<description>test charge</description>
<account_code>chargemock</account_code>
<unit_amount_in_cents type="integer">1000</unit_amount_in_cents>
<currency>USD</currency>
<tax_exempt type="boolean">false</tax_exempt>
<start_date type="datetime">2009-11-03T23:27:46Z</start_date>
<end_date nil="nil" type="datetime"></end_date>
<created_at type="datetime">2009-11-03T23:27:46Z</created_at>
</adjustment>
</adjustments>
25 changes: 25 additions & 0 deletions tests/fixtures/invoice/show-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
GET https://api.recurly.com/v2/accounts/invoicemock/invoices HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
X-Records: 1
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<invoices type="array">
<invoice href="https://api.recurly.com/v2/invoices/4ba1531325014b4f969cd13676f514d8">
<uuid>4ba1531325014b4f969cd13676f514d8</uuid>
<account_code>invoicemock</account_code>
<amount_in_cents>
<USD type="integer">1000</USD>
</amount_in_cents>
<start_date type="datetime">2009-11-03T23:27:46-08:00</start_date>
<end_date type="datetime"></end_date>
<description>test charge</description>
<created_at type="datetime">2009-11-03T23:27:46-08:00</created_at>
<tax_type>usst</tax_type>
</invoice>
</invoices>
34 changes: 34 additions & 0 deletions tests/fixtures/plan/show-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
GET https://api.recurly.com/v2/plans/planmock HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<plan href="https://api.recurly.com/v2/plans/planmock">
<add_ons href="https://api.recurly.com/v2/plans/planmock/add_ons"/>
<plan_code>planmock</plan_code>
<name>Mock Plan</name>
<description nil="nil"></description>
<success_url nil="nil"></success_url>
<cancel_url nil="nil"></cancel_url>
<display_donation_amounts type="boolean">false</display_donation_amounts>
<display_quantity type="boolean">false</display_quantity>
<display_phone_number type="boolean">false</display_phone_number>
<bypass_hosted_confirmation type="boolean">false</bypass_hosted_confirmation>
<unit_name>unit</unit_name>
<payment_page_tos_link nil="nil"></payment_page_tos_link>
<plan_interval_length type="integer">1</plan_interval_length>
<plan_interval_unit>months</plan_interval_unit>
<trial_interval_length type="integer">0</trial_interval_length>
<trial_interval_unit>days</trial_interval_unit>
<created_at type="datetime">2011-10-03T22:23:12Z</created_at>
<tax_exempt type="boolean">true</tax_exempt>
<unit_amount_in_cents>
</unit_amount_in_cents>
<setup_fee_in_cents>
</setup_fee_in_cents>
</plan>
37 changes: 37 additions & 0 deletions tests/fixtures/subscription/show-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GET https://api.recurly.com/v2/accounts/subscribemock/subscriptions HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
X-Records: 1
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<subscriptions type="array">
<subscription
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab">
<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>
<subscription_add_ons type="array">
</subscription_add_ons>
</subscription>
</subscriptions>
37 changes: 37 additions & 0 deletions tests/fixtures/subscription/show.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GET https://api.recurly.com/v2/accounts/subscribemock/subscriptions HTTP/1.1
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: recurly-python/{version}


HTTP/1.1 200 OK
X-Records: 1
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<subscriptions type="array">
<subscription
href="https://api.recurly.com/v2/subscriptions/123456789012345678901234567890ab">
<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>
<subscription_add_ons type="array">
</subscription_add_ons>
</subscription>
</subscriptions>
Loading

0 comments on commit 076b9e6

Please sign in to comment.