seatschart 0.4.0 → 0.5.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +44 -9
  3. data/lib/seatschart/api/audit_api.rb +2 -2
  4. data/lib/seatschart/api/auth_api.rb +4 -4
  5. data/lib/seatschart/api/billing_api.rb +93 -12
  6. data/lib/seatschart/api/charts_api.rb +52 -52
  7. data/lib/seatschart/api/events_api.rb +110 -104
  8. data/lib/seatschart/api/seasons_api.rb +88 -88
  9. data/lib/seatschart/api/seats_api.rb +6 -6
  10. data/lib/seatschart/api/usage_api.rb +4 -4
  11. data/lib/seatschart/api/workspace_api.rb +52 -40
  12. data/lib/seatschart/models/{api_error.rb → api_error_body.rb} +7 -7
  13. data/lib/seatschart/models/delete_api_workspaces_by_workspace_id_members_by_user_id200_response.rb +221 -0
  14. data/lib/seatschart/models/get_api_workspaces_by_workspace_id_invitations200_response.rb +239 -0
  15. data/lib/seatschart/models/get_api_workspaces_by_workspace_id_invitations200_response_invitations_inner.rb +286 -0
  16. data/lib/seatschart/models/get_api_workspaces_by_workspace_id_members200_response.rb +239 -0
  17. data/lib/seatschart/models/get_api_workspaces_by_workspace_id_members200_response_members_inner.rb +288 -0
  18. data/lib/seatschart/models/get_api_workspaces_overview200_response.rb +288 -0
  19. data/lib/seatschart/models/get_api_workspaces_overview200_response_account.rb +270 -0
  20. data/lib/seatschart/models/get_api_workspaces_overview200_response_account_charts.rb +233 -0
  21. data/lib/seatschart/models/get_api_workspaces_overview200_response_account_plan.rb +237 -0
  22. data/lib/seatschart/models/get_api_workspaces_overview200_response_items_inner.rb +439 -0
  23. data/lib/seatschart/models/get_api_workspaces_overview200_response_items_inner_revenue.rb +234 -0
  24. data/lib/seatschart/models/get_api_workspaces_overview200_response_items_inner_usage.rb +271 -0
  25. data/lib/seatschart/models/get_api_workspaces_overview200_response_seats.rb +431 -0
  26. data/lib/seatschart/models/get_api_workspaces_overview200_response_seats_overage.rb +233 -0
  27. data/lib/seatschart/models/get_api_workspaces_overview200_response_seats_projected.rb +237 -0
  28. data/lib/seatschart/models/get_api_workspaces_overview200_response_totals.rb +318 -0
  29. data/lib/seatschart/models/get_api_workspaces_overview200_response_totals_revenue.rb +238 -0
  30. data/lib/seatschart/models/get_api_workspaces_overview200_response_totals_seats.rb +253 -0
  31. data/lib/seatschart/models/post_api_billing_actions_change_plan_request.rb +256 -0
  32. data/lib/seatschart/models/post_api_events_by_event_id_actions_update_extra_data_request_objects_inner.rb +0 -2
  33. data/lib/seatschart/models/post_api_sandboxes201_response.rb +0 -4
  34. data/lib/seatschart/models/post_api_sandboxes_by_sandbox_id_actions_reset200_response.rb +0 -2
  35. data/lib/seatschart/models/post_api_workspaces200_response.rb +0 -4
  36. data/lib/seatschart/models/post_api_workspaces_by_workspace_id_invitations201_response.rb +238 -0
  37. data/lib/seatschart/models/post_api_workspaces_by_workspace_id_invitations201_response_invitation.rb +286 -0
  38. data/lib/seatschart/version.rb +1 -1
  39. data/lib/seatschart/workspaces.rb +172 -0
  40. data/lib/seatschart.rb +23 -3
  41. metadata +25 -5
  42. data/lib/seatschart/models/get_api_workspaces_created_by_api_parameter.rb +0 -103
  43. data/lib/seatschart/models/get_api_workspaces_overview_created_by_api_parameter.rb +0 -103
