recurly 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -34,6 +38,14 @@ module Recurly
34
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
@@ -61,6 +73,14 @@ module Recurly
61
73
  # @!attribute tiers
62
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
@@ -49,6 +57,10 @@ module Recurly
49
57
  # @!attribute tiers
50
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
@@ -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
@@ -29,6 +29,10 @@ module Recurly
29
29
  # @!attribute unit_amount
30
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.
31
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
32
36
  end
33
37
  end
34
38
  end
@@ -33,6 +33,10 @@ module Recurly
33
33
  # @!attribute unit_amount
34
34
  # @return [Float] Optionally, override the add-on's default unit amount.
35
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
36
40
  end
37
41
  end
38
42
  end
@@ -46,6 +46,10 @@ module Recurly
46
46
  # @return [SubscriptionShippingPurchase] Create a shipping address on the account and assign it to the subscription.
47
47
  define_attribute :shipping, :SubscriptionShippingPurchase
48
48
 
49
+ # @!attribute starts_at
50
+ # @return [DateTime] If set, the subscription will begin in the future on this date. The subscription will apply the setup fee and trial period, unless the plan has no trial.
51
+ define_attribute :starts_at, DateTime
52
+
49
53
  # @!attribute total_billing_cycles
50
54
  # @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.
51
55
  define_attribute :total_billing_cycles, Integer
@@ -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 UsageCreate < Request
8
+
9
+ # @!attribute amount
10
+ # @return [Float] The amount of usage. Can be positive, negative, or 0. No decimals allowed, we will strip them. If the usage-based add-on is billed with a percentage, your usage will be a monetary amount you will want to format in cents. (e.g., $5.00 is "500").
11
+ define_attribute :amount, Float
12
+
13
+ # @!attribute merchant_tag
14
+ # @return [String] Custom field for recording the id in your own system associated with the usage, so you can provide auditable usage displays to your customers using a GET on this endpoint.
15
+ define_attribute :merchant_tag, String
16
+
17
+ # @!attribute recording_timestamp
18
+ # @return [DateTime] When the usage was recorded in your system.
19
+ define_attribute :recording_timestamp, DateTime
20
+
21
+ # @!attribute usage_timestamp
22
+ # @return [DateTime] When the usage actually happened. This will define the line item dates this usage is billed under and is important for revenue recognition.
23
+ define_attribute :usage_timestamp, DateTime
24
+ end
25
+ end
26
+ 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.
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.
15
19
  define_attribute :code, String
@@ -46,6 +50,10 @@ module Recurly
46
50
  # @return [ItemMini] Just the important parts.
47
51
  define_attribute :item, :ItemMini
48
52
 
53
+ # @!attribute measured_unit_id
54
+ # @return [String] System-generated unique identifier for an measured unit associated with the add-on.
55
+ define_attribute :measured_unit_id, String
56
+
49
57
  # @!attribute name
50
58
  # @return [String] Describes your add-on and will appear in subscribers' invoices.
51
59
  define_attribute :name, String
@@ -85,6 +93,14 @@ module Recurly
85
93
  # @!attribute updated_at
86
94
  # @return [DateTime] Last updated at
87
95
  define_attribute :updated_at, DateTime
96
+
97
+ # @!attribute usage_percentage
98
+ # @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.
99
+ define_attribute :usage_percentage, Float
100
+
101
+ # @!attribute usage_type
102
+ # @return [String] Type of usage, returns usage type if `add_on_type` is `usage`.
103
+ define_attribute :usage_type, String
88
104
  end
89
105
  end
90
106
  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.
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.
15
19
  define_attribute :code, String
@@ -26,6 +30,10 @@ module Recurly
26
30
  # @return [String] Item ID
27
31
  define_attribute :item_id, String
28
32
 
33
+ # @!attribute measured_unit_id
34
+ # @return [String] System-generated unique identifier for an measured unit associated with the add-on.
35
+ define_attribute :measured_unit_id, String
36
+
29
37
  # @!attribute name
30
38
  # @return [String] Describes your add-on and will appear in subscribers' invoices.
31
39
  define_attribute :name, String
@@ -33,6 +41,14 @@ module Recurly
33
41
  # @!attribute object
34
42
  # @return [String] Object type
35
43
  define_attribute :object, String
44
+
45
+ # @!attribute usage_percentage
46
+ # @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.
47
+ define_attribute :usage_percentage, Float
48
+
49
+ # @!attribute usage_type
50
+ # @return [String] Type of usage, returns usage type if `add_on_type` is `usage`.
51
+ define_attribute :usage_type, String
36
52
  end
37
53
  end
38
54
  end
