recurly 3.5.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.bumpversion.cfg +5 -1
  3. data/CHANGELOG.md +73 -2
  4. data/GETTING_STARTED.md +61 -1
  5. data/lib/recurly/client.rb +79 -26
  6. data/lib/recurly/client/operations.rb +662 -57
  7. data/lib/recurly/errors/api_errors.rb +59 -17
  8. data/lib/recurly/requests/add_on_create.rb +24 -4
  9. data/lib/recurly/requests/add_on_update.rb +13 -1
  10. data/lib/recurly/requests/billing_info_create.rb +11 -3
  11. data/lib/recurly/requests/external_transaction.rb +26 -0
  12. data/lib/recurly/requests/measured_unit_create.rb +22 -0
  13. data/lib/recurly/requests/measured_unit_update.rb +22 -0
  14. data/lib/recurly/requests/plan_create.rb +8 -0
  15. data/lib/recurly/requests/plan_update.rb +8 -0
  16. data/lib/recurly/requests/shipping_method_create.rb +26 -0
  17. data/lib/recurly/requests/shipping_method_update.rb +26 -0
  18. data/lib/recurly/requests/subscription_add_on_create.rb +10 -2
  19. data/lib/recurly/requests/subscription_add_on_update.rb +11 -3
  20. data/lib/recurly/requests/subscription_change_create.rb +1 -1
  21. data/lib/recurly/requests/subscription_purchase.rb +4 -0
  22. data/lib/recurly/requests/usage_create.rb +26 -0
  23. data/lib/recurly/resources/add_on.rb +16 -0
  24. data/lib/recurly/resources/add_on_mini.rb +16 -0
  25. data/lib/recurly/resources/line_item.rb +1 -1
  26. data/lib/recurly/resources/measured_unit.rb +46 -0
  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 +13 -1
  31. data/lib/recurly/resources/subscription_change.rb +4 -0
  32. data/lib/recurly/resources/subscription_change_preview.rb +74 -0
  33. data/lib/recurly/resources/transaction.rb +4 -0
  34. data/lib/recurly/resources/usage.rb +62 -0
  35. data/lib/recurly/version.rb +1 -1
  36. data/openapi/api.yaml +6242 -2891
  37. data/recurly.gemspec +1 -1
  38. data/scripts/format +5 -1
  39. metadata +13 -4
@@ -4,38 +4,80 @@
4
4
  # need and we will usher them to the appropriate places.
5
5
  module Recurly
6
6
  module Errors
7
- class BadRequestError < Errors::APIError; end
7
+ ERROR_MAP = {
8
+ "500" => "InternalServerError",
9
+ "502" => "BadGatewayError",
10
+ "503" => "ServiceUnavailableError",
11
+ "304" => "NotModifiedError",
12
+ "400" => "BadRequestError",
13
+ "401" => "UnauthorizedError",
14
+ "402" => "PaymentRequiredError",
15
+ "403" => "ForbiddenError",
16
+ "404" => "NotFoundError",
17
+ "406" => "NotAcceptableError",
18
+ "412" => "PreconditionFailedError",
19
+ "422" => "UnprocessableEntityError",
20
+ "429" => "TooManyRequestsError",
21
+ }
8
22
 
9
- class InternalServerError < Errors::APIError; end
23
+ class ResponseError < Errors::APIError; end
10
24
 
11
- class ImmutableSubscriptionError < Errors::APIError; end
25
+ class ServerError < ResponseError; end
12
26
 
13
- class InvalidApiKeyError < Errors::APIError; end
27
+ class InternalServerError < ServerError; end
14
28
 
15
- class InvalidApiVersionError < Errors::APIError; end
29
+ class BadGatewayError < ServerError; end
16
30
 
17
- class InvalidContentTypeError < Errors::APIError; end
31
+ class ServiceUnavailableError < ServerError; end
18
32
 
19
- class InvalidPermissionsError < Errors::APIError; end
33
+ class RedirectionError < ResponseError; end
20
34
 
