smplkit 3.0.7 → 3.0.9

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/api_keys_api.rb +7 -0
  3. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb +16 -464
  4. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/context_types_api.rb +7 -0
  5. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/contexts_api.rb +7 -0
  6. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/environments_api.rb +7 -0
  7. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/invitations_api.rb +7 -0
  8. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/metrics_api.rb +23 -2
  9. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/plans_api.rb +9 -2
  10. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/products_api.rb +9 -2
  11. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/services_api.rb +7 -0
  12. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/subscription_api.rb +289 -0
  13. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/users_api.rb +7 -0
  14. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_list_response.rb → admin_subscription_request.rb} +9 -20
  15. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/admin_subscription_request_attributes.rb +190 -0
  16. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_data.rb → admin_subscription_request_resource.rb} +46 -12
  17. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{next_tier_meta.rb → next_tier_response.rb} +6 -6
  18. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_change_projection.rb +321 -0
  19. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_attributes.rb → subscription_item_request.rb} +10 -21
  20. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_attributes.rb → subscription_item_response.rb} +66 -77
  21. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb +390 -0
  22. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_resource.rb +241 -0
  23. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{plan_change_request.rb → subscription_preview_response.rb} +20 -21
  24. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{create_subscription_body.rb → subscription_request.rb} +5 -5
  25. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_request_attributes.rb +179 -0
  26. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_request_resource.rb +227 -0
  27. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_resource.rb +4 -2
  28. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_response.rb +1 -1
  29. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/{subscription_list_meta.rb → subscription_response_attributes.rb} +135 -62
  30. data/lib/smplkit/_generated/app/lib/smplkit_app_client.rb +15 -8
  31. data/lib/smplkit/_generated/app/spec/api/api_keys_api_spec.rb +1 -0
  32. data/lib/smplkit/_generated/app/spec/api/billing_api_spec.rb +3 -86
  33. data/lib/smplkit/_generated/app/spec/api/context_types_api_spec.rb +1 -0
  34. data/lib/smplkit/_generated/app/spec/api/contexts_api_spec.rb +1 -0
  35. data/lib/smplkit/_generated/app/spec/api/environments_api_spec.rb +1 -0
  36. data/lib/smplkit/_generated/app/spec/api/invitations_api_spec.rb +1 -0
  37. data/lib/smplkit/_generated/app/spec/api/metrics_api_spec.rb +4 -1
  38. data/lib/smplkit/_generated/app/spec/api/plans_api_spec.rb +2 -1
  39. data/lib/smplkit/_generated/app/spec/api/products_api_spec.rb +2 -1
  40. data/lib/smplkit/_generated/app/spec/api/services_api_spec.rb +1 -0
  41. data/lib/smplkit/_generated/app/spec/api/subscription_api_spec.rb +83 -0
  42. data/lib/smplkit/_generated/app/spec/api/users_api_spec.rb +1 -0
  43. data/lib/smplkit/_generated/app/spec/models/{create_subscription_attributes_spec.rb → admin_subscription_request_attributes_spec.rb} +9 -9
  44. data/lib/smplkit/_generated/app/spec/models/admin_subscription_request_resource_spec.rb +52 -0
  45. data/lib/smplkit/_generated/app/spec/models/{plan_change_request_spec.rb → admin_subscription_request_spec.rb} +7 -7
  46. data/lib/smplkit/_generated/app/spec/models/{next_tier_meta_spec.rb → next_tier_response_spec.rb} +6 -6
  47. data/lib/smplkit/_generated/app/spec/models/{subscription_list_meta_spec.rb → subscription_change_projection_spec.rb} +20 -14
  48. data/lib/smplkit/_generated/app/spec/models/{create_subscription_data_spec.rb → subscription_item_request_spec.rb} +8 -8
  49. data/lib/smplkit/_generated/app/spec/models/{subscription_attributes_spec.rb → subscription_item_response_spec.rb} +12 -18
  50. data/lib/smplkit/_generated/app/spec/models/subscription_preview_attributes_spec.rb +88 -0
  51. data/lib/smplkit/_generated/app/spec/models/subscription_preview_resource_spec.rb +56 -0
  52. data/lib/smplkit/_generated/app/spec/models/subscription_preview_response_spec.rb +36 -0
  53. data/lib/smplkit/_generated/app/spec/models/{subscription_list_response_spec.rb → subscription_request_attributes_spec.rb} +8 -8
  54. data/lib/smplkit/_generated/app/spec/models/subscription_request_resource_spec.rb +52 -0
  55. data/lib/smplkit/_generated/app/spec/models/{create_subscription_body_spec.rb → subscription_request_spec.rb} +6 -6
  56. data/lib/smplkit/_generated/app/spec/models/subscription_response_attributes_spec.rb +100 -0
  57. metadata +31 -17
