license_manager 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -0
  3. data/README.md +1 -1
  4. data/docs/BillingPortalSession.md +18 -0
  5. data/docs/CreateBillingPortalSession.md +18 -0
  6. data/docs/CreateIntegrationMapping.md +1 -1
  7. data/docs/Integration.md +6 -0
  8. data/docs/IntegrationMapping.md +2 -0
  9. data/docs/IntegrationMappingRecurring.md +20 -0
  10. data/docs/License.md +4 -0
  11. data/docs/LicenseCustomer.md +22 -0
  12. data/docs/LicenseSubscription.md +34 -0
  13. data/docs/LicensesApi.md +5 -5
  14. data/docs/Mrr.md +26 -0
  15. data/docs/MrrByIntervalInner.md +24 -0
  16. data/docs/MrrByPolicyInner.md +22 -0
  17. data/docs/PortalApi.md +79 -0
  18. data/docs/ProductStats.md +2 -0
  19. data/docs/Revenue.md +8 -4
  20. data/docs/StripePermission.md +3 -1
  21. data/docs/StripePrice.md +2 -0
  22. data/docs/StripePriceRecurring.md +20 -0
  23. data/docs/SubscriptionStats.md +38 -0
  24. data/docs/UpdateIntegration.md +3 -1
  25. data/lib/license_manager/api/licenses_api.rb +6 -6
  26. data/lib/license_manager/api/portal_api.rb +70 -0
  27. data/lib/license_manager/models/billing_portal_session.rb +178 -0
  28. data/lib/license_manager/models/create_billing_portal_session.rb +161 -0
  29. data/lib/license_manager/models/create_integration_mapping.rb +1 -1
  30. data/lib/license_manager/models/event_type.rb +4 -1
  31. data/lib/license_manager/models/integration.rb +82 -1
  32. data/lib/license_manager/models/integration_mapping.rb +13 -1
  33. data/lib/license_manager/models/integration_mapping_recurring.rb +228 -0
  34. data/lib/license_manager/models/license.rb +39 -1
  35. data/lib/license_manager/models/license_customer.rb +217 -0
  36. data/lib/license_manager/models/license_subscription.rb +388 -0
  37. data/lib/license_manager/models/mrr.rb +291 -0
  38. data/lib/license_manager/models/mrr_by_interval_inner.rb +279 -0
  39. data/lib/license_manager/models/mrr_by_policy_inner.rb +229 -0
  40. data/lib/license_manager/models/product_stats.rb +14 -1
  41. data/lib/license_manager/models/revenue.rb +60 -6
  42. data/lib/license_manager/models/stripe_permission.rb +31 -4
  43. data/lib/license_manager/models/stripe_price.rb +13 -1
  44. data/lib/license_manager/models/stripe_price_recurring.rb +228 -0
  45. data/lib/license_manager/models/subscription_stats.rb +456 -0
  46. data/lib/license_manager/models/update_integration.rb +42 -4
  47. data/lib/license_manager/version.rb +1 -1
  48. data/lib/license_manager.rb +10 -0
  49. data/openapi.json +599 -14
  50. data/spec/api/licenses_api_spec.rb +3 -3
  51. data/spec/api/portal_api_spec.rb +13 -0
  52. data/spec/models/billing_portal_session_spec.rb +36 -0
  53. data/spec/models/create_billing_portal_session_spec.rb +36 -0
  54. data/spec/models/create_token_spec.rb +1 -1
  55. data/spec/models/integration_mapping_recurring_spec.rb +46 -0
  56. data/spec/models/integration_mapping_spec.rb +6 -0
  57. data/spec/models/integration_spec.rb +18 -0
  58. data/spec/models/license_customer_spec.rb +48 -0
  59. data/spec/models/license_spec.rb +12 -0
  60. data/spec/models/license_subscription_spec.rb +88 -0
  61. data/spec/models/mrr_by_interval_inner_spec.rb +58 -0
  62. data/spec/models/mrr_by_policy_inner_spec.rb +48 -0
  63. data/spec/models/mrr_spec.rb +60 -0
  64. data/spec/models/product_stats_spec.rb +6 -0
  65. data/spec/models/revenue_spec.rb +12 -0
  66. data/spec/models/stripe_permission_spec.rb +6 -0
  67. data/spec/models/stripe_price_recurring_spec.rb +46 -0
  68. data/spec/models/stripe_price_spec.rb +6 -0
  69. data/spec/models/subscription_stats_spec.rb +96 -0
  70. data/spec/models/token_spec.rb +1 -1
  71. data/spec/models/update_integration_spec.rb +6 -0
  72. metadata +41 -1
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #LicenseManager API
3
+
4
+ #Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LicenseManager
17
+ # Customer the license belongs to, the one of `customerId`.
18
+ class LicenseCustomer < ApiModelBase
19
+ attr_accessor :id
20
+
21
+ attr_accessor :email
22
+
23
+ # Display name of the customer. `null` when unknown.
24
+ attr_accessor :name
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'id' => :'id',
30
+ :'email' => :'email',
31
+ :'name' => :'name'
32
+ }
33
+ end
34
+
35
+ # Returns attribute mapping this model knows about
36
+ def self.acceptable_attribute_map
37
+ attribute_map
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ acceptable_attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'id' => :'String',
49
+ :'email' => :'String',
50
+ :'name' => :'String'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ :'name'
58
+ ])
59
+ end
60
+
61
+ # Returns attribute type mapping
62
+ def self.acceptable_openapi_types
63
+ openapi_types
64
+ end
65
+
66
+ # Returns the nullable attributes
67
+ def self.acceptable_openapi_nullable
68
+ openapi_nullable
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `LicenseManager::LicenseCustomer` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ acceptable_attribute_map = self.class.acceptable_attribute_map
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!acceptable_attribute_map.key?(k.to_sym))
82
+ fail ArgumentError, "`#{k}` is not a valid attribute in `LicenseManager::LicenseCustomer`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
83
+ end
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:'id')
88
+ self.id = attributes[:'id']
89
+ else
90
+ self.id = nil
91
+ end
92
+
93
+ if attributes.key?(:'email')
94
+ self.email = attributes[:'email']
95
+ else
96
+ self.email = nil
97
+ end
98
+
99
+ if attributes.key?(:'name')
100
+ self.name = attributes[:'name']
101
+ else
102
+ self.name = nil
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
110
+ invalid_properties = Array.new
111
+ if @id.nil?
112
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
113
+ end
114
+
115
+ if @email.nil?
116
+ invalid_properties.push('invalid value for "email", email cannot be nil.')
117
+ end
118
+
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ warn '[DEPRECATED] the `valid?` method is obsolete'
126
+ return false if @id.nil?
127
+ return false if @email.nil?
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method with validation
132
+ # @param [Object] id Value to be assigned
133
+ def id=(id)
134
+ if id.nil?
135
+ fail ArgumentError, 'id cannot be nil'
136
+ end
137
+
138
+ @id = id
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] email Value to be assigned
143
+ def email=(email)
144
+ if email.nil?
145
+ fail ArgumentError, 'email cannot be nil'
146
+ end
147
+
148
+ @email = email
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ id == o.id &&
157
+ email == o.email &&
158
+ name == o.name
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [id, email, name].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ return nil unless attributes.is_a?(Hash)
178
+ attributes = attributes.transform_keys(&:to_sym)
179
+ # include attributes inherited from allOf parents (the nearest declaration wins)
180
+ map = acceptable_attribute_map
181
+ transformed_hash = {}
182
+ acceptable_openapi_types.each_pair do |key, type|
183
+ if attributes.key?(map[key]) && attributes[map[key]].nil?
184
+ transformed_hash["#{key}"] = nil
185
+ elsif type =~ /\AArray<(.*)>/i
186
+ # check to ensure the input is an array given that the attribute
187
+ # is documented as an array but the input is not
188
+ if attributes[map[key]].is_a?(Array)
189
+ transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
190
+ end
191
+ elsif !attributes[map[key]].nil?
192
+ transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
193
+ end
194
+ end
195
+ new(transformed_hash)
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ # include attributes inherited from allOf parents (the nearest declaration wins)
203
+ self.class.acceptable_attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ end
216
+
217
+ end
@@ -0,0 +1,388 @@
1
+ =begin
2
+ #LicenseManager API
3
+
4
+ #Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LicenseManager
17
+ # The Stripe subscription keeping the license valid, `null` when it isn't a subscription license. The license expires when it stops being paid, includes every update, and can't be canceled during a money back guarantee.
18
+ class LicenseSubscription < ApiModelBase
19
+ attr_accessor :stripe_subscription_id
20
+
21
+ # Status of the subscription in Stripe: `active`, `trialing`, `past_due` while a failed payment is retried, `canceled`, `unpaid`, `paused`, `incomplete` or `incomplete_expired`.
22
+ attr_accessor :status
23
+
24
+ attr_accessor :interval
25
+
26
+ # Number of intervals between payments.
27
+ attr_accessor :interval_count
28
+
29
+ # Units subscribed, multiplying the policy's machines.
30
+ attr_accessor :quantity
31
+
32
+ # Price of one unit for one period, before taxes.
33
+ attr_accessor :price
34
+
35
+ # End of the paid period, when the subscription renews or ends.
36
+ attr_accessor :current_period_end
37
+
38
+ # Whether the subscription ends at the end of the period.
39
+ attr_accessor :cancel_at_period_end
40
+
41
+ attr_accessor :ended_at
42
+
43
+ class EnumAttributeValidator
44
+ attr_reader :datatype
45
+ attr_reader :allowable_values
46
+
47
+ def initialize(datatype, allowable_values)
48
+ @allowable_values = allowable_values.map do |value|
49
+ case datatype.to_s
50
+ when /Integer/i
51
+ value.to_i
52
+ when /Float/i
53
+ value.to_f
54
+ else
55
+ value
56
+ end
57
+ end
58
+ end
59
+
60
+ def valid?(value)
61
+ !value || allowable_values.include?(value)
62
+ end
63
+ end
64
+
65
+ # Attribute mapping from ruby-style variable name to JSON key.
66
+ def self.attribute_map
67
+ {
68
+ :'stripe_subscription_id' => :'stripeSubscriptionId',
69
+ :'status' => :'status',
70
+ :'interval' => :'interval',
71
+ :'interval_count' => :'intervalCount',
72
+ :'quantity' => :'quantity',
73
+ :'price' => :'price',
74
+ :'current_period_end' => :'currentPeriodEnd',
75
+ :'cancel_at_period_end' => :'cancelAtPeriodEnd',
76
+ :'ended_at' => :'endedAt'
77
+ }
78
+ end
79
+
80
+ # Returns attribute mapping this model knows about
81
+ def self.acceptable_attribute_map
82
+ attribute_map
83
+ end
84
+
85
+ # Returns all the JSON keys this model knows about
86
+ def self.acceptable_attributes
87
+ acceptable_attribute_map.values
88
+ end
89
+
90
+ # Attribute type mapping.
91
+ def self.openapi_types
92
+ {
93
+ :'stripe_subscription_id' => :'String',
94
+ :'status' => :'String',
95
+ :'interval' => :'String',
96
+ :'interval_count' => :'Integer',
97
+ :'quantity' => :'Integer',
98
+ :'price' => :'Price',
99
+ :'current_period_end' => :'Time',
100
+ :'cancel_at_period_end' => :'Boolean',
101
+ :'ended_at' => :'Time'
102
+ }
103
+ end
104
+
105
+ # List of attributes with nullable: true
106
+ def self.openapi_nullable
107
+ Set.new([
108
+ :'price',
109
+ :'ended_at'
110
+ ])
111
+ end
112
+
113
+ # Returns attribute type mapping
114
+ def self.acceptable_openapi_types
115
+ openapi_types
116
+ end
117
+
118
+ # Returns the nullable attributes
119
+ def self.acceptable_openapi_nullable
120
+ openapi_nullable
121
+ end
122
+
123
+ # Initializes the object
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ def initialize(attributes = {})
126
+ if (!attributes.is_a?(Hash))
127
+ fail ArgumentError, "The input argument (attributes) must be a hash in `LicenseManager::LicenseSubscription` initialize method"
128
+ end
129
+
130
+ # check to see if the attribute exists and convert string to symbol for hash key
131
+ acceptable_attribute_map = self.class.acceptable_attribute_map
132
+ attributes = attributes.each_with_object({}) { |(k, v), h|
133
+ if (!acceptable_attribute_map.key?(k.to_sym))
134
+ fail ArgumentError, "`#{k}` is not a valid attribute in `LicenseManager::LicenseSubscription`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
135
+ end
136
+ h[k.to_sym] = v
137
+ }
138
+
139
+ if attributes.key?(:'stripe_subscription_id')
140
+ self.stripe_subscription_id = attributes[:'stripe_subscription_id']
141
+ else
142
+ self.stripe_subscription_id = nil
143
+ end
144
+
145
+ if attributes.key?(:'status')
146
+ self.status = attributes[:'status']
147
+ else
148
+ self.status = nil
149
+ end
150
+
151
+ if attributes.key?(:'interval')
152
+ self.interval = attributes[:'interval']
153
+ else
154
+ self.interval = nil
155
+ end
156
+
157
+ if attributes.key?(:'interval_count')
158
+ self.interval_count = attributes[:'interval_count']
159
+ else
160
+ self.interval_count = nil
161
+ end
162
+
163
+ if attributes.key?(:'quantity')
164
+ self.quantity = attributes[:'quantity']
165
+ else
166
+ self.quantity = nil
167
+ end
168
+
169
+ if attributes.key?(:'price')
170
+ self.price = attributes[:'price']
171
+ else
172
+ self.price = nil
173
+ end
174
+
175
+ if attributes.key?(:'current_period_end')
176
+ self.current_period_end = attributes[:'current_period_end']
177
+ else
178
+ self.current_period_end = nil
179
+ end
180
+
181
+ if attributes.key?(:'cancel_at_period_end')
182
+ self.cancel_at_period_end = attributes[:'cancel_at_period_end']
183
+ else
184
+ self.cancel_at_period_end = nil
185
+ end
186
+
187
+ if attributes.key?(:'ended_at')
188
+ self.ended_at = attributes[:'ended_at']
189
+ else
190
+ self.ended_at = nil
191
+ end
192
+ end
193
+
194
+ # Show invalid properties with the reasons. Usually used together with valid?
195
+ # @return Array for valid properties with the reasons
196
+ def list_invalid_properties
197
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
198
+ invalid_properties = Array.new
199
+ if @stripe_subscription_id.nil?
200
+ invalid_properties.push('invalid value for "stripe_subscription_id", stripe_subscription_id cannot be nil.')
201
+ end
202
+
203
+ if @status.nil?
204
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
205
+ end
206
+
207
+ if @interval.nil?
208
+ invalid_properties.push('invalid value for "interval", interval cannot be nil.')
209
+ end
210
+
211
+ if @interval_count.nil?
212
+ invalid_properties.push('invalid value for "interval_count", interval_count cannot be nil.')
213
+ end
214
+
215
+ if @quantity.nil?
216
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
217
+ end
218
+
219
+ if @current_period_end.nil?
220
+ invalid_properties.push('invalid value for "current_period_end", current_period_end cannot be nil.')
221
+ end
222
+
223
+ if @cancel_at_period_end.nil?
224
+ invalid_properties.push('invalid value for "cancel_at_period_end", cancel_at_period_end cannot be nil.')
225
+ end
226
+
227
+ invalid_properties
228
+ end
229
+
230
+ # Check to see if the all the properties in the model are valid
231
+ # @return true if the model is valid
232
+ def valid?
233
+ warn '[DEPRECATED] the `valid?` method is obsolete'
234
+ return false if @stripe_subscription_id.nil?
235
+ return false if @status.nil?
236
+ return false if @interval.nil?
237
+ interval_validator = EnumAttributeValidator.new('String', ["day", "week", "month", "year", "unknown_default_open_api"])
238
+ return false unless interval_validator.valid?(@interval)
239
+ return false if @interval_count.nil?
240
+ return false if @quantity.nil?
241
+ return false if @current_period_end.nil?
242
+ return false if @cancel_at_period_end.nil?
243
+ true
244
+ end
245
+
246
+ # Custom attribute writer method with validation
247
+ # @param [Object] stripe_subscription_id Value to be assigned
248
+ def stripe_subscription_id=(stripe_subscription_id)
249
+ if stripe_subscription_id.nil?
250
+ fail ArgumentError, 'stripe_subscription_id cannot be nil'
251
+ end
252
+
253
+ @stripe_subscription_id = stripe_subscription_id
254
+ end
255
+
256
+ # Custom attribute writer method with validation
257
+ # @param [Object] status Value to be assigned
258
+ def status=(status)
259
+ if status.nil?
260
+ fail ArgumentError, 'status cannot be nil'
261
+ end
262
+
263
+ @status = status
264
+ end
265
+
266
+ # Custom attribute writer method checking allowed values (enum).
267
+ # @param [Object] interval Object to be assigned
268
+ def interval=(interval)
269
+ validator = EnumAttributeValidator.new('String', ["day", "week", "month", "year", "unknown_default_open_api"])
270
+ unless validator.valid?(interval)
271
+ fail ArgumentError, "invalid value for \"interval\", must be one of #{validator.allowable_values}."
272
+ end
273
+ @interval = interval
274
+ end
275
+
276
+ # Custom attribute writer method with validation
277
+ # @param [Object] interval_count Value to be assigned
278
+ def interval_count=(interval_count)
279
+ if interval_count.nil?
280
+ fail ArgumentError, 'interval_count cannot be nil'
281
+ end
282
+
283
+ @interval_count = interval_count
284
+ end
285
+
286
+ # Custom attribute writer method with validation
287
+ # @param [Object] quantity Value to be assigned
288
+ def quantity=(quantity)
289
+ if quantity.nil?
290
+ fail ArgumentError, 'quantity cannot be nil'
291
+ end
292
+
293
+ @quantity = quantity
294
+ end
295
+
296
+ # Custom attribute writer method with validation
297
+ # @param [Object] current_period_end Value to be assigned
298
+ def current_period_end=(current_period_end)
299
+ if current_period_end.nil?
300
+ fail ArgumentError, 'current_period_end cannot be nil'
301
+ end
302
+
303
+ @current_period_end = current_period_end
304
+ end
305
+
306
+ # Custom attribute writer method with validation
307
+ # @param [Object] cancel_at_period_end Value to be assigned
308
+ def cancel_at_period_end=(cancel_at_period_end)
309
+ if cancel_at_period_end.nil?
310
+ fail ArgumentError, 'cancel_at_period_end cannot be nil'
311
+ end
312
+
313
+ @cancel_at_period_end = cancel_at_period_end
314
+ end
315
+
316
+ # Checks equality by comparing each attribute.
317
+ # @param [Object] Object to be compared
318
+ def ==(o)
319
+ return true if self.equal?(o)
320
+ self.class == o.class &&
321
+ stripe_subscription_id == o.stripe_subscription_id &&
322
+ status == o.status &&
323
+ interval == o.interval &&
324
+ interval_count == o.interval_count &&
325
+ quantity == o.quantity &&
326
+ price == o.price &&
327
+ current_period_end == o.current_period_end &&
328
+ cancel_at_period_end == o.cancel_at_period_end &&
329
+ ended_at == o.ended_at
330
+ end
331
+
332
+ # @see the `==` method
333
+ # @param [Object] Object to be compared
334
+ def eql?(o)
335
+ self == o
336
+ end
337
+
338
+ # Calculates hash code according to all attributes.
339
+ # @return [Integer] Hash code
340
+ def hash
341
+ [stripe_subscription_id, status, interval, interval_count, quantity, price, current_period_end, cancel_at_period_end, ended_at].hash
342
+ end
343
+
344
+ # Builds the object from hash
345
+ # @param [Hash] attributes Model attributes in the form of hash
346
+ # @return [Object] Returns the model itself
347
+ def self.build_from_hash(attributes)
348
+ return nil unless attributes.is_a?(Hash)
349
+ attributes = attributes.transform_keys(&:to_sym)
350
+ # include attributes inherited from allOf parents (the nearest declaration wins)
351
+ map = acceptable_attribute_map
352
+ transformed_hash = {}
353
+ acceptable_openapi_types.each_pair do |key, type|
354
+ if attributes.key?(map[key]) && attributes[map[key]].nil?
355
+ transformed_hash["#{key}"] = nil
356
+ elsif type =~ /\AArray<(.*)>/i
357
+ # check to ensure the input is an array given that the attribute
358
+ # is documented as an array but the input is not
359
+ if attributes[map[key]].is_a?(Array)
360
+ transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
361
+ end
362
+ elsif !attributes[map[key]].nil?
363
+ transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
364
+ end
365
+ end
366
+ new(transformed_hash)
367
+ end
368
+
369
+ # Returns the object in the form of hash
370
+ # @return [Hash] Returns the object in the form of hash
371
+ def to_hash
372
+ hash = {}
373
+ # include attributes inherited from allOf parents (the nearest declaration wins)
374
+ self.class.acceptable_attribute_map.each_pair do |attr, param|
375
+ value = self.send(attr)
376
+ if value.nil?
377
+ is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
378
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
379
+ end
380
+
381
+ hash[param] = _to_hash(value)
382
+ end
383
+ hash
384
+ end
385
+
386
+ end
387
+
388
+ end