recurly 3.4.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.bumpversion.cfg +5 -1
  3. data/.github/workflows/docs.yml +28 -0
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +107 -13
  6. data/GETTING_STARTED.md +61 -1
  7. data/README.md +1 -1
  8. data/lib/recurly/client.rb +126 -52
  9. data/lib/recurly/client/operations.rb +314 -1
  10. data/lib/recurly/http.rb +3 -2
  11. data/lib/recurly/pager.rb +31 -12
  12. data/lib/recurly/requests/add_on_create.rb +15 -3
  13. data/lib/recurly/requests/add_on_update.rb +9 -1
  14. data/lib/recurly/requests/billing_info_create.rb +26 -2
  15. data/lib/recurly/requests/external_transaction.rb +26 -0
  16. data/lib/recurly/requests/plan_create.rb +8 -0
  17. data/lib/recurly/requests/plan_update.rb +8 -0
  18. data/lib/recurly/requests/shipping_method_create.rb +26 -0
  19. data/lib/recurly/requests/shipping_method_update.rb +26 -0
  20. data/lib/recurly/requests/subscription_add_on_create.rb +9 -1
  21. data/lib/recurly/requests/subscription_add_on_tier.rb +18 -0
  22. data/lib/recurly/requests/subscription_add_on_update.rb +6 -2
  23. data/lib/recurly/requests/subscription_change_create.rb +1 -1
  24. data/lib/recurly/requests/tier.rb +18 -0
  25. data/lib/recurly/resources/add_on.rb +8 -0
  26. data/lib/recurly/resources/line_item.rb +1 -1
  27. data/lib/recurly/resources/payment_method.rb +4 -0
  28. data/lib/recurly/resources/plan.rb +8 -0
  29. data/lib/recurly/resources/shipping_method.rb +4 -0
  30. data/lib/recurly/resources/subscription_add_on.rb +16 -0
  31. data/lib/recurly/resources/subscription_add_on_tier.rb +18 -0
  32. data/lib/recurly/resources/subscription_change_preview.rb +74 -0
  33. data/lib/recurly/resources/tier.rb +18 -0
  34. data/lib/recurly/resources/transaction.rb +4 -0
  35. data/lib/recurly/version.rb +1 -1
  36. data/openapi/api.yaml +5407 -2794
  37. data/recurly.gemspec +8 -0
  38. data/scripts/changelog +2 -0
  39. data/scripts/format +5 -1
  40. data/scripts/release +5 -3
  41. metadata +18 -4
@@ -4,15 +4,16 @@ module Recurly
4
4
  attr_accessor :status, :body, :request,
5
5
  :request_id, :rate_limit, :rate_limit_remaining,
6
6
  :rate_limit_reset, :date, :proxy_metadata,
7
- :content_type
7
+ :content_type, :total_records
8
8
 
9
9
  def initialize(resp, request)
10
- @request = request
10
+ @request = Request.new(request.method, request.path, request.body)
11
11
  @status = resp.code.to_i
12
12
  @request_id = resp["x-request-id"]
13
13
  @rate_limit = resp["x-ratelimit-limit"].to_i
14
14
  @rate_limit_remaining = resp["x-ratelimit-remaining"].to_i
15
15
  @rate_limit_reset = Time.at(resp["x-ratelimit-reset"].to_i).to_datetime
16
+ @total_records = resp["recurly-total-records"]&.to_i
16
17
  if resp["content-type"]
17
18
  @content_type = resp["content-type"].split(";").first
18
19
  else
@@ -7,7 +7,25 @@ module Recurly
7
7
  @client = client
8
8
  @path = path
9
9
  @options = map_array_params(options)
10
- @next = build_path(@path, @options)
10
+ rewind!
11
+ end
12
+
13
+ # Performs a request with the pager `limit` set to 1 and only returns the first
14
+ # result in the response.
15
+ def first
16
+ # Modify the @next url to set the :limit to 1
17
+ original_next = @next
18
+ @next = @path
19
+ fetch_next!(@options.merge(limit: 1))
20
+ # Restore the @next url to the original
21
+ @next = original_next
22
+ @data.first
23
+ end
24
+
25
+ # Makes a HEAD request to the API to determine how many total records exist.
26
+ def count
27
+ resource = @client.send(:head, self.next, @options)
28
+ resource.get_response.total_records
11
29
  end
12
30
 
13
31
  # Enumerates each "page" from the server.
