license_manager 0.2.0 → 0.3.0

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -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 +2 -0
  11. data/docs/LicenseSubscription.md +34 -0
  12. data/docs/LicensesApi.md +1 -1
  13. data/docs/Mrr.md +26 -0
  14. data/docs/MrrByIntervalInner.md +24 -0
  15. data/docs/MrrByPolicyInner.md +22 -0
  16. data/docs/PortalApi.md +79 -0
  17. data/docs/ProductStats.md +2 -0
  18. data/docs/Revenue.md +8 -4
  19. data/docs/StripePermission.md +3 -1
  20. data/docs/StripePrice.md +2 -0
  21. data/docs/StripePriceRecurring.md +20 -0
  22. data/docs/SubscriptionStats.md +38 -0
  23. data/docs/UpdateIntegration.md +3 -1
  24. data/lib/license_manager/api/licenses_api.rb +2 -2
  25. data/lib/license_manager/api/portal_api.rb +70 -0
  26. data/lib/license_manager/models/billing_portal_session.rb +178 -0
  27. data/lib/license_manager/models/create_billing_portal_session.rb +161 -0
  28. data/lib/license_manager/models/create_integration_mapping.rb +1 -1
  29. data/lib/license_manager/models/event_type.rb +4 -1
  30. data/lib/license_manager/models/integration.rb +82 -1
  31. data/lib/license_manager/models/integration_mapping.rb +13 -1
  32. data/lib/license_manager/models/integration_mapping_recurring.rb +228 -0
  33. data/lib/license_manager/models/license.rb +13 -1
  34. data/lib/license_manager/models/license_subscription.rb +388 -0
  35. data/lib/license_manager/models/mrr.rb +291 -0
  36. data/lib/license_manager/models/mrr_by_interval_inner.rb +279 -0
  37. data/lib/license_manager/models/mrr_by_policy_inner.rb +229 -0
  38. data/lib/license_manager/models/product_stats.rb +14 -1
  39. data/lib/license_manager/models/revenue.rb +60 -6
  40. data/lib/license_manager/models/stripe_permission.rb +31 -4
  41. data/lib/license_manager/models/stripe_price.rb +13 -1
  42. data/lib/license_manager/models/stripe_price_recurring.rb +228 -0
  43. data/lib/license_manager/models/subscription_stats.rb +456 -0
  44. data/lib/license_manager/models/update_integration.rb +42 -4
  45. data/lib/license_manager/version.rb +1 -1
  46. data/lib/license_manager.rb +9 -0
  47. data/openapi.json +563 -10
  48. data/spec/api/licenses_api_spec.rb +1 -1
  49. data/spec/api/portal_api_spec.rb +13 -0
  50. data/spec/models/billing_portal_session_spec.rb +36 -0
  51. data/spec/models/create_billing_portal_session_spec.rb +36 -0
  52. data/spec/models/create_token_spec.rb +1 -1
  53. data/spec/models/integration_mapping_recurring_spec.rb +46 -0
  54. data/spec/models/integration_mapping_spec.rb +6 -0
  55. data/spec/models/integration_spec.rb +18 -0
  56. data/spec/models/license_spec.rb +6 -0
  57. data/spec/models/license_subscription_spec.rb +88 -0
  58. data/spec/models/mrr_by_interval_inner_spec.rb +58 -0
  59. data/spec/models/mrr_by_policy_inner_spec.rb +48 -0
  60. data/spec/models/mrr_spec.rb +60 -0
  61. data/spec/models/product_stats_spec.rb +6 -0
  62. data/spec/models/revenue_spec.rb +12 -0
  63. data/spec/models/stripe_permission_spec.rb +6 -0
  64. data/spec/models/stripe_price_recurring_spec.rb +46 -0
  65. data/spec/models/stripe_price_spec.rb +6 -0
  66. data/spec/models/subscription_stats_spec.rb +96 -0
  67. data/spec/models/token_spec.rb +1 -1
  68. data/spec/models/update_integration_spec.rb +6 -0
  69. metadata +37 -1