@@ -0,0 +1,390 @@
1
+ =begin
2
+ #smplkit API
3
+
4
+ #API for the smplkit platform.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SmplkitGeneratedClient::App
17
+ # Projected totals and per-change breakdown for a hypothetical change.
18
+ class SubscriptionPreviewAttributes < ApiModelBase
19
+ # Projected sum of item monthly list prices after the change.
20
+ attr_accessor :projected_subtotal_cents
21
+
22
+ # Projected discount percentage that will apply after the change.
23
+ attr_accessor :projected_discount_pct
24
+
25
+ # `VOLUME` when the projected discount comes from the multi-product schedule; `OVERRIDE` when an administrator's discount applies.
26
+ attr_accessor :projected_discount_source
27
+
28
+ # Projected discount amount in cents after the change.
29
+ attr_accessor :projected_discount_amount_cents
30
+
31
+ # Projected final monthly total in cents after the change.
32
+ attr_accessor :projected_total_cents
33
+
34
+ attr_accessor :projected_next_tier
35
+
36
+ # Per-product breakdown of changes the desired state would produce. Products that would remain unchanged are omitted.
37
+ attr_accessor :changes
38
+
39
+ # Total amount that would be charged at confirmation time, in cents. The sum of `prorated_charge_today_cents` across `IMMEDIATE` changes.
40
+ attr_accessor :total_charge_today_cents
41
+
42
+ # Projected total of the next monthly invoice in cents, after all scheduled changes have taken effect.
43
+ attr_accessor :next_invoice_total_cents
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'projected_subtotal_cents' => :'projected_subtotal_cents',
71
+ :'projected_discount_pct' => :'projected_discount_pct',
72
+ :'projected_discount_source' => :'projected_discount_source',
73
+ :'projected_discount_amount_cents' => :'projected_discount_amount_cents',
74
+ :'projected_total_cents' => :'projected_total_cents',
75
+ :'projected_next_tier' => :'projected_next_tier',
76
+ :'changes' => :'changes',
77
+ :'total_charge_today_cents' => :'total_charge_today_cents',
78
+ :'next_invoice_total_cents' => :'next_invoice_total_cents'
79
+ }
80
+ end
81
+
82
+ # Returns attribute mapping this model knows about
83
+ def self.acceptable_attribute_map
84
+ attribute_map
85
+ end
86
+
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ acceptable_attribute_map.values
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'projected_subtotal_cents' => :'Integer',
96
+ :'projected_discount_pct' => :'Integer',
97
+ :'projected_discount_source' => :'String',
98
+ :'projected_discount_amount_cents' => :'Integer',
99
+ :'projected_total_cents' => :'Integer',
100
+ :'projected_next_tier' => :'NextTierResponse',
101
+ :'changes' => :'Array<SubscriptionChangeProjection>',
102
+ :'total_charge_today_cents' => :'Integer',
103
+ :'next_invoice_total_cents' => :'Integer'
104
+ }
105
+ end
106
+
107
+ # List of attributes with nullable: true
108
+ def self.openapi_nullable
109
+ Set.new([
110
+ ])
111
+ end
112
+
113
+ # Initializes the object
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ def initialize(attributes = {})
116
+ if (!attributes.is_a?(Hash))
117
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::SubscriptionPreviewAttributes` initialize method"
118
+ end
119
+
120
+ # check to see if the attribute exists and convert string to symbol for hash key
121
+ acceptable_attribute_map = self.class.acceptable_attribute_map
122
+ attributes = attributes.each_with_object({}) { |(k, v), h|
123
+ if (!acceptable_attribute_map.key?(k.to_sym))
124
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::SubscriptionPreviewAttributes`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
125
+ end
126
+ h[k.to_sym] = v
127
+ }
128
+
129
+ if attributes.key?(:'projected_subtotal_cents')
130
+ self.projected_subtotal_cents = attributes[:'projected_subtotal_cents']
131
+ else
132
+ self.projected_subtotal_cents = nil
133
+ end
134
+
135
+ if attributes.key?(:'projected_discount_pct')
136
+ self.projected_discount_pct = attributes[:'projected_discount_pct']
137
+ else
138
+ self.projected_discount_pct = nil
139
+ end
140
+
141
+ if attributes.key?(:'projected_discount_source')
142
+ self.projected_discount_source = attributes[:'projected_discount_source']
143
+ else
144
+ self.projected_discount_source = nil
145
+ end
146
+
147
+ if attributes.key?(:'projected_discount_amount_cents')
148
+ self.projected_discount_amount_cents = attributes[:'projected_discount_amount_cents']
149
+ else
150
+ self.projected_discount_amount_cents = nil
151
+ end
152
+
153
+ if attributes.key?(:'projected_total_cents')
154
+ self.projected_total_cents = attributes[:'projected_total_cents']
155
+ else
156
+ self.projected_total_cents = nil
157
+ end
158
+
159
+ if attributes.key?(:'projected_next_tier')
160
+ self.projected_next_tier = attributes[:'projected_next_tier']
161
+ end
162
+
163
+ if attributes.key?(:'changes')
164
+ if (value = attributes[:'changes']).is_a?(Array)
165
+ self.changes = value
166
+ end
167
+ else
168
+ self.changes = nil
169
+ end
170
+
171
+ if attributes.key?(:'total_charge_today_cents')
172
+ self.total_charge_today_cents = attributes[:'total_charge_today_cents']
173
+ else
174
+ self.total_charge_today_cents = nil
175
+ end
176
+
177
+ if attributes.key?(:'next_invoice_total_cents')
178
+ self.next_invoice_total_cents = attributes[:'next_invoice_total_cents']
179
+ else
180
+ self.next_invoice_total_cents = nil
181
+ end
182
+ end
183
+
184
+ # Show invalid properties with the reasons. Usually used together with valid?
185
+ # @return Array for valid properties with the reasons
186
+ def list_invalid_properties
187
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
188
+ invalid_properties = Array.new
189
+ if @projected_subtotal_cents.nil?
190
+ invalid_properties.push('invalid value for "projected_subtotal_cents", projected_subtotal_cents cannot be nil.')
191
+ end
192
+
193
+ if @projected_discount_pct.nil?
194
+ invalid_properties.push('invalid value for "projected_discount_pct", projected_discount_pct cannot be nil.')
195
+ end
196
+
197
+ if @projected_discount_source.nil?
198
+ invalid_properties.push('invalid value for "projected_discount_source", projected_discount_source cannot be nil.')
199
+ end
200
+
201
+ if @projected_discount_amount_cents.nil?
202
+ invalid_properties.push('invalid value for "projected_discount_amount_cents", projected_discount_amount_cents cannot be nil.')
203
+ end
204
+
205
+ if @projected_total_cents.nil?
206
+ invalid_properties.push('invalid value for "projected_total_cents", projected_total_cents cannot be nil.')
207
+ end
208
+
209
+ if @changes.nil?
210
+ invalid_properties.push('invalid value for "changes", changes cannot be nil.')
211
+ end
212
+
213
+ if @total_charge_today_cents.nil?
214
+ invalid_properties.push('invalid value for "total_charge_today_cents", total_charge_today_cents cannot be nil.')
215
+ end
216
+
217
+ if @next_invoice_total_cents.nil?
218
+ invalid_properties.push('invalid value for "next_invoice_total_cents", next_invoice_total_cents cannot be nil.')
219
+ end
220
+
221
+ invalid_properties
222
+ end
223
+
224
+ # Check to see if the all the properties in the model are valid
225
+ # @return true if the model is valid
226
+ def valid?
227
+ warn '[DEPRECATED] the `valid?` method is obsolete'
228
+ return false if @projected_subtotal_cents.nil?
229
+ return false if @projected_discount_pct.nil?
230
+ return false if @projected_discount_source.nil?
231
+ projected_discount_source_validator = EnumAttributeValidator.new('String', ["VOLUME", "OVERRIDE"])
232
+ return false unless projected_discount_source_validator.valid?(@projected_discount_source)
233
+ return false if @projected_discount_amount_cents.nil?
234
+ return false if @projected_total_cents.nil?
235
+ return false if @changes.nil?
236
+ return false if @total_charge_today_cents.nil?
237
+ return false if @next_invoice_total_cents.nil?
238
+ true
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] projected_subtotal_cents Value to be assigned
243
+ def projected_subtotal_cents=(projected_subtotal_cents)
244
+ if projected_subtotal_cents.nil?
245
+ fail ArgumentError, 'projected_subtotal_cents cannot be nil'
246
+ end
247
+
248
+ @projected_subtotal_cents = projected_subtotal_cents
249
+ end
250
+
251
+ # Custom attribute writer method with validation
252
+ # @param [Object] projected_discount_pct Value to be assigned
253
+ def projected_discount_pct=(projected_discount_pct)
254
+ if projected_discount_pct.nil?
255
+ fail ArgumentError, 'projected_discount_pct cannot be nil'
256
+ end
257
+
258
+ @projected_discount_pct = projected_discount_pct
259
+ end
260
+
261
+ # Custom attribute writer method checking allowed values (enum).
262
+ # @param [Object] projected_discount_source Object to be assigned
263
+ def projected_discount_source=(projected_discount_source)
264
+ validator = EnumAttributeValidator.new('String', ["VOLUME", "OVERRIDE"])
265
+ unless validator.valid?(projected_discount_source)
266
+ fail ArgumentError, "invalid value for \"projected_discount_source\", must be one of #{validator.allowable_values}."
267
+ end
268
+ @projected_discount_source = projected_discount_source
269
+ end
270
+
271
+ # Custom attribute writer method with validation
272
+ # @param [Object] projected_discount_amount_cents Value to be assigned
273
+ def projected_discount_amount_cents=(projected_discount_amount_cents)
274
+ if projected_discount_amount_cents.nil?
275
+ fail ArgumentError, 'projected_discount_amount_cents cannot be nil'
276
+ end
277
+
278
+ @projected_discount_amount_cents = projected_discount_amount_cents
279
+ end
280
+
281
+ # Custom attribute writer method with validation
282
+ # @param [Object] projected_total_cents Value to be assigned
283
+ def projected_total_cents=(projected_total_cents)
284
+ if projected_total_cents.nil?
285
+ fail ArgumentError, 'projected_total_cents cannot be nil'
286
+ end
287
+
288
+ @projected_total_cents = projected_total_cents
289
+ end
290
+
291
+ # Custom attribute writer method with validation
292
+ # @param [Object] changes Value to be assigned
293
+ def changes=(changes)
294
+ if changes.nil?
295
+ fail ArgumentError, 'changes cannot be nil'
296
+ end
297
+
298
+ @changes = changes
299
+ end
300
+
301
+ # Custom attribute writer method with validation
302
+ # @param [Object] total_charge_today_cents Value to be assigned
303
+ def total_charge_today_cents=(total_charge_today_cents)
304
+ if total_charge_today_cents.nil?
305
+ fail ArgumentError, 'total_charge_today_cents cannot be nil'
306
+ end
307
+
308
+ @total_charge_today_cents = total_charge_today_cents
309
+ end
310
+
311
+ # Custom attribute writer method with validation
312
+ # @param [Object] next_invoice_total_cents Value to be assigned
313
+ def next_invoice_total_cents=(next_invoice_total_cents)
314
+ if next_invoice_total_cents.nil?
315
+ fail ArgumentError, 'next_invoice_total_cents cannot be nil'
316
+ end
317
+
318
+ @next_invoice_total_cents = next_invoice_total_cents
319
+ end
320
+
321
+ # Checks equality by comparing each attribute.
322
+ # @param [Object] Object to be compared
323
+ def ==(o)
324
+ return true if self.equal?(o)
325
+ self.class == o.class &&
326
+ projected_subtotal_cents == o.projected_subtotal_cents &&
327
+ projected_discount_pct == o.projected_discount_pct &&
328
+ projected_discount_source == o.projected_discount_source &&
329
+ projected_discount_amount_cents == o.projected_discount_amount_cents &&
330
+ projected_total_cents == o.projected_total_cents &&
331
+ projected_next_tier == o.projected_next_tier &&
332
+ changes == o.changes &&
333
+ total_charge_today_cents == o.total_charge_today_cents &&
334
+ next_invoice_total_cents == o.next_invoice_total_cents
335
+ end
336
+
337
+ # @see the `==` method
338
+ # @param [Object] Object to be compared
339
+ def eql?(o)
340
+ self == o
341
+ end
342
+
343
+ # Calculates hash code according to all attributes.
344
+ # @return [Integer] Hash code
345
+ def hash
346
+ [projected_subtotal_cents, projected_discount_pct, projected_discount_source, projected_discount_amount_cents, projected_total_cents, projected_next_tier, changes, total_charge_today_cents, next_invoice_total_cents].hash
347
+ end
348
+
349
+ # Builds the object from hash
350
+ # @param [Hash] attributes Model attributes in the form of hash
351
+ # @return [Object] Returns the model itself
352
+ def self.build_from_hash(attributes)
353
+ return nil unless attributes.is_a?(Hash)
354
+ attributes = attributes.transform_keys(&:to_sym)
355
+ transformed_hash = {}
356
+ openapi_types.each_pair do |key, type|
357
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
358
+ transformed_hash["#{key}"] = nil
359
+ elsif type =~ /\AArray<(.*)>/i
360
+ # check to ensure the input is an array given that the attribute
361
+ # is documented as an array but the input is not
362
+ if attributes[attribute_map[key]].is_a?(Array)
363
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
364
+ end
365
+ elsif !attributes[attribute_map[key]].nil?
366
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
367
+ end
368
+ end
369
+ new(transformed_hash)
370
+ end
371
+
372
+ # Returns the object in the form of hash
373
+ # @return [Hash] Returns the object in the form of hash
374
+ def to_hash
375
+ hash = {}
376
+ self.class.attribute_map.each_pair do |attr, param|
377
+ value = self.send(attr)
378
+ if value.nil?
379
+ is_nullable = self.class.openapi_nullable.include?(attr)
380
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
381
+ end
382
+
383
+ hash[param] = _to_hash(value)
384
+ end
385
+ hash
386
+ end
387
+
388
+ end
389
+
390
+ end
@@ -0,0 +1,241 @@
1
+ =begin
2
+ #smplkit API
3
+
4
+ #API for the smplkit platform.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SmplkitGeneratedClient::App
17
+ # JSON:API resource object for a subscription preview.
18
+ class SubscriptionPreviewResource < ApiModelBase
19
+ # Always `preview`.
20
+ attr_accessor :id
21
+
22
+ # JSON:API resource type.
23
+ attr_accessor :type
24
+
25
+ attr_accessor :attributes
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'id' => :'id',
53
+ :'type' => :'type',
54
+ :'attributes' => :'attributes'
55
+ }
56
+ end
57
+
58
+ # Returns attribute mapping this model knows about
59
+ def self.acceptable_attribute_map
60
+ attribute_map
61
+ end
62
+
63
+ # Returns all the JSON keys this model knows about
64
+ def self.acceptable_attributes
65
+ acceptable_attribute_map.values
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'id' => :'String',
72
+ :'type' => :'String',
73
+ :'attributes' => :'SubscriptionPreviewAttributes'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ :'id',
81
+ ])
82
+ end
83
+
84
+ # Initializes the object
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ def initialize(attributes = {})
87
+ if (!attributes.is_a?(Hash))
88
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::SubscriptionPreviewResource` initialize method"
89
+ end
90
+
91
+ # check to see if the attribute exists and convert string to symbol for hash key
92
+ acceptable_attribute_map = self.class.acceptable_attribute_map
93
+ attributes = attributes.each_with_object({}) { |(k, v), h|
94
+ if (!acceptable_attribute_map.key?(k.to_sym))
95
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::SubscriptionPreviewResource`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
96
+ end
97
+ h[k.to_sym] = v
98
+ }
99
+
100
+ if attributes.key?(:'id')
101
+ self.id = attributes[:'id']
102
+ else
103
+ self.id = 'preview'
104
+ end
105
+
106
+ if attributes.key?(:'type')
107
+ self.type = attributes[:'type']
108
+ else
109
+ self.type = nil
110
+ end
111
+
112
+ if attributes.key?(:'attributes')
113
+ self.attributes = attributes[:'attributes']
114
+ else
115
+ self.attributes = nil
116
+ end
117
+ end
118
+
119
+ # Show invalid properties with the reasons. Usually used together with valid?
120
+ # @return Array for valid properties with the reasons
121
+ def list_invalid_properties
122
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
123
+ invalid_properties = Array.new
124
+ if @type.nil?
125
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
126
+ end
127
+
128
+ if @attributes.nil?
129
+ invalid_properties.push('invalid value for "attributes", attributes cannot be nil.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ warn '[DEPRECATED] the `valid?` method is obsolete'
139
+ id_validator = EnumAttributeValidator.new('String', ["preview"])
140
+ return false unless id_validator.valid?(@id)
141
+ return false if @type.nil?
142
+ type_validator = EnumAttributeValidator.new('String', ["subscription_preview"])
143
+ return false unless type_validator.valid?(@type)
144
+ return false if @attributes.nil?
145
+ true
146
+ end
147
+
148
+ # Custom attribute writer method checking allowed values (enum).
149
+ # @param [Object] id Object to be assigned
150
+ def id=(id)
151
+ validator = EnumAttributeValidator.new('String', ["preview"])
152
+ unless validator.valid?(id)
153
+ fail ArgumentError, "invalid value for \"id\", must be one of #{validator.allowable_values}."
154
+ end
155
+ @id = id
156
+ end
157
+
158
+ # Custom attribute writer method checking allowed values (enum).
159
+ # @param [Object] type Object to be assigned
160
+ def type=(type)
161
+ validator = EnumAttributeValidator.new('String', ["subscription_preview"])
162
+ unless validator.valid?(type)
163
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
164
+ end
165
+ @type = type
166
+ end
167
+
168
+ # Custom attribute writer method with validation
169
+ # @param [Object] attributes Value to be assigned
170
+ def attributes=(attributes)
171
+ if attributes.nil?
172
+ fail ArgumentError, 'attributes cannot be nil'
173
+ end
174
+
175
+ @attributes = attributes
176
+ end
177
+
178
+ # Checks equality by comparing each attribute.
179
+ # @param [Object] Object to be compared
180
+ def ==(o)
181
+ return true if self.equal?(o)
182
+ self.class == o.class &&
183
+ id == o.id &&
184
+ type == o.type &&
185
+ attributes == o.attributes
186
+ end
187
+
188
+ # @see the `==` method
189
+ # @param [Object] Object to be compared
190
+ def eql?(o)
191
+ self == o
192
+ end
193
+
194
+ # Calculates hash code according to all attributes.
195
+ # @return [Integer] Hash code
196
+ def hash
197
+ [id, type, attributes].hash
198
+ end
199
+
200
+ # Builds the object from hash
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ # @return [Object] Returns the model itself
203
+ def self.build_from_hash(attributes)
204
+ return nil unless attributes.is_a?(Hash)
205
+ attributes = attributes.transform_keys(&:to_sym)
206
+ transformed_hash = {}
207
+ openapi_types.each_pair do |key, type|
208
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
209
+ transformed_hash["#{key}"] = nil
210
+ elsif type =~ /\AArray<(.*)>/i
211
+ # check to ensure the input is an array given that the attribute
212
+ # is documented as an array but the input is not
213
+ if attributes[attribute_map[key]].is_a?(Array)
214
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
215
+ end
216
+ elsif !attributes[attribute_map[key]].nil?
217
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
218
+ end
219
+ end
220
+ new(transformed_hash)
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ end
240
+
241
+ end