@@ -84,7 +102,9 @@ module Recurly
84
102
  def page_enumerator
85
103
  Enumerator.new do |yielder|
86
104
  loop do
87
- fetch_next!
105
+ # Pass in @options when requesting the first page (@data.empty?)
106
+ next_options = @data.empty? ? @options : {}
107
+ fetch_next!(next_options)
88
108
  yielder << data
89
109
  unless has_more?
90
110
  rewind!
@@ -94,8 +114,9 @@ module Recurly
94
114
  end
95
115
  end
96
116
 
97
- def fetch_next!
98
- page = @client.next_page(self)
117
+ def fetch_next!(options)
118
+ path = extract_path(self.next)
119
+ page = @client.send(:get, path, options)
99
120
  @data = page.data.map { |d| JSONParser.from_json(d) }
100
121
  @has_more = page.has_more
101
122
  @next = page.next
@@ -103,15 +124,13 @@ module Recurly
103
124
 
104
125
  def rewind!
105
126
  @data = []
106
- @next = build_path(@path, @options)
127
+ @next = @path
107
128
  end
108
129
 
109
- def build_path(path, options)
110
- if options.empty?
111
- path
112
- else
113
- "#{path}?#{URI.encode_www_form(options)}"
114
- end
130
+ # Returns just the path and parameters so we can safely reuse the connection
131
+ def extract_path(uri_or_path)
132
+ uri = URI(uri_or_path)
133
+ uri.kind_of?(URI::HTTP) ? uri.request_uri : uri_or_path
115
134
  end
116
135
 
117
136
  # Converts array parameters to CSV strings to maintain consistency with
@@ -121,7 +140,7 @@ module Recurly
121
140
  @options = params.map do |key, param|
122
141
  new_param = param.is_a?(Array) ? param.join(",") : param
123
142
  [key, new_param]
124
- end
143
+ end.to_h
125
144
  end
126
145
  end
127
146
  end
@@ -15,7 +15,7 @@ module Recurly
15
15
  define_attribute :code, String
16
16
 
17
17
  # @!attribute currencies
18
- # @return [Array[AddOnPricing]] If `item_code`/`item_id` is part of the request and the item has a default currency then `currencies` is optional. If the item does not have a default currency, then `currencies` is required. If `item_code`/`item_id` is not present `currencies` is required.
18
+ # @return [Array[AddOnPricing]] * If `item_code`/`item_id` is part of the request and the item has a default currency then `currencies` is optional. If the item does not have a default currency, then `currencies` is required. If `item_code`/`item_id` is not present `currencies` is required. * If the add-on's `tier_type` is `tiered`, `volume`, or `stairstep`, then `currencies` must be absent.
19
19
  define_attribute :currencies, Array, { :item_type => :AddOnPricing }
20
20
 
21
21
  # @!attribute default_quantity
@@ -27,17 +27,21 @@ module Recurly
27
27
  define_attribute :display_quantity, :Boolean
28
28
 
29
29
  # @!attribute item_code
30
- # @return [String] Unique code to identify an item. Avaliable when the `Catalog: Item Add-Ons` feature is enabled. If `item_id` and `item_code` are both present, `item_id` will be used.
30
+ # @return [String] Unique code to identify an item. Avaliable when the `Credit Invoices` and `Subscription Billing Terms` features are enabled. If `item_id` and `item_code` are both present, `item_id` will be used.
31
31
  define_attribute :item_code, String
32
32
 
33
33
  # @!attribute item_id
34
- # @return [String] System-generated unique identifier for an item. Available when the `Catalog: Item Add-Ons` feature is enabled. If `item_id` and `item_code` are both present, `item_id` will be used.
34
+ # @return [String] System-generated unique identifier for an item. Available when the `Credit Invoices` and `Subscription Billing Terms` features are enabled. If `item_id` and `item_code` are both present, `item_id` will be used.
35
35
  define_attribute :item_id, String
36
36
 
37
37
  # @!attribute name
38
38
  # @return [String] Describes your add-on and will appear in subscribers' invoices. If `item_code`/`item_id` is part of the request then `name` must be absent. If `item_code`/`item_id` is not present `name` is required.
39
39
  define_attribute :name, String
40
40
 
41
+ # @!attribute optional
42
+ # @return [Boolean] Whether the add-on is optional for the customer to include in their purchase on the hosted payment page. If false, the add-on will be included when a subscription is created through the Recurly UI. However, the add-on will not be included when a subscription is created through the API.
43
+ define_attribute :optional, :Boolean
44
+
41
45
  # @!attribute plan_id
