recurly 4.23.0 → 4.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3425e11a326e6886fe09606f3cd02f155ded5fb774f639d20f47f2a4def65f3
4
- data.tar.gz: 39d0917188e796d37e7179a86e78427dab022cf94ea3d6c13b734153d54f2b0c
3
+ metadata.gz: 83cc9874a222552398eccba8e97f844e448644398831199e20e9eeb09d91443a
4
+ data.tar.gz: dab0e9563f9771f46d4be709e33394305f8c59bc77fa2cd4394106cef1edd8a6
5
5
  SHA512:
6
- metadata.gz: c06705fdd51268f7f1a298dc6b92ab65c4a972106d32d2e7909ac6852d780ab0024170da9c0f028d43695fe17706371684f93366217bbf3577fd9e1200068854
7
- data.tar.gz: 63565f407525519ff2594677070a394675c7500d03565d704c0bd07e4ef7afa94ffb2d9839efd07f527bc65fc9979090d4ab4cf1166d988d7879fcbb757576e9
6
+ metadata.gz: beeb8fd85be7c0b63d7f2ab7c786684e774d731a3d3f501aba66428bb6de7e58c79fd0e4ab6786790e58195cd675c286f259bb98cb0652366a0ab49b885fed11
7
+ data.tar.gz: a2bb85d2f395c94dbe172aabbc281d0e30f6ffd034d85368616a2a921cee68fc6836ae75dbb023299edc2b8b4d31a61f382d9e43e6f130e10a9130bd5d7a2148
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 4.23.0
2
+ current_version = 4.25.0
3
3
  parse = (?P<major>\d+)
4
4
  \.(?P<minor>\d+)
