Skip to content

Commit

Permalink
Merge pull request #494 from recurly/api_version_2_22
Browse files Browse the repository at this point in the history
Release version 2.18.0 / API version 2.22
  • Loading branch information
bhelx authored Aug 21, 2019
2 parents 272db3f + 1de4837 commit 73f10ce
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 10 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<a name="unreleased"></a>
## Unreleased

<a name="v2.18.0"></a>
## v2.18.0 (2019-08-21)

This bumps us to API version 2.22.

* MOTO transactions [PR](//github.com/recurly/recurly-client-ruby/pull/493)
* Changes for Vertex customers [PR](https://github.com/recurly/recurly-client-ruby/pull/491)

There is one breaking change. It only applies to Vertex users so will not likely affect you.
`Invoice#tax_types[].type` on invoice and preview invoice endpoints is no longer returned.


<a name="v2.17.11"></a>
## v2.17.11 (2019-06-27)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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.17'
gem 'recurly', '~> 2.18'
```

Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def redemption(coupon_code)
has_past_due_invoice
has_paused_subscription
preferred_locale
transaction_type
)
alias to_param account_code

Expand Down
1 change: 1 addition & 0 deletions lib/recurly/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Adjustment < Resource
credit_reason_code
original_adjustment_uuid
shipping_address_id
surcharge_in_cents
)
alias to_param uuid

Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class API
@@base_uri = "https://api.recurly.com/v2/"
@@valid_domains = [".recurly.com"]

RECURLY_API_VERSION = '2.21'
RECURLY_API_VERSION = '2.22'

FORMATS = Helper.hash_with_indifferent_read_access(
'pdf' => 'application/pdf',
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/billing_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BillingInfo < Resource
gateway_code
fraud_session_id
three_d_secure_action_result_token_id
transaction_type
) | CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES | AMAZON_ATTRIBUTES | PAYPAL_ATTRIBUTES | ROKU_ATTRIBUTES

# @return ["credit_card", "paypal", "amazon", "bank_account", "roku", nil] The type of billing info.
Expand Down
20 changes: 18 additions & 2 deletions lib/recurly/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def invoice_number_with_prefix
dunning_events_count
final_dunning_event
gateway_code
surcharge_in_cents
)
alias to_param invoice_number_with_prefix

Expand Down Expand Up @@ -142,11 +143,20 @@ def mark_failed

# Initiate a collection attempt on an invoice.
#
# @example
# # Optionally set transaction type
# invoice.force_collect(transaction_type: 'moto')
#
# @param options [Hash] Optional set of details to send to collect endpoint.
# @return [true, false] +true+ when successful, +false+ when unable to
# (e.g., the invoice is no longer open).
def force_collect
def force_collect(options = {})
return false unless link? :force_collect
reload follow_link :force_collect
http_opts = {}
if options[:transaction_type]
http_opts[:body] = transaction_type_xml(options[:transaction_type])
end
reload follow_link(:force_collect, http_opts)
true
end

Expand Down Expand Up @@ -266,6 +276,12 @@ def refund_line_items_to_xml(line_items = nil, refund_method = nil, options = {}
builder.to_s
end

def transaction_type_xml(transaction_type)
builder = XML.new("<invoice/>")
builder.add_element 'transaction_type', transaction_type.to_s
builder.to_s
end

# Invoices are only writeable through {Account} instances.
embedded! true
undef destroy
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/juris_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class JurisDetail < Resource
tax_in_cents
sub_type
jurisdiction_name
classification
)

embedded! true
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Purchase < Resource
vat_reverse_charge_notes
shipping_address_id
gateway_code
transaction_type
)

class << self
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Subscription < Resource
total_amount_in_cents
resume_at
gateway_code
transaction_type
)
alias to_param uuid

Expand Down
1 change: 1 addition & 0 deletions lib/recurly/tax_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TaxType < Resource
tax_in_cents
type
juris_details
tax_classification
)

embedded! true
Expand Down
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 = 17
PATCH = 11
MINOR = 18
PATCH = 0
PRE = nil

VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/adjustments/show-200-taxed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ Content-Type: application/xml; charset=utf-8
<type>General Sales and Use Tax</type>
<juris_details type="array">
<juris_detail>
<classification>tax</classification>
<jurisdiction>STATE</jurisdiction>
<jurisdiction_name nil="nil"></jurisdiction_name>
<tax_in_cents type="integer">115</tax_in_cents>
<description>Sales Tax</description>
<rate type="float">0.056</rate>
</juris_detail>
<juris_detail>
<classification>tax</classification>
<jurisdiction>COUNTY</jurisdiction>
<jurisdiction_name nil="nil"></jurisdiction_name>
<tax_in_cents type="integer">10</tax_in_cents>
<description>Sales Tax</description>
<rate type="float">0.005</rate>
</juris_detail>
<juris_detail>
<classification>tax</classification>
<jurisdiction>DISTRICT</jurisdiction>
<jurisdiction_name nil="nil"></jurisdiction_name>
<tax_in_cents type="integer">103</tax_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/adjustments/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Content-Type: application/xml; charset=utf-8
<currency>USD</currency>
<product_code>basic</product_code>
<revenue_schedule_type>evenly</revenue_schedule_type>
<surcharge_in_cents type="integer">100</surcharge_in_cents>
<tax_details type="array">
<tax_detail>
<name>california</name>
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/invoices/show-200-taxed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ Content-Type: application/xml; charset=utf-8
<refund_geo_code>ABC123</refund_geo_code>
<tax_types type="array">
<tax_type>
<type>STATE</type>
<tax_classification>surcharge</tax_classification>
<tax_in_cents type="integer">115</tax_in_cents>
<description>Sales Tax</description>
</tax_type>
<tax_type>
<type>COUNTY</type>
<tax_classification>surcharge</tax_classification>
<tax_in_cents type="integer">10</tax_in_cents>
<description>Sales Tax</description>
</tax_type>
<tax_type>
<type>DISTRICT</type>
<tax_classification>surcharge</tax_classification>
<tax_in_cents type="integer">103</tax_in_cents>
<description>Sales Tax</description>
</tax_type>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Content-Type: application/xml; charset=utf-8
<subtotal_after_discount_in_cents type="integer">300</subtotal_after_discount_in_cents>
<attempt_next_collection_at nil="nil"></attempt_next_collection_at>
<recovery_reason nil="nil"></recovery_reason>
<surcharge_in_cents type="integer">100</surcharge_in_cents>
<tax_types nil="nil"></tax_types>
<line_items>
<adjustment href="https://api.recurly.com/v2/adjustments/charge" type="charge">
Expand Down
2 changes: 2 additions & 0 deletions spec/recurly/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
adjustment.tax_rate.must_equal 0.0875
adjustment.revenue_schedule_type.must_equal 'evenly'
adjustment.proration_rate.must_equal 0.5
adjustment.surcharge_in_cents.must_equal 100

tax_details = adjustment.tax_details
tax_details.length.must_equal 2
Expand Down Expand Up @@ -69,6 +70,7 @@
tax_type.juris_details.length.must_equal 3

juris_detail = tax_type.juris_details.first
juris_detail.classification.must_equal 'tax'
juris_detail.jurisdiction.must_equal 'STATE'
juris_detail.tax_in_cents[:USD].must_equal 115
juris_detail.rate.must_equal 0.056
Expand Down
17 changes: 16 additions & 1 deletion spec/recurly/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
invoice.credit_payments.first.must_be_instance_of CreditPayment
end

it 'should have surcharge_in_cents' do
stub_api_request :get, 'invoices/1000', 'invoices/show-200'
invoice = Invoice.find('1000')
invoice.surcharge_in_cents.must_equal 100
end

it 'includes the invoice number prefix' do
stub_api_request :get, 'invoices/invoice-with-prefix', 'invoices/show-200-prefix'

Expand Down Expand Up @@ -61,7 +67,7 @@

tax_type = tax_types.first
tax_type.must_be_instance_of TaxType
tax_type.type.must_equal 'STATE'
tax_type.tax_classification.must_equal 'surcharge'
tax_type.tax_in_cents[:USD].must_equal 115
tax_type.description.must_equal 'Sales Tax'
end
Expand Down Expand Up @@ -161,6 +167,15 @@
end
end

describe "#force_collect" do
it "must call /collect with body" do
stub_api_request :get, 'invoices/1000', 'invoices/show-200'
stub_api_request :put, 'invoices/created-invoice/collect', 'invoices/show-200-updated'
invoice = Invoice.find(1000)
invoice.force_collect(transaction_type: 'moto')
end
end

describe "#save" do
it "must update an invoice" do
stub_api_request :get, 'invoices/1000', 'invoices/show-200'
Expand Down
1 change: 1 addition & 0 deletions spec/recurly/purchase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
let(:purchase) do
Purchase.new(
account: {account_code: 'account123'},
transaction_type: 'moto',
adjustments: [
{
product_code: 'product_code',
Expand Down

0 comments on commit 73f10ce

Please sign in to comment.