42
46
  # @return [String] Plan ID
43
47
  define_attribute :plan_id, String
@@ -49,6 +53,14 @@ module Recurly
49
53
  # @!attribute tax_code
50
54
  # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If `item_code`/`item_id` is part of the request then `tax_code` must be absent.
51
55
  define_attribute :tax_code, String
56
+
57
+ # @!attribute tier_type
58
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based).
59
+ define_attribute :tier_type, String
60
+
61
+ # @!attribute tiers
62
+ # @return [Array[Tier]] If the tier_type is `flat`, then `tiers` must be absent. The `tiers` object must include one to many tiers with `ending_quantity` and `unit_amount` for the desired `currencies`. There must be one tier with an `ending_quantity` of 999999999 which is the default if not provided.
63
+ define_attribute :tiers, Array, { :item_type => :Tier }
52
64
  end
53
65
  end
54
66
  end
@@ -15,7 +15,7 @@ module Recurly
15
15
  define_attribute :code, String
16
16
 
17
17
  # @!attribute currencies
18
- # @return [Array[AddOnPricing]] Add-on pricing
18
+ # @return [Array[AddOnPricing]] If the add-on's `tier_type` is `tiered`, `volume` or `stairstep`, then `currencies` must be absent.
19
19
  define_attribute :currencies, Array, { :item_type => :AddOnPricing }
20
20
 
21
21
  # @!attribute default_quantity
@@ -34,6 +34,10 @@ module Recurly
34
34
  # @return [String] Describes your add-on and will appear in subscribers' invoices. If an `Item` is associated to the `AddOn` then `name` must be absent.
35
35
  define_attribute :name, String
36
36
 
37
+ # @!attribute optional
38
+ # @return [Boolean] Whether the add-on is optional for the customer to include in their purchase on the hosted payment page. If false, the add-on will be included when a subscription is created through the Recurly UI. However, the add-on will not be included when a subscription is created through the API.
39
+ define_attribute :optional, :Boolean
40
+
37
41
  # @!attribute revenue_schedule_type
38
42
  # @return [String] When this add-on is invoiced, the line item will use this revenue schedule. If an `Item` is associated to the `AddOn` then `revenue_schedule_type` must be absent in the request as the value will be set from the item.
39
43
  define_attribute :revenue_schedule_type, String
@@ -41,6 +45,10 @@ module Recurly
41
45
  # @!attribute tax_code
42
46
  # @return [String] Optional field used by Avalara, Vertex, and Recurly's EU VAT tax feature to determine taxation rules. If you have your own AvaTax or Vertex account configured, use their tax codes to assign specific tax rules. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If an `Item` is associated to the `AddOn` then `tax code` must be absent.
43
47
  define_attribute :tax_code, String
48
+
49
+ # @!attribute tiers
50
+ # @return [Array[Tier]] If the tier_type is `flat`, then `tiers` must be absent. The `tiers` object must include one to many tiers with `ending_quantity` and `unit_amount` for the desired `currencies`. There must be one tier with an `ending_quantity` of 999999999 which is the default if not provided.
51
+ define_attribute :tiers, Array, { :item_type => :Tier }
44
52
  end
45
53
  end
46
54
  end
@@ -6,6 +6,14 @@ module Recurly
6
6
  module Requests
7
7
  class BillingInfoCreate < Request
8
8
 
9
+ # @!attribute account_number
10
+ # @return [String] The bank account number. (ACH, Bacs only)
11
+ define_attribute :account_number, String
12
+
13
+ # @!attribute account_type
14
+ # @return [String] The bank account type. (ACH only)
15
+ define_attribute :account_type, String
16
+
9
17
  # @!attribute address
10
18
  # @return [Address]
11
19
  define_attribute :address, :Address
@@ -39,7 +47,7 @@ module Recurly
39
47
  define_attribute :gateway_token, String
40
48
 
41
49
  # @!attribute iban
42
- # @return [String] The International Bank Account Number, up to 34 alphanumeric characters comprising a country code; two check digits; and a number that includes the domestic bank account number, branch identifier, and potential routing information
50
+ # @return [String] The International Bank Account Number, up to 34 alphanumeric characters comprising a country code; two check digits; and a number that includes the domestic bank account number, branch identifier, and potential routing information. (SEPA only)
43
51
  define_attribute :iban, String
