recurly 4.80.0 → 4.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.bumpversion.cfg +1 -1
- data/.github/workflows/ci.yml +5 -3
- data/CHANGELOG.md +12 -0
- data/GETTING_STARTED.md +1 -1
- data/README.md +27 -0
- data/lib/recurly/client.rb +164 -97
- data/lib/recurly/errors/network_errors.rb +25 -0
- data/lib/recurly/http/adapter.rb +22 -0
- data/lib/recurly/http/default_http_adapter.rb +107 -0
- data/lib/recurly/http/http_method.rb +13 -0
- data/lib/recurly/http/response.rb +48 -0
- data/lib/recurly/http.rb +4 -2
- data/lib/recurly/requests/coupon_create.rb +9 -1
- data/lib/recurly/requests/coupon_update.rb +9 -1
- data/lib/recurly/requests/invoice_create.rb +4 -0
- data/lib/recurly/requests/recovery_billing_info_create.rb +5 -1
- data/lib/recurly/requests/recovery_invoice_create.rb +4 -0
- data/lib/recurly/requests/recovery_payment_method_create.rb +34 -0
- data/lib/recurly/requests/subscription_create.rb +4 -0
- data/lib/recurly/requests/subscription_update.rb +4 -0
- data/lib/recurly/resources/coupon.rb +9 -1
- data/lib/recurly/resources/payment_method.rb +2 -2
- data/lib/recurly/resources/transaction.rb +4 -0
- data/lib/recurly/resources/unique_coupon_code.rb +4 -0
- data/lib/recurly/version.rb +1 -1
- data/lib/recurly.rb +4 -0
- data/openapi/api.yaml +10878 -90
- data/recurly.gemspec +1 -1
- metadata +18 -7
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Recurly
|
|
2
|
+
module HTTP
|
|
3
|
+
# The normalized response object every HTTP adapter must return from +#call+.
|
|
4
|
+
# It decouples the client from any particular transport library
|
|
5
|
+
# (+Net::HTTP+, Faraday, Typhoeus, ...).
|
|
6
|
+
#
|
|
7
|
+
# Header lookup is case-insensitive: keys are downcased on construction and
|
|
8
|
+
# +#[]+ downcases the lookup key.
|
|
9
|
+
class AdapterResponse
|
|
10
|
+
# @return [Integer] the numeric HTTP status code (e.g. 200)
|
|
11
|
+
attr_reader :status_code
|
|
12
|
+
|
|
13
|
+
# @return [Hash] response headers, keyed by downcased name
|
|
14
|
+
attr_reader :headers
|
|
15
|
+
|
|
16
|
+
# @return [String, nil] the raw response body
|
|
17
|
+
attr_reader :body
|
|
18
|
+
|
|
19
|
+
# @return [String, nil] the HTTP reason phrase (e.g. "Bad Gateway"), if the
|
|
20
|
+
# adapter captured one. May be nil for adapters that do not surface it.
|
|
21
|
+
attr_reader :reason_phrase
|
|
22
|
+
|
|
23
|
+
def initialize(status_code:, headers:, body:, reason_phrase: nil)
|
|
24
|
+
@status_code = status_code
|
|
25
|
+
@headers = (headers || {}).each_with_object({}) do |(k, v), acc|
|
|
26
|
+
acc[k.to_s.downcase] = v
|
|
27
|
+
end
|
|
28
|
+
@body = body
|
|
29
|
+
@reason_phrase = reason_phrase
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Case-insensitive header lookup.
|
|
33
|
+
# @param name [String]
|
|
34
|
+
# @return [String, nil]
|
|
35
|
+
def [](name)
|
|
36
|
+
@headers[name.to_s.downcase]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The status code as a String. +Errors::APIError.from_response+ keys
|
|
40
|
+
# +ERROR_MAP+ on the string status, so the object handed to it must expose
|
|
41
|
+
# a string +#code+.
|
|
42
|
+
# @return [String]
|
|
43
|
+
def code
|
|
44
|
+
@status_code.to_s
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/recurly/http.rb
CHANGED
|
@@ -6,9 +6,11 @@ module Recurly
|
|
|
6
6
|
:rate_limit_reset, :date, :proxy_metadata,
|
|
7
7
|
:content_type, :total_records
|
|
8
8
|
|
|
9
|
+
# @param resp [Recurly::HTTP::AdapterResponse] the normalized adapter response
|
|
10
|
+
# @param request [Recurly::HTTP::Request] the request wrapper (relative path)
|
|
9
11
|
def initialize(resp, request)
|
|
10
12
|
@request = Request.new(request.method, request.path, request.body)
|
|
11
|
-
@status = resp.
|
|
13
|
+
@status = resp.status_code
|
|
12
14
|
@request_id = resp["x-request-id"]
|
|
13
15
|
@rate_limit = resp["x-ratelimit-limit"].to_i
|
|
14
16
|
@rate_limit_remaining = resp["x-ratelimit-remaining"].to_i
|
|
@@ -17,7 +19,7 @@ module Recurly
|
|
|
17
19
|
if resp["content-type"]
|
|
18
20
|
@content_type = resp["content-type"].split(";").first
|
|
19
21
|
else
|
|
20
|
-
@content_type =
|
|
22
|
+
@content_type = nil
|
|
21
23
|
end
|
|
22
24
|
if resp.body && !resp.body.empty?
|
|
23
25
|
@body = resp.body
|
|
@@ -79,9 +79,17 @@ module Recurly
|
|
|
79
79
|
define_attribute :plan_codes, Array, { :item_type => String }
|
|
80
80
|
|
|
81
81
|
# @!attribute redeem_by_date
|
|
82
|
-
# @return [String] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time.
|
|
82
|
+
# @return [String] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time. Mutually exclusive with redeem_by_interval_unit/redeem_by_interval_amount.
|
|
83
83
|
define_attribute :redeem_by_date, String
|
|
84
84
|
|
|
85
|
+
# @!attribute redeem_by_interval_amount
|
|
86
|
+
# @return [Integer] Quantity of redeem_by_interval_unit. Must be paired with redeem_by_interval_unit.
|
|
87
|
+
define_attribute :redeem_by_interval_amount, Integer
|
|
88
|
+
|
|
89
|
+
# @!attribute redeem_by_interval_unit
|
|
90
|
+
# @return [String] Unit of the relative redemption window. Must be paired with redeem_by_interval_amount. Mutually exclusive with redeem_by_date. Bulk coupons only.
|
|
91
|
+
define_attribute :redeem_by_interval_unit, String
|
|
92
|
+
|
|
85
93
|
# @!attribute redemption_resource
|
|
86
94
|
# @return [String] Whether the discount is for all eligible charges on the account, or only a specific subscription.
|
|
87
95
|
define_attribute :redemption_resource, String
|
|
@@ -27,8 +27,16 @@ module Recurly
|
|
|
27
27
|
define_attribute :name, String
|
|
28
28
|
|
|
29
29
|
# @!attribute redeem_by_date
|
|
30
|
-
# @return [String] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time.
|
|
30
|
+
# @return [String] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time. Mutually exclusive with redeem_by_interval_unit/redeem_by_interval_amount.
|
|
31
31
|
define_attribute :redeem_by_date, String
|
|
32
|
+
|
|
33
|
+
# @!attribute redeem_by_interval_amount
|
|
34
|
+
# @return [Integer] Quantity of redeem_by_interval_unit. Must be paired with redeem_by_interval_unit.
|
|
35
|
+
define_attribute :redeem_by_interval_amount, Integer
|
|
36
|
+
|
|
37
|
+
# @!attribute redeem_by_interval_unit
|
|
38
|
+
# @return [String] Unit of the relative redemption window. Must be paired with redeem_by_interval_amount. Mutually exclusive with redeem_by_date. Bulk coupons only.
|
|
39
|
+
define_attribute :redeem_by_interval_unit, String
|
|
32
40
|
end
|
|
33
41
|
end
|
|
34
42
|
end
|
|
@@ -50,6 +50,10 @@ module Recurly
|
|
|
50
50
|
# @return [String] This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes to add or override Terms and Conditions.
|
|
51
51
|
define_attribute :terms_and_conditions, String
|
|
52
52
|
|
|
53
|
+
# @!attribute transaction_descriptor_suffix
|
|
54
|
+
# @return [String] Optionally overrides the suffix component of the composed transaction descriptor. If omitted, the suffix is derived from the subscription's plan name or the invoice description, with a Trial prefix on Visa trial conversions. Subject to gateway availability and payment method support.
|
|
55
|
+
define_attribute :transaction_descriptor_suffix, String
|
|
56
|
+
|
|
53
57
|
# @!attribute vat_reverse_charge_notes
|
|
54
58
|
# @return [String] VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription.
|
|
55
59
|
define_attribute :vat_reverse_charge_notes, String
|
|
@@ -42,12 +42,16 @@ module Recurly
|
|
|
42
42
|
# @return [Array[PaymentGatewayReferences]] Array of Payment Gateway References, each a reference to a third-party gateway object of varying types.
|
|
43
43
|
define_attribute :payment_gateway_references, Array, { :item_type => :PaymentGatewayReferences }
|
|
44
44
|
|
|
45
|
+
# @!attribute payment_method
|
|
46
|
+
# @return [RecoveryPaymentMethodCreate] Merchant-supplied fallback payment method metadata. Recurly's own gateway-token lookup is authoritative and will override any of these fields it can determine itself; these fields are only used to fill gaps when that lookup is unavailable.
|
|
47
|
+
define_attribute :payment_method, :RecoveryPaymentMethodCreate
|
|
48
|
+
|
|
45
49
|
# @!attribute primary_payment_method
|
|
46
50
|
# @return [Boolean] The `primary_payment_method` field is used to designate the primary billing info on the account. An account can have a maximum of 1 primary. If a user sets a different payment method as a primary, then the existing primary will no longer be marked as such.
|
|
47
51
|
define_attribute :primary_payment_method, :Boolean
|
|
48
52
|
|
|
49
53
|
# @!attribute transactions
|
|
50
|
-
# @return [Array[RecoveryTransactionCreate]] Transactions from previous collection attempts for this payment method.
|
|
54
|
+
# @return [Array[RecoveryTransactionCreate]] Transactions from previous collection attempts for this payment method. Optional, unless this billing_info is the primary payment method and the account's dunning campaign skips Recurly's own retry attempts entirely -- in that case at least one entry is required.
|
|
51
55
|
define_attribute :transactions, Array, { :item_type => :RecoveryTransactionCreate }
|
|
52
56
|
end
|
|
53
57
|
end
|
|
@@ -29,6 +29,10 @@ module Recurly
|
|
|
29
29
|
# @!attribute po_number
|
|
30
30
|
# @return [String] This identifies the PO number associated with the subscription.
|
|
31
31
|
define_attribute :po_number, String
|
|
32
|
+
|
|
33
|
+
# @!attribute transaction_descriptor_suffix
|
|
34
|
+
# @return [String] Optionally overrides the suffix component of the composed transaction descriptor. If omitted, the suffix is derived from the subscription's plan name or the invoice description, with a Trial prefix on Visa trial conversions. Subject to gateway availability and payment method support.
|
|
35
|
+
define_attribute :transaction_descriptor_suffix, String
|
|
32
36
|
end
|
|
33
37
|
end
|
|
34
38
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file is automatically created by Recurly's OpenAPI generation process
|
|
2
|
+
# and thus any edits you make by hand will be lost. If you wish to make a
|
|
3
|
+
# change to this file, please create a Github issue explaining the changes you
|
|
4
|
+
# need and we will usher them to the appropriate places.
|
|
5
|
+
module Recurly
|
|
6
|
+
module Requests
|
|
7
|
+
class RecoveryPaymentMethodCreate < Request
|
|
8
|
+
|
|
9
|
+
# @!attribute card_type
|
|
10
|
+
# @return [String] The card brand (e.g. `Visa`, `MasterCard`). Present for `credit_card`, `apple_pay`, and `google_pay`/`google_pay_device_pan`; omitted for `paypal_billing_agreement`.
|
|
11
|
+
define_attribute :card_type, String
|
|
12
|
+
|
|
13
|
+
# @!attribute exp_month
|
|
14
|
+
# @return [Integer] Expiration month.
|
|
15
|
+
define_attribute :exp_month, Integer
|
|
16
|
+
|
|
17
|
+
# @!attribute exp_year
|
|
18
|
+
# @return [Integer] Expiration year.
|
|
19
|
+
define_attribute :exp_year, Integer
|
|
20
|
+
|
|
21
|
+
# @!attribute first_six
|
|
22
|
+
# @return [String] For a plain card, the card's own first six digits (BIN). For a tokenized wallet payment (`apple_pay`, `google_pay`, or `google_pay_device_pan`), this is the DPAN's (the wallet/device token's own number) first six digits — **not** the underlying card's (FPAN). The FPAN is never accepted or represented; no separate wallet-specific field is provided.
|
|
23
|
+
define_attribute :first_six, String
|
|
24
|
+
|
|
25
|
+
# @!attribute last_four
|
|
26
|
+
# @return [String] The card's (or, for a tokenized wallet payment, the DPAN's) last four digits. See `first_six` for the DPAN-vs-FPAN distinction on wallets.
|
|
27
|
+
define_attribute :last_four, String
|
|
28
|
+
|
|
29
|
+
# @!attribute object
|
|
30
|
+
# @return [String] The payment method type.
|
|
31
|
+
define_attribute :object, String
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -138,6 +138,10 @@ module Recurly
|
|
|
138
138
|
# @return [Integer] The number of cycles/billing periods in a term. When `remaining_billing_cycles=0`, if `auto_renew=true` the subscription will renew and a new term will begin, otherwise the subscription will expire.
|
|
139
139
|
define_attribute :total_billing_cycles, Integer
|
|
140
140
|
|
|
141
|
+
# @!attribute transaction_descriptor_suffix
|
|
142
|
+
# @return [String] Optionally overrides the suffix component of the composed transaction descriptor. If omitted, the suffix is derived from the subscription's plan name or the invoice description, with a Trial prefix on Visa trial conversions. Subject to gateway availability and payment method support.
|
|
143
|
+
define_attribute :transaction_descriptor_suffix, String
|
|
144
|
+
|
|
141
145
|
# @!attribute transaction_type
|
|
142
146
|
# @return [String] An optional type designation for the payment gateway transaction created by this request. Supports 'moto' value, which is the acronym for mail order and telephone transactions.
|
|
143
147
|
define_attribute :transaction_type, String
|
|
@@ -77,6 +77,10 @@ module Recurly
|
|
|
77
77
|
# @!attribute terms_and_conditions
|
|
78
78
|
# @return [String] Specify custom notes to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.
|
|
79
79
|
define_attribute :terms_and_conditions, String
|
|
80
|
+
|
|
81
|
+
# @!attribute transaction_descriptor_suffix
|
|
82
|
+
# @return [String] Optionally overrides the suffix component of the composed transaction descriptor. If omitted, the suffix is derived from the subscription's plan name or the invoice description, with a Trial prefix on Visa trial conversions. Subject to gateway availability and payment method support.
|
|
83
|
+
define_attribute :transaction_descriptor_suffix, String
|
|
80
84
|
end
|
|
81
85
|
end
|
|
82
86
|
end
|
|
@@ -87,9 +87,17 @@ module Recurly
|
|
|
87
87
|
define_attribute :plans, Array, { :item_type => :PlanMini }
|
|
88
88
|
|
|
89
89
|
# @!attribute redeem_by
|
|
90
|
-
# @return [DateTime] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time.
|
|
90
|
+
# @return [DateTime] The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time. Null for bulk coupons configured with a relative redeem-by interval (see redeem_by_interval_unit and redeem_by_interval_amount).
|
|
91
91
|
define_attribute :redeem_by, DateTime
|
|
92
92
|
|
|
93
|
+
# @!attribute redeem_by_interval_amount
|
|
94
|
+
# @return [Integer] For a bulk coupon with a relative redeem-by, the number of redeem_by_interval_unit intervals after a code's generation that it remains redeemable. Null unless the coupon uses a relative redeem-by.
|
|
95
|
+
define_attribute :redeem_by_interval_amount, Integer
|
|
96
|
+
|
|
97
|
+
# @!attribute redeem_by_interval_unit
|
|
98
|
+
# @return [String] For a bulk coupon with a relative redeem-by, the unit of the interval after which each generated unique code expires. Null unless the coupon uses a relative redeem-by.
|
|
99
|
+
define_attribute :redeem_by_interval_unit, String
|
|
100
|
+
|
|
93
101
|
# @!attribute redemption_resource
|
|
94
102
|
# @return [String] Whether the discount is for all eligible charges on the account, or only a specific subscription.
|
|
95
103
|
define_attribute :redemption_resource, String
|
|
@@ -35,7 +35,7 @@ module Recurly
|
|
|
35
35
|
define_attribute :exp_year, Integer
|
|
36
36
|
|
|
37
37
|
# @!attribute first_six
|
|
38
|
-
# @return [String] Credit card number's first six digits.
|
|
38
|
+
# @return [String] Credit card number's first six digits. For a tokenized wallet payment (`apple_pay`, `google_pay`, or `google_pay_device_pan`), this is the DPAN's (the wallet/device token's own number) first six digits, not the underlying card's (FPAN).
|
|
39
39
|
define_attribute :first_six, String
|
|
40
40
|
|
|
41
41
|
# @!attribute funding_source
|
|
@@ -55,7 +55,7 @@ module Recurly
|
|
|
55
55
|
define_attribute :gateway_token, String
|
|
56
56
|
|
|
57
57
|
# @!attribute last_four
|
|
58
|
-
# @return [String] Credit card number's last four digits. Will refer to bank account if payment method is ACH.
|
|
58
|
+
# @return [String] Credit card number's last four digits. Will refer to bank account if payment method is ACH. For a tokenized wallet payment (`apple_pay`, `google_pay`, or `google_pay_device_pan`), this is the DPAN's last four digits, not the underlying card's (FPAN).
|
|
59
59
|
define_attribute :last_four, String
|
|
60
60
|
|
|
61
61
|
# @!attribute last_two
|
|
@@ -134,6 +134,10 @@ module Recurly
|
|
|
134
134
|
# @return [TransactionPaymentGateway]
|
|
135
135
|
define_attribute :payment_gateway, :TransactionPaymentGateway
|
|
136
136
|
|
|
137
|
+
# @!attribute payment_gateway_references
|
|
138
|
+
# @return [Array[PaymentGatewayReferences]] Array of Payment Gateway References captured at transaction time, each a reference to a third-party gateway object of varying types.
|
|
139
|
+
define_attribute :payment_gateway_references, Array, { :item_type => :PaymentGatewayReferences }
|
|
140
|
+
|
|
137
141
|
# @!attribute payment_method
|
|
138
142
|
# @return [PaymentMethod]
|
|
139
143
|
define_attribute :payment_method, :PaymentMethod
|
|
@@ -34,6 +34,10 @@ module Recurly
|
|
|
34
34
|
# @return [String] Object type
|
|
35
35
|
define_attribute :object, String
|
|
36
36
|
|
|
37
|
+
# @!attribute redeem_by_date
|
|
38
|
+
# @return [DateTime] Absolute expiry computed and stored at code-generation time. Set only for Window (relative redeem-by) coupons. Null for Anytime coupons and Specific Date coupons — those resolve expiry from the parent coupon's redeem_by at redemption time, not at code-generation time.
|
|
39
|
+
define_attribute :redeem_by_date, DateTime
|
|
40
|
+
|
|
37
41
|
# @!attribute redeemed_at
|
|
38
42
|
# @return [DateTime] The date and time the unique coupon code was redeemed.
|
|
39
43
|
define_attribute :redeemed_at, DateTime
|
data/lib/recurly/version.rb
CHANGED
data/lib/recurly.rb
CHANGED
|
@@ -6,8 +6,12 @@ require "recurly/pager"
|
|
|
6
6
|
require "recurly/requests"
|
|
7
7
|
require "recurly/resources"
|
|
8
8
|
require "recurly/http"
|
|
9
|
+
require "recurly/http/http_method"
|
|
10
|
+
require "recurly/http/response"
|
|
9
11
|
require "recurly/errors"
|
|
10
12
|
require "recurly/connection_pool"
|
|
13
|
+
require "recurly/http/adapter"
|
|
14
|
+
require "recurly/http/default_http_adapter"
|
|
11
15
|
require "recurly/client"
|
|
12
16
|
require "recurly/webhooks"
|
|
13
17
|
|