5
5
  \.(?P<patch>\d+)
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.25.0](https://github.com/recurly/recurly-client-ruby/tree/4.25.0) (2022-11-15)
4
+
5
+ [Full Changelog](https://github.com/recurly/recurly-client-ruby/compare/4.24.0...4.25.0)
6
+
7
+
8
+ **Merged Pull Requests**
9
+
10
+ - Generated Latest Changes for v2021-02-25 (External Subscriptions feature) [#809](https://github.com/recurly/recurly-client-ruby/pull/809) ([recurly-integrations](https://github.com/recurly-integrations))
11
+ - Generated Latest Changes for v2021-02-25 [#807](https://github.com/recurly/recurly-client-ruby/pull/807) ([recurly-integrations](https://github.com/recurly-integrations))
12
+
13
+
14
+
15
+ ## [4.24.0](https://github.com/recurly/recurly-client-ruby/tree/4.24.0) (2022-11-03)
16
+
17
+ [Full Changelog](https://github.com/recurly/recurly-client-ruby/compare/4.23.0...4.24.0)
18
+
19
+
20
+
21
+
22
+
3
23
  ## [4.23.0](https://github.com/recurly/recurly-client-ruby/tree/4.23.0) (2022-10-27)
4
24
 
5
25
  [Full Changelog](https://github.com/recurly/recurly-client-ruby/compare/4.22.0...4.23.0)
data/GETTING_STARTED.md CHANGED
@@ -5,7 +5,7 @@ This repository houses the official ruby client for Recurly's V3 API.
5
5
  In your Gemfile, add `recurly` as a dependency.
6
6
 
7
7
  ```ruby
8
- gem 'recurly', '~> 4.23'
8
+ gem 'recurly', '~> 4.25'
9
9
  ```
10
10
 
11
11
  > *Note*: We try to follow [semantic versioning](https://semver.org/) and will only apply breaking changes to major versions.
@@ -588,7 +588,7 @@ module Recurly
588
588
  delete(path, **options)
589
589
  end
590
590
 
591
- # Show the coupon redemptions for an account
591
+ # List the coupon redemptions for an account
592
592
  #
593
593
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_account_coupon_redemptions list_account_coupon_redemptions api documentation}
594
594
  #
@@ -636,7 +636,7 @@ module Recurly
636
636
  pager(path, **options)
637
637
  end
638
638
 
639
- # Show the coupon redemptions that are active on an account
639
+ # List the coupon redemptions that are active on an account
640
640
  #
641
641
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_active_coupon_redemptions list_active_coupon_redemptions api documentation}
642
642
  #
@@ -950,7 +950,7 @@ module Recurly
950
950
  post(path, body, Requests::LineItemCreate, **options)
951
951
  end
952
952
 
953
- # Fetch a list of an account's notes
953
+ # List an account's notes
954
954
  #
955
955
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_account_notes list_account_notes api documentation}
956
956
  #
@@ -2046,6 +2046,68 @@ module Recurly
2046
2046
  delete(path, **options)
2047
2047
  end
2048
2048
 
2049
+ # List a site's external products
2050
+ #
2051
+ # {https://developers.recurly.com/api/v2021-02-25#operation/list_external_products list_external_products api documentation}
2052
+ #
2053
+ # @param params [Hash] Optional query string parameters:
2054
+ # :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
2055
+ # order. In descending order updated records will move behind the cursor and could
2056
+ # prevent some records from being returned.
2057
+ #
2058
+ #
2059
+ # @return [Pager<Resources::ExternalProduct>] A list of the the external_products on a site.
2060
+ #
2061
+ def list_external_products(**options)
2062
+ path = "/external_products"
2063
+ pager(path, **options)
2064
+ end
2065
+
2066
+ # Fetch an external product
2067
+ #
2068
+ # {https://developers.recurly.com/api/v2021-02-25#operation/get_external_product get_external_product api documentation}
2069
+ #
2070
+ # @param external_product_id [String] External product id
2071
+ # @param params [Hash] Optional query string parameters:
2072
+ #
2073
+ # @return [Resources::ExternalProduct] Settings for an external product.
2074
+ #
2075
+ def get_external_product(external_product_id:, **options)
2076
+ path = interpolate_path("/external_products/{external_product_id}", external_product_id: external_product_id)
2077
+ get(path, **options)
2078
+ end
2079
+
2080
+ # List a site's external subscriptions
2081
+ #
2082
+ # {https://developers.recurly.com/api/v2021-02-25#operation/list_external_subscriptions list_external_subscriptions api documentation}
2083
+ #
2084
+ # @param params [Hash] Optional query string parameters:
2085
+ # :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
2086
+ # order. In descending order updated records will move behind the cursor and could
2087
+ # prevent some records from being returned.
2088
+ #
2089
+ #
2090
+ # @return [Pager<Resources::ExternalSubscription>] A list of the the external_subscriptions on a site.
2091
+ #
2092
+ def list_external_subscriptions(**options)
2093
+ path = "/external_subscriptions"
2094
+ pager(path, **options)
2095
+ end
2096
+
2097
+ # Fetch an external subscription
2098
+ #
2099
+ # {https://developers.recurly.com/api/v2021-02-25#operation/get_external_subscription get_external_subscription api documentation}
2100
+ #
2101
+ # @param external_subscription_id [String] External subscription id
2102
+ # @param params [Hash] Optional query string parameters:
2103
+ #
2104
+ # @return [Resources::ExternalSubscription] Settings for an external subscription.
2105
+ #
2106
+ def get_external_subscription(external_subscription_id:, **options)
2107
+ path = interpolate_path("/external_subscriptions/{external_subscription_id}", external_subscription_id: external_subscription_id)
2108
+ get(path, **options)
2109
+ end
2110
+
2049
2111
  # List a site's invoices
2050
2112
  #
2051
2113
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_invoices list_invoices api documentation}
@@ -2357,7 +2419,7 @@ module Recurly
2357
2419
  pager(path, **options)
2358
2420
  end
2359
2421
 
2360
- # Show the coupon redemptions applied to an invoice
2422
+ # List the coupon redemptions applied to an invoice
2361
2423
  #
2362
2424
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_invoice_coupon_redemptions list_invoice_coupon_redemptions api documentation}
2363
2425
  #
@@ -3586,7 +3648,7 @@ module Recurly
3586
3648
  pager(path, **options)
3587
3649
  end
3588
3650
 
3589
- # Show the coupon redemptions for a subscription
3651
+ # List the coupon redemptions for a subscription
3590
3652
  #
3591
3653
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_subscription_coupon_redemptions list_subscription_coupon_redemptions api documentation}
3592
3654
  #
@@ -4015,7 +4077,7 @@ module Recurly
4015
4077
  get(path, **options)
4016
4078
  end
4017
4079
 
4018
- # Show the dunning campaigns for a site
4080
+ # List the dunning campaigns for a site
4019
4081
  #
4020
4082
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_dunning_campaigns list_dunning_campaigns api documentation}
4021
4083
  #