44
52
 
45
53
  # @!attribute ip_address
@@ -54,6 +62,10 @@ module Recurly
54
62
  # @return [String] Expiration month
55
63
  define_attribute :month, String
56
64
 
65
+ # @!attribute name_on_account
66
+ # @return [String] The name associated with the bank account (ACH, SEPA, Bacs only)
67
+ define_attribute :name_on_account, String
68
+
57
69
  # @!attribute number
58
70
  # @return [String] Credit card number, spaces and dashes are accepted.
59
71
  define_attribute :number, String
@@ -62,18 +74,30 @@ module Recurly
62
74
  # @return [String] PayPal billing agreement ID
63
75
  define_attribute :paypal_billing_agreement_id, String
64
76
 
77
+ # @!attribute routing_number
78
+ # @return [String] The bank's rounting number. (ACH only)
79
+ define_attribute :routing_number, String
80
+
81
+ # @!attribute sort_code
82
+ # @return [String] Bank identifier code for UK based banks. Required for Bacs based billing infos. (Bacs only)
83
+ define_attribute :sort_code, String
84
+
65
85
  # @!attribute three_d_secure_action_result_token_id
66
86
  # @return [String] A token generated by Recurly.js after completing a 3-D Secure device fingerprinting or authentication challenge.
67
87
  define_attribute :three_d_secure_action_result_token_id, String
68
88
 
69
89
  # @!attribute token_id
70
- # @return [String] A token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token).
90
+ # @return [String] A token [generated by Recurly.js](https://developers.recurly.com/reference/recurly-js/#getting-a-token).
71
91
  define_attribute :token_id, String
72
92
 
73
93
  # @!attribute transaction_type
74
94
  # @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.
75
95
  define_attribute :transaction_type, String
76
96
 
97
+ # @!attribute type
98
+ # @return [String] The payment method type for a non-credit card based billing info. The value of `bacs` is the only accepted value (Bacs only)
99
+ define_attribute :type, String
100
+
77
101
  # @!attribute vat_number
78
102
  # @return [String] VAT number
79
103
  define_attribute :vat_number, String
@@ -0,0 +1,26 @@
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 ExternalTransaction < Request
8
+
9
+ # @!attribute amount
10
+ # @return [Float] The total amount of the transcaction. Cannot excceed the invoice total.
11
+ define_attribute :amount, Float
12
+
13
+ # @!attribute collected_at
14
+ # @return [DateTime] Datetime that the external payment was collected. Defaults to current datetime.
15
+ define_attribute :collected_at, DateTime
16
+
17
+ # @!attribute description
18
+ # @return [String] Used as the transaction's description.
19
+ define_attribute :description, String
20
+
21
+ # @!attribute payment_method
22
+ # @return [String] Payment method used for the external transaction.
23
+ define_attribute :payment_method, String
24
+ end
25
+ end
26
+ end
@@ -14,6 +14,10 @@ module Recurly
14
14
  # @return [Array[AddOnCreate]] Add Ons
15
15
  define_attribute :add_ons, Array, { :item_type => :AddOnCreate }
16
16
 
17
+ # @!attribute allow_any_item_on_subscriptions
18
+ # @return [Boolean] Used to determine whether items can be assigned as add-ons to individual subscriptions. If `true`, items can be assigned as add-ons to individual subscription add-ons. If `false`, only plan add-ons can be used.
19
+ define_attribute :allow_any_item_on_subscriptions, :Boolean
20
+
17
21
  # @!attribute auto_renew
18
22
  # @return [Boolean] Subscriptions will automatically inherit this value once they are active. If `auto_renew` is `true`, then a subscription will automatically renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself.
19
23
  define_attribute :auto_renew, :Boolean
@@ -74,6 +78,10 @@ module Recurly
74
78
  # @return [Integer] Length of plan's trial period in `trial_units`. `0` means `no trial`.
75
79
  define_attribute :trial_length, Integer
76
80
 
81
+ # @!attribute trial_requires_billing_info
82
+ # @return [Boolean] Allow free trial subscriptions to be created without billing info. Should not be used if billing info is needed for initial invoice due to existing uninvoiced charges or setup fee.
83
+ define_attribute :trial_requires_billing_info, :Boolean
84
+
77
85
  # @!attribute trial_unit
78
86
  # @return [String] Units for the plan's trial period.