@@ -0,0 +1,46 @@
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 Resources
7
+ class MeasuredUnit < Resource
8
+
9
+ # @!attribute created_at
10
+ # @return [DateTime] Created at
11
+ define_attribute :created_at, DateTime
12
+
13
+ # @!attribute deleted_at
14
+ # @return [DateTime] Deleted at
15
+ define_attribute :deleted_at, DateTime
16
+
17
+ # @!attribute description
18
+ # @return [String] Optional internal description.
19
+ define_attribute :description, String
20
+
21
+ # @!attribute display_name
22
+ # @return [String] Display name for the measured unit. Can only contain spaces, underscores and must be alphanumeric.
23
+ define_attribute :display_name, String
24
+
25
+ # @!attribute id
26
+ # @return [String] Item ID
27
+ define_attribute :id, String
28
+
29
+ # @!attribute name
30
+ # @return [String] Unique internal name of the measured unit on your site.
31
+ define_attribute :name, String
32
+
33
+ # @!attribute object
34
+ # @return [String] Object type
35
+ define_attribute :object, String
36
+
37
+ # @!attribute state
38
+ # @return [String] The current state of the measured unit.
39
+ define_attribute :state, String
40
+
41
+ # @!attribute updated_at
42
+ # @return [DateTime] Last updated at
43
+ define_attribute :updated_at, DateTime
44
+ end
45
+ end
46
+ end
@@ -47,7 +47,7 @@ module Recurly
47
47
  define_attribute :tier_type, String
48
48
 
49
49
  # @!attribute tiers
50
- # @return [Array[SubscriptionAddOnTier]] Empty unless `tier_type` is `tiered`, `volume`, or `stairstep`.
50
+ # @return [Array[SubscriptionAddOnTier]] If tiers are provided in the request, all existing tiers on the Subscription Add-on will be removed and replaced by the tiers in the request.
51
51
  define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
52
52
 
53
53
  # @!attribute unit_amount
@@ -57,6 +57,10 @@ module Recurly
57
57
  # @!attribute updated_at
58
58
  # @return [DateTime] Updated at
59
59
  define_attribute :updated_at, DateTime
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.
63
+ define_attribute :usage_percentage, Float
60
64
  end
61
65
  end
62
66
  end
@@ -30,6 +30,10 @@ module Recurly
30
30
  # @return [String] The ID of the Subscription Change.
31
31
  define_attribute :id, String
32
32
 
33
+ # @!attribute invoice_collection
34
+ # @return [InvoiceCollection] Invoice Collection
35
+ define_attribute :invoice_collection, :InvoiceCollection
36
+
33
37
  # @!attribute object
34
38
  # @return [String] Object type
35
39
  define_attribute :object, String
@@ -31,7 +31,7 @@ module Recurly
31
31
  define_attribute :id, String
32
32
 
33
33
  # @!attribute invoice_collection
34
- # @return [InvoiceCollection] Invoice collection
34
+ # @return [InvoiceCollection] Invoice Collection
35
35
  define_attribute :invoice_collection, :InvoiceCollection
36
36
 
37
37
  # @!attribute object
@@ -0,0 +1,62 @@
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 Resources
7
+ class Usage < Resource
8
+
9
+ # @!attribute amount
10
+ # @return [Float] The amount of usage. Can be positive, negative, or 0. No decimals allowed, we will strip them. If the usage-based add-on is billed with a percentage, your usage will be a monetary amount you will want to format in cents. (e.g., $5.00 is "500").
11
+ define_attribute :amount, Float
12
+
13
+ # @!attribute billed_at
14
+ # @return [DateTime] When the usage record was billed on an invoice.
15
+ define_attribute :billed_at, DateTime
16
+
17
+ # @!attribute created_at
18
+ # @return [DateTime] When the usage record was created in Recurly.
19
+ define_attribute :created_at, DateTime
20
+
21
+ # @!attribute id
22
+ # @return [String]
23
+ define_attribute :id, String
24
+
25
+ # @!attribute measured_unit_id
26
+ # @return [String] The ID of the measured unit associated with the add-on the usage record is for.
27
+ define_attribute :measured_unit_id, String
28
+
29
+ # @!attribute merchant_tag
30
+ # @return [String] Custom field for recording the id in your own system associated with the usage, so you can provide auditable usage displays to your customers using a GET on this endpoint.
31
+ define_attribute :merchant_tag, String
32
+
33
+ # @!attribute object
34
+ # @return [String] Object type
35
+ define_attribute :object, String
36
+
37
+ # @!attribute recording_timestamp
38
+ # @return [DateTime] When the usage was recorded in your system.
39
+ define_attribute :recording_timestamp, DateTime
40
+
41
+ # @!attribute tier_type
42
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based).
43
+ define_attribute :tier_type, String
44
+
45
+ # @!attribute tiers
46
+ # @return [Array[SubscriptionAddOnTier]] The tiers and prices of the subscription based on the usage_timestamp. If tier_type = flat, tiers = null
47
+ define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
48
+
49
+ # @!attribute updated_at
50
+ # @return [DateTime] When the usage record was billed on an invoice.
51
+ define_attribute :updated_at, DateTime
52
+
53
+ # @!attribute usage_timestamp
54
+ # @return [DateTime] When the usage actually happened. This will define the line item dates this usage is billed under and is important for revenue recognition.
55
+ define_attribute :usage_timestamp, DateTime
56
+
57
+ # @!attribute usage_type
58
+ # @return [String] Type of usage, returns usage type if `add_on_type` is `usage`.
59
+ define_attribute :usage_type, String
60
+ end
61
+ end
62
+ end