Skip to content

Commit

Permalink
Merge pull request #139 from recurly/2.3.0
Browse files Browse the repository at this point in the history
bump 2.3.0
  • Loading branch information
cbarton committed May 14, 2014
2 parents 90cde1d + e980f26 commit efa08df
Show file tree
Hide file tree
Showing 26 changed files with 334 additions and 19 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<a name="v2.3.0"></a>
## v2.3.0 (2014-5-14)

#### Features

* Added subscription preview: `Recurly::Subscription.preview` [0d55115](https://github.com/recurly/recurly-client-ruby/commit/0d55115b6155b6a2fb36bfbfcf0cd797f861841e)
* Added tax details to adjustments: `adjustment.tax_details` [c672258](https://github.com/recurly/recurly-client-ruby/commit/c6722589a6174fd2c791d4393522508ec4223694)
* Removed `taxable` support on adjustments [b542b8a](https://github.com/recurly/recurly-client-ruby/commit/b542b8a16616ba7d4cc1da22200ea3eb7ba426b0)
* Added `tax_exempt` to accounts, adjustments and plans [b542b8a](https://github.com/recurly/recurly-client-ruby/commit/b542b8a16616ba7d4cc1da22200ea3eb7ba426b0)
* Added `tax_rate`, `tax_type` to invoices and subscriptions [6a43f37](https://github.com/recurly/recurly-client-ruby/commit/6a43f37b86eb659aa99be4cf48bed0f07927b197)
* Added `tax_in_cents` to subscriptions [6a43f37](https://github.com/recurly/recurly-client-ruby/commit/6a43f37b86eb659aa99be4cf48bed0f07927b197)

<a name="v2.2.3"></a>
## v2.2.3 (2014-5-9)

Expand All @@ -15,7 +27,6 @@

* The gem now explicitly requires Ruby 1.9.3 or newer ([PR](https://github.com/recurly/recurly-client-ruby/pull/129))


<a name="v2.2.1"></a>
## v2.2.1 (2014-1-2)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
recurly (2.2.3)
recurly (2.3.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Recurly is packaged as a Ruby gem. We recommend you install it with
[Bundler](http://gembundler.com/) by adding the following line to your Gemfile:

``` ruby
gem 'recurly', '~> 2.2.3'
gem 'recurly', '~> 2.3.0'
```

Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
Expand Down
1 change: 1 addition & 0 deletions lib/recurly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Recurly
autoload :Account, 'recurly/account'
autoload :AddOn, 'recurly/add_on'
autoload :Address, 'recurly/address'
autoload :TaxDetail, 'recurly/tax_detail'
autoload :Adjustment, 'recurly/adjustment'
autoload :API, 'recurly/api'
autoload :BillingInfo, 'recurly/billing_info'
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Account < Resource
hosted_login_token
vat_number
address
tax_exempt
created_at
)
alias to_param account_code
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class Address < Resource
phone
)
end
end
end
3 changes: 2 additions & 1 deletion lib/recurly/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Adjustment < Resource
tax_in_cents
total_in_cents
currency
taxable
tax_exempt
tax_details
product_code
start_date
end_date
Expand Down
2 changes: 2 additions & 0 deletions lib/recurly/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Invoice < Resource
vat_number
subtotal_in_cents
tax_in_cents
tax_type
tax_rate
total_in_cents
currency
created_at
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Plan < Resource
trial_interval_unit
total_billing_cycles
accounting_code
tax_exempt
created_at
)
alias to_param plan_code
Expand Down
19 changes: 19 additions & 0 deletions lib/recurly/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Recurly
class Subscription < Resource
autoload :AddOns, 'recurly/subscription/add_ons'

class NotPreviewableError < StandardError; end

# @macro [attach] scope
# @scope class
# @return [Pager<Subscription>] A pager that yields +$1+ subscriptions.
Expand Down Expand Up @@ -45,9 +47,26 @@ class Subscription < Resource
net_terms
collection_method
po_number
tax_in_cents
tax_type
tax_rate
)
alias to_param uuid

def self.preview(attributes = {})
new(attributes) { |record| record.preview }
end

def preview
raise NotPreviewableError.new('Cannot preview an existing subscription') unless new_record?

clear_errors
@response = API.send(:post, "#{path}/preview", to_xml)
reload response
rescue API::UnprocessableEntity => e
apply_errors e
end

# @return [Subscription] A new subscription.
def initialize attributes = {}
super({ :currency => Recurly.default_currency }.merge attributes)
Expand Down
14 changes: 14 additions & 0 deletions lib/recurly/tax_detail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'bigdecimal'

module Recurly
class TaxDetail < Resource
define_attribute_methods %w(
name
type
tax_rate
tax_in_cents
)

embedded! true
end
end
4 changes: 2 additions & 2 deletions lib/recurly/version.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Recurly
module Version
MAJOR = 2
MINOR = 2
PATCH = 3
MINOR = 3
PATCH = 0
PRE = nil

VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/accounts/create-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ Location: https://api.recurly.com/v2/accounts/abcdef1234567890.xml
<accept_language>en-US</accept_language>
<hosted_login_token>18d935f06b0547ddad8cdf2490ac802e</hosted_login_token>
<created_at type="datetime">2011-04-30T12:00:00Z</created_at>
<vat_number>12345-67</vat_number>
<address>
<address1>123 Main St.</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94105</zip>
<country>US</country>
<phone>8015551234</phone>
</address>
</account>
32 changes: 32 additions & 0 deletions spec/fixtures/accounts/show-200-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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/abcdef1234567890">
<adjustments href="https://api.recurly.com/v2/accounts/abcdef1234567890/adjustments"/>
<billing_info href="https://api.recurly.com/v2/accounts/abcdef1234567890/billing_info"/>
<invoices href="https://api.recurly.com/v2/accounts/abcdef1234567890/invoices"/>
<redemption href="https://api.recurly.com/v2/accounts/abcdef1234567890/redemption"/>
<subscriptions href="https://api.recurly.com/v2/accounts/abcdef1234567890/subscriptions"/>
<transactions href="https://api.recurly.com/v2/accounts/abcdef1234567890/transactions"/>
<account_code>abcdef1234567890</account_code>
<username>shmohawk58</username>
<email>[email protected]</email>
<first_name>Larry</first_name>
<last_name>David</last_name>
<company_name>Home Box Office</company_name>
<accept_language>en-US</accept_language>
<hosted_login_token>18d935f06b0547ddad8cdf2490ac802e</hosted_login_token>
<created_at type="datetime">2011-04-30T12:00:00Z</created_at>
<vat_number>12345-67</vat_number>
<tax_exempt type="boolean">true</tax_exempt>
<address>
<address1>123 Main St.</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94105</zip>
<country>US</country>
<phone>8015551234</phone>
</address>
</account>
10 changes: 10 additions & 0 deletions spec/fixtures/accounts/update-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ Location: https://api.recurly.com/v2/accounts/abcdef1234567890.xml
<accept_language>en-US</accept_language>
<hosted_login_token>19d935f06b0547ddad8cdf2490ac802e</hosted_login_token>
<created_at type="datetime">2011-04-30T12:00:00Z</created_at>
<vat_number>12345-67</vat_number>
<address>
<address1>123 Main St.</address1>
<address2 nil="nil"></address2>
<city>San Francisco</city>
<state>CA</state>
<zip>94105</zip>
<country>US</country>
<phone>8015551234</phone>
</address>
</account>
1 change: 0 additions & 1 deletion spec/fixtures/adjustments/show-200-nosub.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Content-Type: application/xml; charset=utf-8
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<product_code>basic</product_code>
<start_date type="datetime">2011-04-30T07:00:00Z</start_date>
<end_date type="datetime">2011-04-30T07:00:00Z</end_date>
Expand Down
25 changes: 25 additions & 0 deletions spec/fixtures/adjustments/show-200-taxed.xml
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

<?xml version="1.0" encoding="UTF-8"?>
<adjustment href="https://api.recurly.com/v2/adjustments/abcdef1234567890" type="charge">
<account href="https://api.recurly.com/v2/accounts/account"/>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice"/>
<subscription href="https://api.recurly.com/v2/subscriptions/abcdef1234567890"/>
<uuid>abcdef1234567890</uuid>
<state>pending</state>
<accounting_code nil="nil"></accounting_code>
<origin>plan</origin>
<description>$12 Annual Subscription</description>
<unit_amount_in_cents type="integer">1200</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<tax_exempt type="boolean">false</tax_exempt>
<product_code>basic</product_code>
<start_date type="datetime">2011-04-30T07:00:00Z</start_date>
<end_date type="datetime">2011-04-30T07:00:00Z</end_date>
<created_at type="datetime">2011-08-31T03:30:00Z</created_at>
</adjustment>
17 changes: 15 additions & 2 deletions spec/fixtures/adjustments/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@ Content-Type: application/xml; charset=utf-8
<unit_amount_in_cents type="integer">1200</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<tax_in_cents type="integer">5000</tax_in_cents>
<total_in_cents type="integer">1200</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<product_code>basic</product_code>
<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">2011-04-30T07:00:00Z</start_date>
<end_date type="datetime">2011-04-30T07:00:00Z</end_date>
<created_at type="datetime">2011-08-31T03:30:00Z</created_at>
Expand Down
11 changes: 5 additions & 6 deletions spec/fixtures/invoices/show-200-nosub.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
HTTP/1.1 201 Created
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8
Location: https://api.recurly.com/v2/invoices/created-invoice

<?xml version="1.0" encoding="UTF-8"?>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice">
Expand All @@ -11,7 +10,7 @@ Location: https://api.recurly.com/v2/invoices/created-invoice
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<tax_in_cents type="integer">100</tax_in_cents>
<total_in_cents type="integer">300</total_in_cents>
<currency>USD</currency>
<created_at type="datetime">2011-04-30T08:00:00Z</created_at>
Expand All @@ -23,11 +22,11 @@ Location: https://api.recurly.com/v2/invoices/created-invoice
<state>invoiced</state>
<description>Special charge</description>
<origin>one_time</origin>
<unit_amount_in_cents type="integer">100</unit_amount_in_cents>
<unit_amount_in_cents type="integer">300</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<total_in_cents type="integer">100</total_in_cents>
<tax_in_cents type="integer">100</tax_in_cents>
<total_in_cents type="integer">300</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<start_date nil="nil"></start_date>
Expand Down
87 changes: 87 additions & 0 deletions spec/fixtures/invoices/show-200-taxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice">
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890"/>
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
<tax_in_cents type="integer">100</tax_in_cents>
<total_in_cents type="integer">300</total_in_cents>
<currency>USD</currency>
<created_at type="datetime">2011-04-30T08:00:00Z</created_at>
<tax_type>usst</tax_type>
<line_items>
<adjustment href="https://api.recurly.com/v2/adjustments/charge" type="charge">
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890"/>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice"/>
<uuid>charge</uuid>
<state>invoiced</state>
<description>Special charge</description>
<origin>one_time</origin>
<unit_amount_in_cents type="integer">300</unit_amount_in_cents>
<quantity type="integer">1</quantity>
<discount_in_cents type="integer">0</discount_in_cents>
<tax_in_cents type="integer">100</tax_in_cents>
<total_in_cents type="integer">300</total_in_cents>
<currency>USD</currency>
<taxable type="boolean">false</taxable>
<start_date nil="nil"></start_date>
<end_date nil="nil"></end_date>
<created_at type="datetime">2011-04-30T08:00:00Z</created_at>
</adjustment>
</line_items>
<transactions>
<transaction href="https://api.recurly.com/v2/transactions/transaction" type="credit_card">
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890"/>
<invoice href="https://api.recurly.com/v2/invoices/created-invoice"/>
<uuid>transaction</uuid>
<action>purchase</action>
<amount_in_cents type="integer">300</amount_in_cents>
<tax_in_cents type="integer">0</tax_in_cents>
<currency>USD</currency>
<status>success</status>
<reference nil="nil"></reference>
<recurring type="boolean">false</recurring>
<test type="boolean">true</test>
<voidable type="boolean">true</voidable>
<refundable type="boolean">true</refundable>
<cvv_result code="" nil="nil"></cvv_result>
<avs_result code="" nil="nil"></avs_result>
<avs_result_street nil="nil"></avs_result_street>
<avs_result_postal nil="nil"></avs_result_postal>
<created_at type="datetime">2011-04-30T08:00:00Z</created_at>
<details>
<account>
<account_code>abcdef1234567890</account_code>
<first_name>Lucille</first_name>
<last_name>Bluth</last_name>
<company nil="nil"></company>
<email>[email protected]</email>
<billing_info type="credit_card">
<first_name>George</first_name>
<last_name>Bluth</last_name>
<address1 nil="nil"></address1>
<address2 nil="nil"></address2>
<city nil="nil"></city>
<state nil="nil"></state>
<zip nil="nil"></zip>
<country nil="nil"></country>
<phone nil="nil"></phone>
<vat_number nil="nil"></vat_number>
<card_type>Visa</card_type>
<year type="integer">2014</year>
<month type="integer">1</month>
<first_six>411111</first_six>
<last_four>1111</last_four>
</billing_info>
</account>
</details>
<a name="refund" href="https://api.recurly.com/v2/transactions/transaction" method="delete"/>
</transaction>
</transactions>
</invoice>
Loading

0 comments on commit efa08df

Please sign in to comment.