79
87
  define_attribute :trial_unit, String
@@ -14,6 +14,10 @@ module Recurly
14
14
  # @return [Array[AddOnCreate]] Add Ons
15
15
  define_attribute :add_ons, Array, { :item_type => :AddOnCreate }
16
16
 
17
+ # @!attribute allow_any_item_on_subscriptions
18
+ # @return [Boolean] Used to determine whether items can be assigned as add-ons to individual subscriptions. If `true`, items can be assigned as add-ons to individual subscription add-ons. If `false`, only plan add-ons can be used.
19
+ define_attribute :allow_any_item_on_subscriptions, :Boolean
20
+
17
21
  # @!attribute auto_renew
18
22
  # @return [Boolean] Subscriptions will automatically inherit this value once they are active. If `auto_renew` is `true`, then a subscription will automatically renew its term at renewal. If `auto_renew` is `false`, then a subscription will expire at the end of its term. `auto_renew` can be overridden on the subscription record itself.
19
23
  define_attribute :auto_renew, :Boolean
@@ -70,6 +74,10 @@ module Recurly
70
74
  # @return [Integer] Length of plan's trial period in `trial_units`. `0` means `no trial`.
71
75
  define_attribute :trial_length, Integer
72
76
 
77
+ # @!attribute trial_requires_billing_info
78
+ # @return [Boolean] Allow free trial subscriptions to be created without billing info. Should not be used if billing info is needed for initial invoice due to existing uninvoiced charges or setup fee.
79
+ define_attribute :trial_requires_billing_info, :Boolean
80
+
73
81
  # @!attribute trial_unit
74
82
  # @return [String] Units for the plan's trial period.
75
83
  define_attribute :trial_unit, String
@@ -0,0 +1,26 @@
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 ShippingMethodCreate < Request
8
+
9
+ # @!attribute accounting_code
10
+ # @return [String] Accounting code for shipping method.
11
+ define_attribute :accounting_code, String
12
+
13
+ # @!attribute code
14
+ # @return [String] The internal name used identify the shipping method.
15
+ define_attribute :code, String
16
+
17
+ # @!attribute name
18
+ # @return [String] The name of the shipping method displayed to customers.
19
+ define_attribute :name, String
20
+
21
+ # @!attribute tax_code
22
+ # @return [String] Used by Avalara, Vertex, and Recurly’s built-in tax feature. The tax code values are specific to each tax system. If you are using Recurly’s built-in taxes the values are: - `FR` – Common Carrier FOB Destination - `FR022000` – Common Carrier FOB Origin - `FR020400` – Non Common Carrier FOB Destination - `FR020500` – Non Common Carrier FOB Origin - `FR010100` – Delivery by Company Vehicle Before Passage of Title - `FR010200` – Delivery by Company Vehicle After Passage of Title - `NT` – Non-Taxable
23
+ define_attribute :tax_code, String
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
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 ShippingMethodUpdate < Request
8
+
9
+ # @!attribute accounting_code
10
+ # @return [String] Accounting code for shipping method.
11
+ define_attribute :accounting_code, String
12
+
13
+ # @!attribute code
14
+ # @return [String] The internal name used identify the shipping method.
15
+ define_attribute :code, String
16
+
17
+ # @!attribute name
18
+ # @return [String] The name of the shipping method displayed to customers.
19
+ define_attribute :name, String
20
+
21
+ # @!attribute tax_code
22
+ # @return [String] Used by Avalara, Vertex, and Recurly’s built-in tax feature. The tax code values are specific to each tax system. If you are using Recurly’s built-in taxes the values are: - `FR` – Common Carrier FOB Destination - `FR022000` – Common Carrier FOB Origin - `FR020400` – Non Common Carrier FOB Destination - `FR020500` – Non Common Carrier FOB Origin - `FR010100` – Delivery by Company Vehicle Before Passage of Title - `FR010200` – Delivery by Company Vehicle After Passage of Title - `NT` – Non-Taxable
23
+ define_attribute :tax_code, String
24
+ end
25
+ end
26
+ end
@@ -6,6 +6,10 @@ module Recurly
6
6
  module Requests
7
7
  class SubscriptionAddOnCreate < Request
8
8
 