21
- class InvalidTokenError < Errors::APIError; end
35
+ class NotModifiedError < ResponseError; end
22
36
 
23
- class NotFoundError < Errors::APIError; end
37
+ class ClientError < Errors::APIError; end
24
38
 
25
- class SimultaneousRequestError < Errors::APIError; end
39
+ class BadRequestError < ClientError; end
26
40
 
27
- class TransactionError < Errors::APIError; end
41
+ class InvalidContentTypeError < BadRequestError; end
28
42
 
29
- class UnauthorizedError < Errors::APIError; end
43
+ class UnauthorizedError < ClientError; end
30
44
 
31
- class UnavailableInApiVersionError < Errors::APIError; end
45
+ class PaymentRequiredError < ClientError; end
32
46
 
33
- class UnknownApiVersionError < Errors::APIError; end
47
+ class ForbiddenError < ClientError; end
34
48
 
35
- class ValidationError < Errors::APIError; end
49
+ class InvalidApiKeyError < ForbiddenError; end
36
50
 
37
- class MissingFeatureError < Errors::APIError; end
51
+ class InvalidPermissionsError < ForbiddenError; end
38
52
 
39
- class RateLimitedError < Errors::APIError; end
53
+ class NotFoundError < ClientError; end
54
+
55
+ class NotAcceptableError < ClientError; end
56
+
57
+ class UnknownApiVersionError < NotAcceptableError; end
58
+
59
+ class UnavailableInApiVersionError < NotAcceptableError; end
60
+
61
+ class InvalidApiVersionError < NotAcceptableError; end
62
+
63
+ class PreconditionFailedError < ClientError; end
64
+
65
+ class UnprocessableEntityError < ClientError; end
66
+
67
+ class ValidationError < UnprocessableEntityError; end
68
+
69
+ class MissingFeatureError < UnprocessableEntityError; end
70
+
71
+ class TransactionError < UnprocessableEntityError; end
72
+
73
+ class SimultaneousRequestError < UnprocessableEntityError; end
74
+
75
+ class ImmutableSubscriptionError < UnprocessableEntityError; end
76
+
77
+ class InvalidTokenError < UnprocessableEntityError; end
78
+
79
+ class TooManyRequestsError < ClientError; end
80
+
81
+ class RateLimitedError < TooManyRequestsError; end
40
82
  end
41
83
  end
@@ -10,6 +10,10 @@ module Recurly
10
10
  # @return [String] Accounting code for invoice line items for this add-on. If no value is provided, it defaults to add-on's code. If `item_code`/`item_id` is part of the request then `accounting_code` must be absent.
11
11
  define_attribute :accounting_code, String
12
12
 
13
+ # @!attribute add_on_type
14
+ # @return [String] Whether the add-on type is fixed, or usage-based.
15
+ define_attribute :add_on_type, String
16
+
13
17
  # @!attribute code
14
18
  # @return [String] The unique identifier for the add-on within its plan. If `item_code`/`item_id` is part of the request then `code` must be absent. If `item_code`/`item_id` is not present `code` is required.
15
19
  define_attribute :code, String
@@ -27,13 +31,21 @@ module Recurly
27
31
  define_attribute :display_quantity, :Boolean
28
32
 
29
33
  # @!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.
34
+ # @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
35
  define_attribute :item_code, String
32
36
 
33
37
  # @!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.
38
+ # @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
39
  define_attribute :item_id, String
36
40
 
41
+ # @!attribute measured_unit_id
42
+ # @return [String] System-generated unique identifier for a measured unit to be associated with the add-on. Either `measured_unit_id` or `measured_unit_name` are required when `add_on_type` is `usage`. If `measured_unit_id` and `measured_unit_name` are both present, `measured_unit_id` will be used.
43
+ define_attribute :measured_unit_id, String
44
+
45
+ # @!attribute measured_unit_name
46
+ # @return [String] Name of a measured unit to be associated with the add-on. Either `measured_unit_id` or `measured_unit_name` are required when `add_on_type` is `usage`. If `measured_unit_id` and `measured_unit_name` are both present, `measured_unit_id` will be used.
47
+ define_attribute :measured_unit_name, String
48
+
37
49
  # @!attribute name