@@ -0,0 +1,228 @@
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
+ # Billing period of a recurring price, `null` for a one-time price. Subscribing to a recurring price creates one subscription license, valid while it's paid.
18
+ class IntegrationMappingRecurring < ApiModelBase
19
+ attr_accessor :interval
20
+
21
+ attr_accessor :interval_count
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'interval' => :'interval',
49
+ :'interval_count' => :'intervalCount'
50
+ }
51
+ end
52
+
53
+ # Returns attribute mapping this model knows about
54
+ def self.acceptable_attribute_map
55
+ attribute_map
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ acceptable_attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'interval' => :'String',
67
+ :'interval_count' => :'Integer'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Returns attribute type mapping
78
+ def self.acceptable_openapi_types
79
+ openapi_types
80
+ end
81
+
82
+ # Returns the nullable attributes
83
+ def self.acceptable_openapi_nullable
84
+ openapi_nullable
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `LicenseManager::IntegrationMappingRecurring` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ acceptable_attribute_map = self.class.acceptable_attribute_map
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!acceptable_attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `LicenseManager::IntegrationMappingRecurring`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'interval')
104
+ self.interval = attributes[:'interval']
105
+ else
106
+ self.interval = nil
107
+ end
108
+
109
+ if attributes.key?(:'interval_count')
110
+ self.interval_count = attributes[:'interval_count']
111
+ else
112
+ self.interval_count = nil
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
120
+ invalid_properties = Array.new
121
+ if @interval.nil?
122
+ invalid_properties.push('invalid value for "interval", interval cannot be nil.')
123
+ end
124
+
125
+ if @interval_count.nil?
126
+ invalid_properties.push('invalid value for "interval_count", interval_count cannot be nil.')
127
+ end
128
+
129
+ invalid_properties
130
+ end
131
+
132
+ # Check to see if the all the properties in the model are valid
133
+ # @return true if the model is valid
134
+ def valid?
135
+ warn '[DEPRECATED] the `valid?` method is obsolete'
136
+ return false if @interval.nil?
137
+ interval_validator = EnumAttributeValidator.new('String', ["day", "week", "month", "year", "unknown_default_open_api"])
138
+ return false unless interval_validator.valid?(@interval)
139
+ return false if @interval_count.nil?
140
+ true
141
+ end
142
+
143
+ # Custom attribute writer method checking allowed values (enum).
144
+ # @param [Object] interval Object to be assigned
145
+ def interval=(interval)
146
+ validator = EnumAttributeValidator.new('String', ["day", "week", "month", "year", "unknown_default_open_api"])
147
+ unless validator.valid?(interval)
148
+ fail ArgumentError, "invalid value for \"interval\", must be one of #{validator.allowable_values}."
149
+ end
150
+ @interval = interval
151
+ end
152
+
153
+ # Custom attribute writer method with validation
154
+ # @param [Object] interval_count Value to be assigned
155
+ def interval_count=(interval_count)
156
+ if interval_count.nil?
157
+ fail ArgumentError, 'interval_count cannot be nil'
158
+ end
159
+
160
+ @interval_count = interval_count
161
+ end
162
+
163
+ # Checks equality by comparing each attribute.
164
+ # @param [Object] Object to be compared
165
+ def ==(o)
166
+ return true if self.equal?(o)
167
+ self.class == o.class &&
168
+ interval == o.interval &&
169
+ interval_count == o.interval_count
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(o)
175
+ self == o
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Integer] Hash code
180
+ def hash
181
+ [interval, interval_count].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def self.build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ # include attributes inherited from allOf parents (the nearest declaration wins)
191
+ map = acceptable_attribute_map
192
+ transformed_hash = {}
193
+ acceptable_openapi_types.each_pair do |key, type|
194
+ if attributes.key?(map[key]) && attributes[map[key]].nil?
195
+ transformed_hash["#{key}"] = nil
196
+ elsif type =~ /\AArray<(.*)>/i
197
+ # check to ensure the input is an array given that the attribute
198
+ # is documented as an array but the input is not
199
+ if attributes[map[key]].is_a?(Array)
200
+ transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
201
+ end
202
+ elsif !attributes[map[key]].nil?
203
+ transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
204
+ end
205
+ end
206
+ new(transformed_hash)
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ # include attributes inherited from allOf parents (the nearest declaration wins)
214
+ self.class.acceptable_attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ end
227
+
228
+ end
@@ -63,6 +63,8 @@ module LicenseManager
63
63
 