9
+ # @!attribute add_on_source
10
+ # @return [String] Used to determine where the associated add-on data is pulled from. If this value is set to `plan_add_on` or left blank, then add_on data will be pulled from the plan's add-ons. If the associated `plan` has `allow_any_item_on_subscriptions` set to `true` and this field is set to `item`, then the associated add-on data will be pulled from the site's item catalog.
11
+ define_attribute :add_on_source, String
12
+
9
13
  # @!attribute code
10
14
  # @return [String] Add-on code
11
15
  define_attribute :code, String
@@ -18,8 +22,12 @@ module Recurly
18
22
  # @return [String] Revenue schedule type
19
23
  define_attribute :revenue_schedule_type, String
20
24
 
25
+ # @!attribute tiers
26
+ # @return [Array[SubscriptionAddOnTier]] If the plan add-on's `tier_type` is `flat`, then `tiers` must be absent. The `tiers` object must include one to many tiers with `ending_quantity` and `unit_amount`. There must be one tier with an `ending_quantity` of 999999999 which is the default if not provided.
27
+ define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
28
+
21
29
  # @!attribute unit_amount
22
- # @return [Float] Optionally, override the add-on's default unit amount.
30
+ # @return [Float] * Optionally, override the add-on's default unit amount. * If the plan add-on's `tier_type` is `tiered`, `volume`, or `stairstep`, then `unit_amount` must be absent.
23
31
  define_attribute :unit_amount, Float
24
32
  end
25
33
  end
@@ -0,0 +1,18 @@
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 SubscriptionAddOnTier < Request
8
+
9
+ # @!attribute ending_quantity
10
+ # @return [Integer] Ending quantity
11
+ define_attribute :ending_quantity, Integer
12
+
13
+ # @!attribute unit_amount
14
+ # @return [Float] Unit amount
15
+ define_attribute :unit_amount, Float
16
+ end
17
+ end
18
+ end
@@ -7,11 +7,11 @@ module Recurly
7
7
  class SubscriptionAddOnUpdate < Request
8
8
 
9
9
  # @!attribute code
10
- # @return [String] Add-on code
10
+ # @return [String] If a code is provided without an id, the subscription add-on attributes will be set to the current value for those attributes on the plan add-on unless provided in the request.
11
11
  define_attribute :code, String
12
12
 
13
13
  # @!attribute id
14
- # @return [String] Set this to include or modify an existing subscription add-on.
14
+ # @return [String] When an id is provided, the existing subscription add-on attributes will persist unless overridden in the request.
15
15
  define_attribute :id, String
16
16
 
17
17
  # @!attribute quantity
@@ -22,6 +22,10 @@ module Recurly
22
22
  # @return [String] Revenue schedule type
23
23
  define_attribute :revenue_schedule_type, String
24
24
 
25
+ # @!attribute tiers
26
+ # @return [Array[SubscriptionAddOnTier]] If the plan add-on's `tier_type` is `flat`, then `tiers` must be absent. The `tiers` object must include one to many tiers with `ending_quantity` and `unit_amount`. There must be one tier with an `ending_quantity` of 999999999 which is the default if not provided.
27
+ define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
28
+
25
29
  # @!attribute unit_amount
26
30
  # @return [Float] Optionally, override the add-on's default unit amount.
27
31
  define_attribute :unit_amount, Float
@@ -7,7 +7,7 @@ module Recurly
7
7
  class SubscriptionChangeCreate < Request
8
8
 
9
9
  # @!attribute add_ons
10
- # @return [Array[SubscriptionAddOnUpdate]] If you provide a value for this field it will replace any existing add-ons. So, when adding or modifying an add-on, you need to include the existing subscription add-ons. Unchanged add-ons can be included just using the subscription add-on's ID: `{"id": "abc123"}`.
10
+ # @return [Array[SubscriptionAddOnUpdate]] If you provide a value for this field it will replace any existing add-ons. So, when adding or modifying an add-on, you need to include the existing subscription add-ons. Unchanged add-ons can be included just using the subscription add-on's ID: `{"id": "abc123"}`. If a subscription add-on's `code` is supplied without the `id`, `{"code": "def456"}`, the subscription add-on attributes will be set to the current values of the plan add-on unless provided in the request. - If an `id` is passed, any attributes not passed in will pull from the existing subscription add-on - If a `code` is passed, any attributes not passed in will pull from the current values of the plan add-on - Attributes passed in as part of the request will override either of the above scenarios
11
11
  define_attribute :add_ons, Array, { :item_type => :SubscriptionAddOnUpdate }
12
12
 
13
13
  # @!attribute collection_method