38
50
  # @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
51
  define_attribute :name, String
@@ -55,12 +67,20 @@ module Recurly
55
67
  define_attribute :tax_code, String
56
68
 
57
69
  # @!attribute tier_type
58
- # @return [String] The type of tiering used by the Add-on.
70
+ # @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
71
  define_attribute :tier_type, String
60
72
 
61
73
  # @!attribute tiers
62
- # @return [Array[Tier]] At least one tier is required if `tier_type` is not 'flat'.
74
+ # @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
75
  define_attribute :tiers, Array, { :item_type => :Tier }
76
+
77
+ # @!attribute usage_percentage
78
+ # @return [Float] The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0. Required if `add_on_type` is usage and `usage_type` is percentage. Must be omitted otherwise. `usage_percentage` does not support tiers.
79
+ define_attribute :usage_percentage, Float
80
+
81
+ # @!attribute usage_type
82
+ # @return [String] Type of usage, required if `add_on_type` is `usage`.
83
+ define_attribute :usage_type, String
64
84
  end
65
85
  end
66
86
  end
@@ -30,6 +30,14 @@ module Recurly
30
30
  # @return [String] Add-on ID
31
31
  define_attribute :id, String
32
32
 
33
+ # @!attribute measured_unit_id
34
+ # @return [String] System-generated unique identifier for a measured unit to be associated with the add-on. Either `measured_unit_id` or `measured_unit_name` are required when `add_on_type` is `usage`. If `measured_unit_id` and `measured_unit_name` are both present, `measured_unit_id` will be used.
35
+ define_attribute :measured_unit_id, String
36
+
37
+ # @!attribute measured_unit_name
38
+ # @return [String] Name of a measured unit to be associated with the add-on. Either `measured_unit_id` or `measured_unit_name` are required when `add_on_type` is `usage`. If `measured_unit_id` and `measured_unit_name` are both present, `measured_unit_id` will be used.
39
+ define_attribute :measured_unit_name, String
40
+
33
41
  # @!attribute name
34
42
  # @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
43
  define_attribute :name, String
@@ -47,8 +55,12 @@ module Recurly
47
55
  define_attribute :tax_code, String
48
56
 
49
57
  # @!attribute tiers
50
- # @return [Array[Tier]] If tiers are provided in the request, all existing tiers on the Add-on will be removed and replaced by the tiers in the request.
58
+ # @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
59
  define_attribute :tiers, Array, { :item_type => :Tier }
60
+
61
+ # @!attribute usage_percentage
62
+ # @return [Float] The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0. Required if `add_on_type` is usage and `usage_type` is percentage. Must be omitted otherwise. `usage_percentage` does not support tiers.
63
+ define_attribute :usage_percentage, Float
52
64
  end
53
65
  end
54
66
  end
@@ -7,7 +7,7 @@ module Recurly
7
7
  class BillingInfoCreate < Request
8
8
 
9
9
  # @!attribute account_number
10
- # @return [String] The bank account number. (ACH only)
10
+ # @return [String] The bank account number. (ACH, Bacs only)
11
11
  define_attribute :account_number, String
12
12
 
13
13
  # @!attribute account_type
@@ -63,7 +63,7 @@ module Recurly
63
63
  define_attribute :month, String
64
64
 
65
65
  # @!attribute name_on_account
66
- # @return [String] The name associated with the bank account.
66
+ # @return [String] The name associated with the bank account (ACH, SEPA, Bacs only)
67
67
  define_attribute :name_on_account, String
68
68
 
69
69
  # @!attribute number
@@ -78,18 +78,26 @@ module Recurly
78
78
  # @return [String] The bank's rounting number. (ACH only)
79
79
  define_attribute :routing_number, String
80
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
+
81
85
  # @!attribute three_d_secure_action_result_token_id
82
86
  # @return [String] A token generated by Recurly.js after completing a 3-D Secure device fingerprinting or authentication challenge.