64
64
  attr_accessor :cancellation_reason
65
65
 
66
+ attr_accessor :subscription
67
+
66
68
  # Comment given when the license was canceled. `null` when there's none.
67
69
  attr_accessor :cancellation_comment
68
70
 
@@ -116,6 +118,7 @@ module LicenseManager
116
118
  :'cancellable_until' => :'cancellableUntil',
117
119
  :'canceled_at' => :'canceledAt',
118
120
  :'cancellation_reason' => :'cancellationReason',
121
+ :'subscription' => :'subscription',
119
122
  :'cancellation_comment' => :'cancellationComment',
120
123
  :'stripe_refund_id' => :'stripeRefundId',
121
124
  :'updated_at' => :'updatedAt'
@@ -154,6 +157,7 @@ module LicenseManager
154
157
  :'cancellable_until' => :'Time',
155
158
  :'canceled_at' => :'Time',
156
159
  :'cancellation_reason' => :'CancellationReason',
160
+ :'subscription' => :'LicenseSubscription',
157
161
  :'cancellation_comment' => :'String',
158
162
  :'stripe_refund_id' => :'String',
159
163
  :'updated_at' => :'Time'
@@ -171,6 +175,7 @@ module LicenseManager
171
175
  :'price',
172
176
  :'cancellable_until',
173
177
  :'canceled_at',
178
+ :'subscription',
174
179
  :'cancellation_comment',
175
180
  :'stripe_refund_id',
176
181
  ])
@@ -318,6 +323,12 @@ module LicenseManager
318
323
  self.cancellation_reason = nil
319
324
  end
320
325
 
326
+ if attributes.key?(:'subscription')
327
+ self.subscription = attributes[:'subscription']
328
+ else
329
+ self.subscription = nil
330
+ end
331
+
321
332
  if attributes.key?(:'cancellation_comment')
322
333
  self.cancellation_comment = attributes[:'cancellation_comment']
323
334
  else
@@ -556,6 +567,7 @@ module LicenseManager
556
567
  cancellable_until == o.cancellable_until &&
557
568
  canceled_at == o.canceled_at &&
558
569
  cancellation_reason == o.cancellation_reason &&
570
+ subscription == o.subscription &&
559
571
  cancellation_comment == o.cancellation_comment &&
560
572
  stripe_refund_id == o.stripe_refund_id &&
561
573
  updated_at == o.updated_at
@@ -570,7 +582,7 @@ module LicenseManager
570
582
  # Calculates hash code according to all attributes.
571
583
  # @return [Integer] Hash code
572
584
  def hash
573
- [id, product_id, policy_id, customer_id, key, created_at, expires_at, meta, stripe_payment_intent_id, max_machines, max_offline_duration_seconds, active_machine_count, last_activated_at, max_version, price, status, cancellable_until, canceled_at, cancellation_reason, cancellation_comment, stripe_refund_id, updated_at].hash
585
+ [id, product_id, policy_id, customer_id, key, created_at, expires_at, meta, stripe_payment_intent_id, max_machines, max_offline_duration_seconds, active_machine_count, last_activated_at, max_version, price, status, cancellable_until, canceled_at, cancellation_reason, subscription, cancellation_comment, stripe_refund_id, updated_at].hash
574
586
  end
575
587
 
576
588
  # Builds the object from hash
@@ -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