@@ -0,0 +1,431 @@
1
+ =begin
2
+ #SeatsChart API
3
+
4
+ #Seat inventory and locking API for B2B2C integrations. Authenticate using `x-api-key` (partners) or `Authorization: Bearer` with an HS256 JWT.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.11.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SeatsChart
17
+ # Seat billing of the caller's billing account for the month; `null` without an account.
18
+ class GetApiWorkspacesOverview200ResponseSeats
19
+ attr_accessor :month
20
+
21
+ attr_accessor :plan_id
22
+
23
+ attr_accessor :mode
24
+
25
+ attr_accessor :used_seats
26
+
27
+ attr_accessor :included_seats
28
+
29
+ # US cents per seat beyond the included ones (may be fractional).
30
+ attr_accessor :overage_price_cents_per_seat
31
+
32
+ attr_accessor :overage
33
+
34
+ attr_accessor :allowance_exceeded
35
+
36
+ attr_accessor :allowance_near
37
+
38
+ attr_accessor :projected
39
+
40
+ attr_accessor :billing_owner_user_id
41
+
42
+ attr_accessor :rolled_up
43
+
44
+ attr_accessor :workspace_count
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'month' => :'month',
72
+ :'plan_id' => :'planId',
73
+ :'mode' => :'mode',
74
+ :'used_seats' => :'usedSeats',
75
+ :'included_seats' => :'includedSeats',
76
+ :'overage_price_cents_per_seat' => :'overagePriceCentsPerSeat',
77
+ :'overage' => :'overage',
78
+ :'allowance_exceeded' => :'allowanceExceeded',
79
+ :'allowance_near' => :'allowanceNear',
80
+ :'projected' => :'projected',
81
+ :'billing_owner_user_id' => :'billingOwnerUserId',
82
+ :'rolled_up' => :'rolledUp',
83
+ :'workspace_count' => :'workspaceCount'
84
+ }
85
+ end
86
+
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ attribute_map.values
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'month' => :'String',
96
+ :'plan_id' => :'String',
97
+ :'mode' => :'String',
98
+ :'used_seats' => :'Integer',
99
+ :'included_seats' => :'Integer',
100
+ :'overage_price_cents_per_seat' => :'Float',
101
+ :'overage' => :'GetApiWorkspacesOverview200ResponseSeatsOverage',
102
+ :'allowance_exceeded' => :'Boolean',
103
+ :'allowance_near' => :'Boolean',
104
+ :'projected' => :'GetApiWorkspacesOverview200ResponseSeatsProjected',
105
+ :'billing_owner_user_id' => :'String',
106
+ :'rolled_up' => :'Boolean',
107
+ :'workspace_count' => :'Integer'
108
+ }
109
+ end
110
+
111
+ # List of attributes with nullable: true
112
+ def self.openapi_nullable
113
+ Set.new([
114
+ :'included_seats',
115
+ :'overage_price_cents_per_seat',
116
+ :'projected',
117
+ :'billing_owner_user_id',
118
+ ])
119
+ end
120
+
121
+ # Initializes the object
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ def initialize(attributes = {})
124
+ if (!attributes.is_a?(Hash))
125
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SeatsChart::GetApiWorkspacesOverview200ResponseSeats` initialize method"
126
+ end
127
+
128
+ # check to see if the attribute exists and convert string to symbol for hash key
129
+ attributes = attributes.each_with_object({}) { |(k, v), h|
130
+ if (!self.class.attribute_map.key?(k.to_sym))
131
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SeatsChart::GetApiWorkspacesOverview200ResponseSeats`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
132
+ end
133
+ h[k.to_sym] = v
134
+ }
135
+
136
+ if attributes.key?(:'month')
137
+ self.month = attributes[:'month']
138
+ else
139
+ self.month = nil
140
+ end
141
+
142
+ if attributes.key?(:'plan_id')
143
+ self.plan_id = attributes[:'plan_id']
144
+ else
145
+ self.plan_id = nil
146
+ end
147
+
148
+ if attributes.key?(:'mode')
149
+ self.mode = attributes[:'mode']
150
+ else
151
+ self.mode = nil
152
+ end
153
+
154
+ if attributes.key?(:'used_seats')
155
+ self.used_seats = attributes[:'used_seats']
156
+ else
157
+ self.used_seats = nil
158
+ end
159
+
160
+ if attributes.key?(:'included_seats')
161
+ self.included_seats = attributes[:'included_seats']
162
+ else
163
+ self.included_seats = nil
164
+ end
165
+
166
+ if attributes.key?(:'overage_price_cents_per_seat')
167
+ self.overage_price_cents_per_seat = attributes[:'overage_price_cents_per_seat']
168
+ else
169
+ self.overage_price_cents_per_seat = nil
170
+ end
171
+
172
+ if attributes.key?(:'overage')
173
+ self.overage = attributes[:'overage']
174
+ else
175
+ self.overage = nil
176
+ end
177
+
178
+ if attributes.key?(:'allowance_exceeded')
179
+ self.allowance_exceeded = attributes[:'allowance_exceeded']
180
+ else
181
+ self.allowance_exceeded = nil
182
+ end
183
+
184
+ if attributes.key?(:'allowance_near')
185
+ self.allowance_near = attributes[:'allowance_near']
186
+ else
187
+ self.allowance_near = nil
188
+ end
189
+
190
+ if attributes.key?(:'projected')
191
+ self.projected = attributes[:'projected']
192
+ end
193
+
194
+ if attributes.key?(:'billing_owner_user_id')
195
+ self.billing_owner_user_id = attributes[:'billing_owner_user_id']
196
+ else
197
+ self.billing_owner_user_id = nil
198
+ end
199
+
200
+ if attributes.key?(:'rolled_up')
201
+ self.rolled_up = attributes[:'rolled_up']
202
+ else
203
+ self.rolled_up = nil
204
+ end
205
+
206
+ if attributes.key?(:'workspace_count')
207
+ self.workspace_count = attributes[:'workspace_count']
208
+ else
209
+ self.workspace_count = nil
210
+ end
211
+ end
212
+
213
+ # Show invalid properties with the reasons. Usually used together with valid?
214
+ # @return Array for valid properties with the reasons
215
+ def list_invalid_properties
216
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
217
+ invalid_properties = Array.new
218
+ if @month.nil?
219
+ invalid_properties.push('invalid value for "month", month cannot be nil.')
220
+ end
221
+
222
+ if @plan_id.nil?
223
+ invalid_properties.push('invalid value for "plan_id", plan_id cannot be nil.')
224
+ end
225
+
226
+ if @mode.nil?
227
+ invalid_properties.push('invalid value for "mode", mode cannot be nil.')
228
+ end
229
+
230
+ if @used_seats.nil?
231
+ invalid_properties.push('invalid value for "used_seats", used_seats cannot be nil.')
232
+ end
233
+
234
+ if @overage.nil?
235
+ invalid_properties.push('invalid value for "overage", overage cannot be nil.')
236
+ end
237
+
238
+ if @allowance_exceeded.nil?
239
+ invalid_properties.push('invalid value for "allowance_exceeded", allowance_exceeded cannot be nil.')
240
+ end
241
+
242
+ if @allowance_near.nil?
243
+ invalid_properties.push('invalid value for "allowance_near", allowance_near cannot be nil.')
244
+ end
245
+
246
+ if @rolled_up.nil?
247
+ invalid_properties.push('invalid value for "rolled_up", rolled_up cannot be nil.')
248
+ end
249
+
250
+ if @workspace_count.nil?
251
+ invalid_properties.push('invalid value for "workspace_count", workspace_count cannot be nil.')
252
+ end
253
+
254
+ invalid_properties
255
+ end
256
+
257
+ # Check to see if the all the properties in the model are valid
258
+ # @return true if the model is valid
259
+ def valid?
260
+ warn '[DEPRECATED] the `valid?` method is obsolete'
261
+ return false if @month.nil?
262
+ return false if @plan_id.nil?
263
+ return false if @mode.nil?
264
+ mode_validator = EnumAttributeValidator.new('String', ["allowance", "overage", "on_demand"])
265
+ return false unless mode_validator.valid?(@mode)
266
+ return false if @used_seats.nil?
267
+ return false if @overage.nil?
268
+ return false if @allowance_exceeded.nil?
269
+ return false if @allowance_near.nil?
270
+ return false if @rolled_up.nil?
271
+ return false if @workspace_count.nil?
272
+ true
273
+ end
274
+
275
+ # Custom attribute writer method checking allowed values (enum).
276
+ # @param [Object] mode Object to be assigned
277
+ def mode=(mode)
278
+ validator = EnumAttributeValidator.new('String', ["allowance", "overage", "on_demand"])
279
+ unless validator.valid?(mode)
280
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
281
+ end
282
+ @mode = mode
283
+ end
284
+
285
+ # Checks equality by comparing each attribute.
286
+ # @param [Object] Object to be compared
287
+ def ==(o)
288
+ return true if self.equal?(o)
289
+ self.class == o.class &&
290
+ month == o.month &&
291
+ plan_id == o.plan_id &&
292
+ mode == o.mode &&
293
+ used_seats == o.used_seats &&
294
+ included_seats == o.included_seats &&
295
+ overage_price_cents_per_seat == o.overage_price_cents_per_seat &&
296
+ overage == o.overage &&
297
+ allowance_exceeded == o.allowance_exceeded &&
298
+ allowance_near == o.allowance_near &&
299
+ projected == o.projected &&
300
+ billing_owner_user_id == o.billing_owner_user_id &&
301
+ rolled_up == o.rolled_up &&
302
+ workspace_count == o.workspace_count
303
+ end
304
+
305
+ # @see the `==` method
306
+ # @param [Object] Object to be compared
307
+ def eql?(o)
308
+ self == o
309
+ end
310
+
311
+ # Calculates hash code according to all attributes.
312
+ # @return [Integer] Hash code
313
+ def hash
314
+ [month, plan_id, mode, used_seats, included_seats, overage_price_cents_per_seat, overage, allowance_exceeded, allowance_near, projected, billing_owner_user_id, rolled_up, workspace_count].hash
315
+ end
316
+
317
+ # Builds the object from hash
318
+ # @param [Hash] attributes Model attributes in the form of hash
319
+ # @return [Object] Returns the model itself
320
+ def self.build_from_hash(attributes)
321
+ return nil unless attributes.is_a?(Hash)
322
+ attributes = attributes.transform_keys(&:to_sym)
323
+ transformed_hash = {}
324
+ openapi_types.each_pair do |key, type|
325
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
326
+ transformed_hash["#{key}"] = nil
327
+ elsif type =~ /\AArray<(.*)>/i
328
+ # check to ensure the input is an array given that the attribute
329
+ # is documented as an array but the input is not
330
+ if attributes[attribute_map[key]].is_a?(Array)
331
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
332
+ end
333
+ elsif !attributes[attribute_map[key]].nil?
334
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
335
+ end
336
+ end
337
+ new(transformed_hash)
338
+ end
339
+
340
+ # Deserializes the data based on type
341
+ # @param string type Data type
342
+ # @param string value Value to be deserialized
343
+ # @return [Object] Deserialized data
344
+ def self._deserialize(type, value)
345
+ case type.to_sym
346
+ when :Time
347
+ Time.parse(value)
348
+ when :Date
349
+ Date.parse(value)
350
+ when :String
351
+ value.to_s
352
+ when :Integer
353
+ value.to_i
354
+ when :Float
355
+ value.to_f
356
+ when :Boolean
357
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
358
+ true
359
+ else
360
+ false
361
+ end
362
+ when :Object
363
+ # generic object (usually a Hash), return directly
364
+ value
365
+ when /\AArray<(?<inner_type>.+)>\z/
366
+ inner_type = Regexp.last_match[:inner_type]
367
+ value.map { |v| _deserialize(inner_type, v) }
368
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
369
+ k_type = Regexp.last_match[:k_type]
370
+ v_type = Regexp.last_match[:v_type]
371
+ {}.tap do |hash|
372
+ value.each do |k, v|
373
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
374
+ end
375
+ end
376
+ else # model
377
+ # models (e.g. Pet) or oneOf
378
+ klass = SeatsChart.const_get(type)
379
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
380
+ end
381
+ end
382
+
383
+ # Returns the string representation of the object
384
+ # @return [String] String presentation of the object
385
+ def to_s
386
+ to_hash.to_s
387
+ end
388
+
389
+ # to_body is an alias to to_hash (backward compatibility)
390
+ # @return [Hash] Returns the object in the form of hash
391
+ def to_body
392
+ to_hash
393
+ end
394
+
395
+ # Returns the object in the form of hash
396
+ # @return [Hash] Returns the object in the form of hash
397
+ def to_hash
398
+ hash = {}
399
+ self.class.attribute_map.each_pair do |attr, param|
400
+ value = self.send(attr)
401
+ if value.nil?
402
+ is_nullable = self.class.openapi_nullable.include?(attr)
403
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
404
+ end
405
+
406
+ hash[param] = _to_hash(value)
407
+ end
408
+ hash
409
+ end
410
+
411
+ # Outputs non-array value in the form of hash
412
+ # For object, use to_hash. Otherwise, just return the value
413
+ # @param [Object] value Any valid value
414
+ # @return [Hash] Returns the value in the form of hash
415
+ def _to_hash(value)
416
+ if value.is_a?(Array)
417
+ value.compact.map { |v| _to_hash(v) }
418
+ elsif value.is_a?(Hash)
419
+ {}.tap do |hash|
420
+ value.each { |k, v| hash[k] = _to_hash(v) }
421
+ end
422
+ elsif value.respond_to? :to_hash
423
+ value.to_hash
424
+ else
425
+ value
426
+ end
427
+ end
428
+
429
+ end
430
+
431
+ end
@@ -0,0 +1,233 @@
1
+ =begin
2
+ #SeatsChart API
3
+
4
+ #Seat inventory and locking API for B2B2C integrations. Authenticate using `x-api-key` (partners) or `Authorization: Bearer` with an HS256 JWT.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.11.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SeatsChart
17
+ class GetApiWorkspacesOverview200ResponseSeatsOverage
18
+ attr_accessor :seats
19
+
20
+ attr_accessor :cost_cents
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'seats' => :'seats',
26
+ :'cost_cents' => :'costCents'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'seats' => :'Integer',
39
+ :'cost_cents' => :'Integer'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ :'cost_cents'
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SeatsChart::GetApiWorkspacesOverview200ResponseSeatsOverage` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SeatsChart::GetApiWorkspacesOverview200ResponseSeatsOverage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'seats')
66
+ self.seats = attributes[:'seats']
67
+ else
68
+ self.seats = nil
69
+ end
70
+
71
+ if attributes.key?(:'cost_cents')
72
+ self.cost_cents = attributes[:'cost_cents']
73
+ else
74
+ self.cost_cents = nil
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ if @seats.nil?
84
+ invalid_properties.push('invalid value for "seats", seats cannot be nil.')
85
+ end
86
+
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
+ return false if @seats.nil?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ seats == o.seats &&
104
+ cost_cents == o.cost_cents
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [seats, cost_cents].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ attributes = attributes.transform_keys(&:to_sym)
125
+ transformed_hash = {}
126
+ openapi_types.each_pair do |key, type|
127
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = nil
129
+ elsif type =~ /\AArray<(.*)>/i
130
+ # check to ensure the input is an array given that the attribute
131
+ # is documented as an array but the input is not
132
+ if attributes[attribute_map[key]].is_a?(Array)
133
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
134
+ end
135
+ elsif !attributes[attribute_map[key]].nil?
136
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
137
+ end
138
+ end
139
+ new(transformed_hash)
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def self._deserialize(type, value)
147
+ case type.to_sym
148
+ when :Time
149
+ Time.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :Boolean
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ # models (e.g. Pet) or oneOf
180
+ klass = SeatsChart.const_get(type)
181
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ end
232
+
233
+ end