@@ -4032,7 +4094,7 @@ module Recurly
4032
4094
  pager(path, **options)
4033
4095
  end
4034
4096
 
4035
- # Show the settings for a dunning campaign
4097
+ # Fetch a dunning campaign
4036
4098
  #
4037
4099
  # {https://developers.recurly.com/api/v2021-02-25#operation/get_dunning_campaign get_dunning_campaign api documentation}
4038
4100
  #
@@ -4078,7 +4140,7 @@ module Recurly
4078
4140
  pager(path, **options)
4079
4141
  end
4080
4142
 
4081
- # Show the settings for an invoice template
4143
+ # Fetch an invoice template
4082
4144
  #
4083
4145
  # {https://developers.recurly.com/api/v2021-02-25#operation/get_invoice_template get_invoice_template api documentation}
4084
4146
  #
@@ -4092,7 +4154,7 @@ module Recurly
4092
4154
  get(path, **options)
4093
4155
  end
4094
4156
 
4095
- # Show all entitlements granted to an account
4157
+ # List entitlements granted to an account
4096
4158
  #
4097
4159
  # {https://developers.recurly.com/api/v2021-02-25#operation/list_entitlements list_entitlements api documentation}
4098
4160
  #
@@ -4110,5 +4172,23 @@ module Recurly
4110
4172
  path = interpolate_path("/accounts/{account_id}/entitlements", account_id: account_id)
4111
4173
  pager(path, **options)
4112
4174
  end
4175
+
4176
+ # List an account's external subscriptions
4177
+ #
4178
+ # {https://developers.recurly.com/api/v2021-02-25#operation/list_account_external_subscriptions list_account_external_subscriptions api documentation}
4179
+ #
4180
+ # @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
4181
+ # @param params [Hash] Optional query string parameters:
4182
+ # :sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
4183
+ # order. In descending order updated records will move behind the cursor and could
4184
+ # prevent some records from being returned.
4185
+ #
4186
+ #
4187
+ # @return [Pager<Resources::ExternalSubscription>] A list of the the external_subscriptions on an account.
4188
+ #
4189
+ def list_account_external_subscriptions(account_id:, **options)
4190
+ path = interpolate_path("/accounts/{account_id}/external_subscriptions", account_id: account_id)
4191
+ pager(path, **options)
4192
+ end
4113
4193
  end
4114
4194
  end
@@ -0,0 +1,5 @@
1
+ module Recurly
2
+ module Errors
3
+ class SignatureVerificationError < StandardError; end
4
+ end
5
+ end
@@ -48,4 +48,5 @@ module Recurly
48
48
 
49
49
  require_relative "./errors/api_errors"
50
50
  require_relative "./errors/network_errors"
51
+ require_relative "./errors/webhooks_errors"
51
52
  end
@@ -79,13 +79,17 @@ module Recurly
79
79
  define_attribute :tax_code, String
80
80
 
81
81
  # @!attribute tier_type
82
- # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://developers.recurly.com/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
82
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://recurly.com/developers/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
83
83
  define_attribute :tier_type, String
84
84
 
85
85
  # @!attribute tiers
86
86
  # @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 without an `ending_quantity` value which represents the final tier.
87
87
  define_attribute :tiers, Array, { :item_type => :Tier }
88
88
 