83
87
  define_attribute :three_d_secure_action_result_token_id, String
84
88
 
85
89
  # @!attribute token_id
86
- # @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).
87
91
  define_attribute :token_id, String
88
92
 
89
93
  # @!attribute transaction_type
90
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.
91
95
  define_attribute :transaction_type, String
92
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
+
93
101
  # @!attribute vat_number
94
102
  # @return [String] VAT number
95
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
@@ -0,0 +1,22 @@
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 MeasuredUnitCreate < Request
8
+
9
+ # @!attribute description
10
+ # @return [String] Optional internal description.
11
+ define_attribute :description, String
12
+
13
+ # @!attribute display_name
14
+ # @return [String] Display name for the measured unit.
15
+ define_attribute :display_name, String
16
+
17
+ # @!attribute name
18
+ # @return [String] Unique internal name of the measured unit on your site.
19
+ define_attribute :name, String
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
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 MeasuredUnitUpdate < Request
8
+
9
+ # @!attribute description
10
+ # @return [String] Optional internal description.
11
+ define_attribute :description, String
12
+
13
+ # @!attribute display_name
14
+ # @return [String] Display name for the measured unit.
15
+ define_attribute :display_name, String
16
+
17
+ # @!attribute name
18
+ # @return [String] Unique internal name of the measured unit on your site.
19
+ define_attribute :name, String
20
+ end
21
+ end
22
+ 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,8 +6,12 @@ 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
- # @return [String] Add-on code
14
+ # @return [String] If `add_on_source` is set to `plan_add_on` or left blank, then plan's add-on `code` should be used. If `add_on_source` is set to `item`, then the `code` from the associated item should be used.
11
15
  define_attribute :code, String
12
16
 
13
17
  # @!attribute quantity
@@ -19,12 +23,16 @@ module Recurly
19
23
  define_attribute :revenue_schedule_type, String
20
24
 
21
25
  # @!attribute tiers
22
- # @return [Array[SubscriptionAddOnTier]] If the plan add-on's `tier_type` is `flat`, then `tiers` must be absent.
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.
23
27
  define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
24
28
 
25
29
  # @!attribute unit_amount
26
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.
27
31
  define_attribute :unit_amount, Float
32
+
33
+ # @!attribute usage_percentage
34
+ # @return [Float] The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0. Required if `add_on_type` is usage and `usage_type` is percentage. Must be omitted otherwise. `usage_percentage` does not support tiers.
35
+ define_attribute :usage_percentage, Float
28
36
  end
29
37
  end
30
38
  end
@@ -6,12 +6,16 @@ module Recurly
6
6
  module Requests
7
7
  class SubscriptionAddOnUpdate < 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
- # @return [String] Add-on code
14
+ # @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. If `add_on_source` is set to `plan_add_on` or left blank, then plan's add-on `code` should be used. If `add_on_source` is set to `item`, then the `code` from the associated item should be used.
11
15
  define_attribute :code, String
12
16
 
13
17
  # @!attribute id
14
- # @return [String] Set this to include or modify an existing subscription add-on.
18
+ # @return [String] When an id is provided, the existing subscription add-on attributes will persist unless overridden in the request.
15
19
  define_attribute :id, String
16
20
 
17
21
  # @!attribute quantity
@@ -23,12 +27,16 @@ module Recurly
23
27
  define_attribute :revenue_schedule_type, String
24
28
 
25
29
  # @!attribute tiers
26
- # @return [Array[SubscriptionAddOnTier]] If the plan add-on's `tier_type` is `flat`, then `tiers` must be absent.
30
+ # @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
31
  define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
28
32
 
29
33
  # @!attribute unit_amount
30
34
  # @return [Float] Optionally, override the add-on's default unit amount.
31
35
  define_attribute :unit_amount, Float
36
+
37
+ # @!attribute usage_percentage
38
+ # @return [Float] The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0. Required if add_on_type is usage and usage_type is percentage.
39
+ define_attribute :usage_percentage, Float
32
40
  end
33
41
  end
34
42
  end