89
+ # @!attribute usage_calculation_type
90
+ # @return [String] The type of calculation to be employed for an add-on. Cumulative billing will sum all usage records created in the current billing cycle. Last-in-period billing will apply only the most recent usage record in the billing period. If no value is specified, cumulative billing will be used.
91
+ define_attribute :usage_calculation_type, String
92
+
89
93
  # @!attribute usage_percentage
90
94
  # @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, `tier_type` is `flat` and `usage_type` is percentage. Must be omitted otherwise.
91
95
  define_attribute :usage_percentage, Float
@@ -95,7 +99,7 @@ module Recurly
95
99
  define_attribute :usage_timeframe, String
96
100
 
97
101
  # @!attribute usage_type
98
- # @return [String] Type of usage, required if `add_on_type` is `usage`. See our [Guide](https://developers.recurly.com/guides/usage-based-billing-guide.html) for an overview of how to configure usage add-ons.
102
+ # @return [String] Type of usage, required if `add_on_type` is `usage`. See our [Guide](https://recurly.com/developers/guides/usage-based-billing-guide.html) for an overview of how to configure usage add-ons.
99
103
  define_attribute :usage_type, String
100
104
  end
101
105
  end
@@ -70,6 +70,10 @@ module Recurly
70
70
  # @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 without an `ending_quantity` value which represents the final tier.
71
71
  define_attribute :tiers, Array, { :item_type => :Tier }
72
72
 
73
+ # @!attribute usage_calculation_type
74
+ # @return [String] The type of calculation to be employed for an add-on. Cumulative billing will sum all usage records created in the current billing cycle. Last-in-period billing will apply only the most recent usage record in the billing period. If no value is specified, cumulative billing will be used.
75
+ define_attribute :usage_calculation_type, String
76
+
73
77
  # @!attribute usage_percentage
74
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, `tier_type` is `flat` and `usage_type` is percentage. Must be omitted otherwise.
75
79
  define_attribute :usage_percentage, Float
@@ -115,7 +115,7 @@ module Recurly
115
115
  define_attribute :three_d_secure_action_result_token_id, String
116
116
 
117
117
  # @!attribute token_id
118
- # @return [String] A token [generated by Recurly.js](https://developers.recurly.com/reference/recurly-js/#getting-a-token).
118
+ # @return [String] A token [generated by Recurly.js](https://recurly.com/developers/reference/recurly-js/#getting-a-token).
119
119
  define_attribute :token_id, String
120
120
 
121
121
  # @!attribute transaction_type
@@ -38,6 +38,10 @@ module Recurly
38
38
  # @return [Array[PlanPricing]] Pricing
39
39
  define_attribute :currencies, Array, { :item_type => :PlanPricing }
40
40
 
41
+ # @!attribute custom_fields
42
+ # @return [Array[CustomField]] The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value.
43
+ define_attribute :custom_fields, Array, { :item_type => :CustomField }
44
+
41
45
  # @!attribute description
42
46
  # @return [String] Optional description, not displayed.
43
47
  define_attribute :description, String
@@ -34,6 +34,10 @@ module Recurly
34
34
  # @return [Array[PlanPricing]] Optional when the pricing model is 'ramp'.
35
35
  define_attribute :currencies, Array, { :item_type => :PlanPricing }
36
36
 
37
+ # @!attribute custom_fields
38
+ # @return [Array[CustomField]] The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value.
39
+ define_attribute :custom_fields, Array, { :item_type => :CustomField }
40
+
37
41
  # @!attribute description
38
42
  # @return [String] Optional description, not displayed.
39
43
  define_attribute :description, String
@@ -27,7 +27,7 @@ module Recurly
27
27
  define_attribute :revenue_schedule_type, String
28
28
 
29
29
  # @!attribute tiers
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 without an `ending_quantity` value which represents the final tier. See our [Guide](https://developers.recurly.com/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
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 without an `ending_quantity` value which represents the final tier. See our [Guide](https://recurly.com/developers/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
31
31
  define_attribute :tiers, Array, { :item_type => :SubscriptionAddOnTier }
32
32
 
33
33
  # @!attribute unit_amount
@@ -39,7 +39,7 @@ module Recurly
39
39
  define_attribute :unit_amount_decimal, String
40
40
 
41
41
  # @!attribute usage_percentage
42
- # @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. See our [Guide](https://developers.recurly.com/guides/usage-based-billing-guide.html) for an overview of how to configure usage add-ons.
42
+ # @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. See our [Guide](https://recurly.com/developers/guides/usage-based-billing-guide.html) for an overview of how to configure usage add-ons.
43
43
  define_attribute :usage_percentage, Float
44
44
  end
45
45
  end
@@ -95,7 +95,7 @@ module Recurly
95
95
  define_attribute :tax_code, String
96
96
 
97
97
  # @!attribute tier_type
98
- # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://developers.recurly.com/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
98
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://recurly.com/developers/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
99
99
  define_attribute :tier_type, String
100
100
 
101
101
  # @!attribute tiers
@@ -106,6 +106,10 @@ module Recurly
106
106
  # @return [DateTime] Last updated at
107
107
  define_attribute :updated_at, DateTime
108
108
 
109
+ # @!attribute usage_calculation_type
110
+ # @return [String] The type of calculation to be employed for an add-on. Cumulative billing will sum all usage records created in the current billing cycle. Last-in-period billing will apply only the most recent usage record in the billing period. If no value is specified, cumulative billing will be used.
111
+ define_attribute :usage_calculation_type, String
112
+
109
113
  # @!attribute usage_percentage
110
114
  # @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.
111
115
  define_attribute :usage_percentage, Float
@@ -0,0 +1,38 @@
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 ExternalProduct < Resource
8
+
9
+ # @!attribute created_at
10
+ # @return [DateTime] When the external product was created in Recurly.
11
+ define_attribute :created_at, DateTime
12
+
13
+ # @!attribute external_product_references
14
+ # @return [Array[ExternalProductReferenceMini]] List of external product references of the external product.
15
+ define_attribute :external_product_references, Array, { :item_type => :ExternalProductReferenceMini }
16
+
17
+ # @!attribute id
18
+ # @return [String] System-generated unique identifier for an external product ID, e.g. `e28zov4fw0v2`.
19
+ define_attribute :id, String
20
+
21
+ # @!attribute name
22
+ # @return [String] Name to identify the external product in Recurly.
23
+ define_attribute :name, String
24
+
25
+ # @!attribute object
26
+ # @return [String] Object type
27
+ define_attribute :object, String
28
+
29
+ # @!attribute plan
30
+ # @return [PlanMini] Just the important parts.
31
+ define_attribute :plan, :PlanMini
32
+
33
+ # @!attribute updated_at
34
+ # @return [DateTime] When the external product was updated in Recurly.
35
+ define_attribute :updated_at, DateTime
36
+ end
37
+ end
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 Resources
7
+ class ExternalProductReferenceMini < Resource
8
+
9
+ # @!attribute created_at
10
+ # @return [DateTime] When the external product was created in Recurly.
11
+ define_attribute :created_at, DateTime
12
+
13
+ # @!attribute external_connection_type
14
+ # @return [String] Source connection platform.
15
+ define_attribute :external_connection_type, String
16
+
17
+ # @!attribute id
18
+ # @return [String] System-generated unique identifier for an external product ID, e.g. `e28zov4fw0v2`.
19
+ define_attribute :id, String
20
+
21
+ # @!attribute object
22
+ # @return [String] object
23
+ define_attribute :object, String
24
+
25
+ # @!attribute reference_code
26
+ # @return [String] A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store.
27
+ define_attribute :reference_code, String
28
+
29
+ # @!attribute updated_at
30
+ # @return [DateTime] When the external product was updated in Recurly.
31
+ define_attribute :updated_at, DateTime
32
+ end
33
+ end
34
+ 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 Resources
7
+ class ExternalResourceMini < Resource
8
+
9
+ # @!attribute external_object_reference
10
+ # @return [String] Identifier or URL reference where the resource is canonically available in the external platform.
11
+ define_attribute :external_object_reference, String
12
+
13
+ # @!attribute id
14
+ # @return [String] System-generated unique identifier for an external resource ID, e.g. `e28zov4fw0v2`.
15
+ define_attribute :id, String
16
+
17
+ # @!attribute object
18
+ # @return [String] Object type
19
+ define_attribute :object, String
20
+ end
21
+ end
22
+ end
@@ -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 ExternalSubscription < Resource
8
+
9
+ # @!attribute account
10
+ # @return [AccountMini] Account mini details
11
+ define_attribute :account, :AccountMini
12
+
13
+ # @!attribute activated_at
14
+ # @return [DateTime] When the external subscription was activated in the external platform.
15
+ define_attribute :activated_at, DateTime
16
+
17
+ # @!attribute app_identifier
18
+ # @return [String] Identifier of the app that generated the external subscription.
19
+ define_attribute :app_identifier, String
20
+
21
+ # @!attribute auto_renew
22
+ # @return [Boolean] An indication of whether or not the external subscription will auto-renew at the expiration date.
23
+ define_attribute :auto_renew, :Boolean
24
+
25
+ # @!attribute created_at
26
+ # @return [DateTime] When the external subscription was created in Recurly.
27
+ define_attribute :created_at, DateTime
28
+
29
+ # @!attribute expires_at
30
+ # @return [DateTime] When the external subscription expires in the external platform.
31
+ define_attribute :expires_at, DateTime
32
+
33
+ # @!attribute external_product_reference
34
+ # @return [ExternalProductReferenceMini] External Product Reference details
35
+ define_attribute :external_product_reference, :ExternalProductReferenceMini
36
+
37
+ # @!attribute external_resource
38
+ # @return [ExternalResourceMini] External Resource mini details
39
+ define_attribute :external_resource, :ExternalResourceMini
40
+
41
+ # @!attribute id
42
+ # @return [String] System-generated unique identifier for an external subscription ID, e.g. `e28zov4fw0v2`.
43
+ define_attribute :id, String
44
+
45
+ # @!attribute last_purchased
46
+ # @return [DateTime] When a new billing event occurred on the external subscription in conjunction with a recent billing period, reactivation or upgrade/downgrade.
47
+ define_attribute :last_purchased, DateTime
48
+
49
+ # @!attribute object
50
+ # @return [String] Object type
51
+ define_attribute :object, String
52
+
53
+ # @!attribute quantity
54
+ # @return [Integer] An indication of the quantity of a subscribed item's quantity.
55
+ define_attribute :quantity, Integer
56
+
57
+ # @!attribute updated_at
58
+ # @return [DateTime] When the external subscription was updated in Recurly.
59
+ define_attribute :updated_at, DateTime
60
+ end
61
+ end
62
+ end
@@ -38,6 +38,10 @@ module Recurly
38
38
  # @return [Array[PlanPricing]] Pricing
39
39
  define_attribute :currencies, Array, { :item_type => :PlanPricing }
40
40
 
41
+ # @!attribute custom_fields
42
+ # @return [Array[CustomField]] The custom fields will only be altered when they are included in a request. Sending an empty array will not remove any existing values. To remove a field send the name with a null or empty value.
43
+ define_attribute :custom_fields, Array, { :item_type => :CustomField }
44
+
41
45
  # @!attribute deleted_at
42
46
  # @return [DateTime] Deleted at
43
47
  define_attribute :deleted_at, DateTime
@@ -47,7 +47,7 @@ module Recurly
47
47
  define_attribute :subscription_id, String
48
48
 
49
49
  # @!attribute tier_type
50
- # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://developers.recurly.com/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
50
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://recurly.com/developers/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
51
51
  define_attribute :tier_type, String
52
52
 
53
53
  # @!attribute tiers
@@ -66,6 +66,10 @@ module Recurly
66
66
  # @return [DateTime] Updated at
67
67
  define_attribute :updated_at, DateTime
68
68
 
69
+ # @!attribute usage_calculation_type
70
+ # @return [String] The type of calculation to be employed for an add-on. Cumulative billing will sum all usage records created in the current billing cycle. Last-in-period billing will apply only the most recent usage record in the billing period. If no value is specified, cumulative billing will be used.
71
+ define_attribute :usage_calculation_type, String
72
+
69
73
  # @!attribute usage_percentage
70
74
  # @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.
71
75
  define_attribute :usage_percentage, Float
@@ -43,7 +43,7 @@ module Recurly
43
43
  define_attribute :recording_timestamp, DateTime
44
44
 
45
45
  # @!attribute tier_type
46
- # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://developers.recurly.com/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
46
+ # @return [String] The pricing model for the add-on. For more information, [click here](https://docs.recurly.com/docs/billing-models#section-quantity-based). See our [Guide](https://recurly.com/developers/guides/item-addon-guide.html) for an overview of how to configure quantity-based pricing models.
47
47
  define_attribute :tier_type, String
48
48
 
49
49
  # @!attribute tiers
@@ -1,3 +1,3 @@
1
1
  module Recurly
2
- VERSION = "4.23.0"
2
+ VERSION = "4.25.0"
3
3
  end
@@ -0,0 +1,52 @@
1
+ module Recurly
2
+ module Webhooks
3
+ DEFAULT_TOLERANCE = 5 * 60 * 1000
4
+
5
+ # Verify webhook signature
6
+ #
7
+ # @param header [String] recurly-signature header from request
8
+ # @param secret [String] Shared secret for notification endpoint
9
+ # @param body [String] Request POST body
10
+ # @param tolerance [Integer] Allowed notification time drift in milliseconds
11
+ # @example
12
+ # begin
13
+ # Recurly::Webhooks.verify_signature(header,
14
+ # ENV['WEBHOOKS_KEY'],
15
+ # request.body)
16
+ # rescue Recurly::Errors::SignatureVerificationError => e
17
+ # puts e.message
18
+ # end
19
+ #
20
+ def self.verify_signature(header, secret, body, tolerance: DEFAULT_TOLERANCE)
21
+ s_timestamp, *signatures = header.split(",")
22
+ timestamp = Integer(s_timestamp)
23
+ now = (Time.now.to_f * 1000).to_i
24
+
25
+ if (now - timestamp).abs > tolerance
26
+ raise Recurly::Errors::SignatureVerificationError.new(
27
+ "Notification (#{Time.at(timestamp / 1000.0)}) is more than #{tolerance / 1000.0}s out of date"
28
+ )
29
+ end
30
+
31
+ expected = OpenSSL::HMAC.hexdigest("sha256", secret, "#{timestamp}.#{body}")
32
+
33
+ unless signatures.any? { |s| secure_compare(expected, s) }
34
+ raise Recurly::Errors::SignatureVerificationError.new(
35
+ "No matching signatures found for payload"
36
+ )
37
+ end
38
+ end
39
+
40
+ # https://github.com/rack/rack/blob/2-2-stable/lib/rack/utils.rb#L374
41
+ # https://github.com/heartcombo/devise/blob/4-1-stable/lib/devise.rb#L477
42
+ def self.secure_compare(a, b)
43
+ return false if a.bytesize != b.bytesize
44
+ l = a.unpack("C#{a.bytesize}")
45
+
46
+ res = 0
47
+ b.each_byte { |byte| res |= byte ^ l.shift }
48
+ res == 0
49
+ end
50
+ private_class_method :secure_compare
51
+ end
52
+ end
data/lib/recurly.rb CHANGED
@@ -9,6 +9,7 @@ require "recurly/http"
9
9
  require "recurly/errors"
10
10
  require "recurly/connection_pool"
11
11
  require "recurly/client"
12
+ require "recurly/webhooks"
12
13
 
13
14
  module Recurly
14
15
  STRICT_MODE = ENV["RECURLY_STRICT_MODE"] && ENV["RECURLY_STRICT_MODE"].downcase == "true"