timelogic-api 1.0.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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +188 -0
  3. data/docs/ApiError.md +22 -0
  4. data/docs/BulkError.md +24 -0
  5. data/docs/CalendarResponse.md +48 -0
  6. data/docs/DiffEndpointRef.md +18 -0
  7. data/docs/DiffResponse.md +36 -0
  8. data/docs/DstResponse.md +42 -0
  9. data/docs/ElapsedResponse.md +32 -0
  10. data/docs/ErrorResponse.md +22 -0
  11. data/docs/GetCurrentTime200Response.md +49 -0
  12. data/docs/GetTimezone200Response.md +49 -0
  13. data/docs/JwkKey.md +28 -0
  14. data/docs/JwksResponse.md +18 -0
  15. data/docs/TimeApi.md +1093 -0
  16. data/docs/TimePayload.md +38 -0
  17. data/docs/TimePayloadBulkItem.md +49 -0
  18. data/docs/TimePayloadBulkResponse.md +15 -0
  19. data/docs/TimezoneMatch.md +42 -0
  20. data/docs/TimezoneOffsetResponse.md +44 -0
  21. data/docs/TimezoneResolvedResponse.md +42 -0
  22. data/docs/UtilityApi.md +74 -0
  23. data/lib/timelogic-api/api/time_api.rb +1344 -0
  24. data/lib/timelogic-api/api/utility_api.rb +82 -0
  25. data/lib/timelogic-api/api_client.rb +394 -0
  26. data/lib/timelogic-api/api_error.rb +58 -0
  27. data/lib/timelogic-api/configuration.rb +353 -0
  28. data/lib/timelogic-api/models/api_error.rb +282 -0
  29. data/lib/timelogic-api/models/bulk_error.rb +271 -0
  30. data/lib/timelogic-api/models/calendar_response.rb +474 -0
  31. data/lib/timelogic-api/models/diff_endpoint_ref.rb +222 -0
  32. data/lib/timelogic-api/models/diff_response.rb +386 -0
  33. data/lib/timelogic-api/models/dst_response.rb +427 -0
  34. data/lib/timelogic-api/models/elapsed_response.rb +354 -0
  35. data/lib/timelogic-api/models/error_response.rb +247 -0
  36. data/lib/timelogic-api/models/get_current_time200_response.rb +105 -0
  37. data/lib/timelogic-api/models/get_timezone200_response.rb +105 -0
  38. data/lib/timelogic-api/models/jwk_key.rb +371 -0
  39. data/lib/timelogic-api/models/jwks_response.rb +223 -0
  40. data/lib/timelogic-api/models/time_payload.rb +395 -0
  41. data/lib/timelogic-api/models/time_payload_bulk_item.rb +106 -0
  42. data/lib/timelogic-api/models/time_payload_bulk_response.rb +210 -0
  43. data/lib/timelogic-api/models/timezone_match.rb +437 -0
  44. data/lib/timelogic-api/models/timezone_offset_response.rb +452 -0
  45. data/lib/timelogic-api/models/timezone_resolved_response.rb +434 -0
  46. data/lib/timelogic-api/transport_configuration.rb +34 -0
  47. data/lib/timelogic-api/version.rb +7 -0
  48. data/lib/timelogic-api.rb +63 -0
  49. metadata +134 -0
@@ -0,0 +1,474 @@
1
+ =begin
2
+ #TimeLogic API | A World Time API
3
+
4
+ # Official public API contract for TimeLogic API.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TimeLogic::Api
17
+ class CalendarResponse
18
+ attr_accessor :unix
19
+
20
+ attr_accessor :unix_ms
21
+
22
+ attr_accessor :utc
23
+
24
+ attr_accessor :iso_local
25
+
26
+ attr_accessor :rfc2822
27
+
28
+ attr_accessor :human
29
+
30
+ attr_accessor :day_number
31
+
32
+ attr_accessor :day_short
33
+
34
+ attr_accessor :day_full
35
+
36
+ attr_accessor :timezone
37
+
38
+ attr_accessor :formatted
39
+
40
+ attr_accessor :year
41
+
42
+ attr_accessor :month
43
+
44
+ attr_accessor :month_name
45
+
46
+ attr_accessor :day
47
+
48
+ attr_accessor :week_number
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'unix' => :'unix',
54
+ :'unix_ms' => :'unix_ms',
55
+ :'utc' => :'utc',
56
+ :'iso_local' => :'iso_local',
57
+ :'rfc2822' => :'rfc2822',
58
+ :'human' => :'human',
59
+ :'day_number' => :'day_number',
60
+ :'day_short' => :'day_short',
61
+ :'day_full' => :'day_full',
62
+ :'timezone' => :'timezone',
63
+ :'formatted' => :'formatted',
64
+ :'year' => :'year',
65
+ :'month' => :'month',
66
+ :'month_name' => :'month_name',
67
+ :'day' => :'day',
68
+ :'week_number' => :'week_number'
69
+ }
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'unix' => :'Integer',
81
+ :'unix_ms' => :'Integer',
82
+ :'utc' => :'Time',
83
+ :'iso_local' => :'String',
84
+ :'rfc2822' => :'String',
85
+ :'human' => :'String',
86
+ :'day_number' => :'Integer',
87
+ :'day_short' => :'String',
88
+ :'day_full' => :'String',
89
+ :'timezone' => :'String',
90
+ :'formatted' => :'String',
91
+ :'year' => :'Integer',
92
+ :'month' => :'Integer',
93
+ :'month_name' => :'String',
94
+ :'day' => :'Integer',
95
+ :'week_number' => :'Integer'
96
+ }
97
+ end
98
+
99
+ # List of attributes with nullable: true
100
+ def self.openapi_nullable
101
+ Set.new([
102
+ :'iso_local',
103
+ :'timezone',
104
+ ])
105
+ end
106
+
107
+ # List of class defined in allOf (OpenAPI v3)
108
+ def self.openapi_all_of
109
+ [
110
+ :'TimePayload'
111
+ ]
112
+ end
113
+
114
+ # Initializes the object
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ def initialize(attributes = {})
117
+ if (!attributes.is_a?(Hash))
118
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TimeLogic::Api::CalendarResponse` initialize method"
119
+ end
120
+
121
+ # check to see if the attribute exists and convert string to symbol for hash key
122
+ attributes = attributes.each_with_object({}) { |(k, v), h|
123
+ if (!self.class.attribute_map.key?(k.to_sym))
124
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TimeLogic::Api::CalendarResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
125
+ end
126
+ h[k.to_sym] = v
127
+ }
128
+
129
+ if attributes.key?(:'unix')
130
+ self.unix = attributes[:'unix']
131
+ else
132
+ self.unix = nil
133
+ end
134
+
135
+ if attributes.key?(:'unix_ms')
136
+ self.unix_ms = attributes[:'unix_ms']
137
+ else
138
+ self.unix_ms = nil
139
+ end
140
+
141
+ if attributes.key?(:'utc')
142
+ self.utc = attributes[:'utc']
143
+ else
144
+ self.utc = nil
145
+ end
146
+
147
+ if attributes.key?(:'iso_local')
148
+ self.iso_local = attributes[:'iso_local']
149
+ else
150
+ self.iso_local = nil
151
+ end
152
+
153
+ if attributes.key?(:'rfc2822')
154
+ self.rfc2822 = attributes[:'rfc2822']
155
+ else
156
+ self.rfc2822 = nil
157
+ end
158
+
159
+ if attributes.key?(:'human')
160
+ self.human = attributes[:'human']
161
+ else
162
+ self.human = nil
163
+ end
164
+
165
+ if attributes.key?(:'day_number')
166
+ self.day_number = attributes[:'day_number']
167
+ else
168
+ self.day_number = nil
169
+ end
170
+
171
+ if attributes.key?(:'day_short')
172
+ self.day_short = attributes[:'day_short']
173
+ else
174
+ self.day_short = nil
175
+ end
176
+
177
+ if attributes.key?(:'day_full')
178
+ self.day_full = attributes[:'day_full']
179
+ else
180
+ self.day_full = nil
181
+ end
182
+
183
+ if attributes.key?(:'timezone')
184
+ self.timezone = attributes[:'timezone']
185
+ else
186
+ self.timezone = nil
187
+ end
188
+
189
+ if attributes.key?(:'formatted')
190
+ self.formatted = attributes[:'formatted']
191
+ end
192
+
193
+ if attributes.key?(:'year')
194
+ self.year = attributes[:'year']
195
+ else
196
+ self.year = nil
197
+ end
198
+
199
+ if attributes.key?(:'month')
200
+ self.month = attributes[:'month']
201
+ else
202
+ self.month = nil
203
+ end
204
+
205
+ if attributes.key?(:'month_name')
206
+ self.month_name = attributes[:'month_name']
207
+ else
208
+ self.month_name = nil
209
+ end
210
+
211
+ if attributes.key?(:'day')
212
+ self.day = attributes[:'day']
213
+ else
214
+ self.day = nil
215
+ end
216
+
217
+ if attributes.key?(:'week_number')
218
+ self.week_number = attributes[:'week_number']
219
+ end
220
+ end
221
+
222
+ # Show invalid properties with the reasons. Usually used together with valid?
223
+ # @return Array for valid properties with the reasons
224
+ def list_invalid_properties
225
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
226
+ invalid_properties = Array.new
227
+ if @unix.nil?
228
+ invalid_properties.push('invalid value for "unix", unix cannot be nil.')
229
+ end
230
+
231
+ if @unix_ms.nil?
232
+ invalid_properties.push('invalid value for "unix_ms", unix_ms cannot be nil.')
233
+ end
234
+
235
+ if @utc.nil?
236
+ invalid_properties.push('invalid value for "utc", utc cannot be nil.')
237
+ end
238
+
239
+ if @rfc2822.nil?
240
+ invalid_properties.push('invalid value for "rfc2822", rfc2822 cannot be nil.')
241
+ end
242
+
243
+ if @human.nil?
244
+ invalid_properties.push('invalid value for "human", human cannot be nil.')
245
+ end
246
+
247
+ if @day_number.nil?
248
+ invalid_properties.push('invalid value for "day_number", day_number cannot be nil.')
249
+ end
250
+
251
+ if @day_number > 7
252
+ invalid_properties.push('invalid value for "day_number", must be smaller than or equal to 7.')
253
+ end
254
+
255
+ if @day_number < 1
256
+ invalid_properties.push('invalid value for "day_number", must be greater than or equal to 1.')
257
+ end
258
+
259
+ if @day_short.nil?
260
+ invalid_properties.push('invalid value for "day_short", day_short cannot be nil.')
261
+ end
262
+
263
+ if @day_full.nil?
264
+ invalid_properties.push('invalid value for "day_full", day_full cannot be nil.')
265
+ end
266
+
267
+ if @year.nil?
268
+ invalid_properties.push('invalid value for "year", year cannot be nil.')
269
+ end
270
+
271
+ if @month.nil?
272
+ invalid_properties.push('invalid value for "month", month cannot be nil.')
273
+ end
274
+
275
+ if @month_name.nil?
276
+ invalid_properties.push('invalid value for "month_name", month_name cannot be nil.')
277
+ end
278
+
279
+ if @day.nil?
280
+ invalid_properties.push('invalid value for "day", day cannot be nil.')
281
+ end
282
+
283
+ invalid_properties
284
+ end
285
+
286
+ # Check to see if the all the properties in the model are valid
287
+ # @return true if the model is valid
288
+ def valid?
289
+ warn '[DEPRECATED] the `valid?` method is obsolete'
290
+ return false if @unix.nil?
291
+ return false if @unix_ms.nil?
292
+ return false if @utc.nil?
293
+ return false if @rfc2822.nil?
294
+ return false if @human.nil?
295
+ return false if @day_number.nil?
296
+ return false if @day_number > 7
297
+ return false if @day_number < 1
298
+ return false if @day_short.nil?
299
+ return false if @day_full.nil?
300
+ return false if @year.nil?
301
+ return false if @month.nil?
302
+ return false if @month_name.nil?
303
+ return false if @day.nil?
304
+ true
305
+ end
306
+
307
+ # Custom attribute writer method with validation
308
+ # @param [Object] day_number Value to be assigned
309
+ def day_number=(day_number)
310
+ if day_number.nil?
311
+ fail ArgumentError, 'day_number cannot be nil'
312
+ end
313
+
314
+ if day_number > 7
315
+ fail ArgumentError, 'invalid value for "day_number", must be smaller than or equal to 7.'
316
+ end
317
+
318
+ if day_number < 1
319
+ fail ArgumentError, 'invalid value for "day_number", must be greater than or equal to 1.'
320
+ end
321
+
322
+ @day_number = day_number
323
+ end
324
+
325
+ # Checks equality by comparing each attribute.
326
+ # @param [Object] Object to be compared
327
+ def ==(o)
328
+ return true if self.equal?(o)
329
+ self.class == o.class &&
330
+ unix == o.unix &&
331
+ unix_ms == o.unix_ms &&
332
+ utc == o.utc &&
333
+ iso_local == o.iso_local &&
334
+ rfc2822 == o.rfc2822 &&
335
+ human == o.human &&
336
+ day_number == o.day_number &&
337
+ day_short == o.day_short &&
338
+ day_full == o.day_full &&
339
+ timezone == o.timezone &&
340
+ formatted == o.formatted &&
341
+ year == o.year &&
342
+ month == o.month &&
343
+ month_name == o.month_name &&
344
+ day == o.day &&
345
+ week_number == o.week_number
346
+ end
347
+
348
+ # @see the `==` method
349
+ # @param [Object] Object to be compared
350
+ def eql?(o)
351
+ self == o
352
+ end
353
+
354
+ # Calculates hash code according to all attributes.
355
+ # @return [Integer] Hash code
356
+ def hash
357
+ [unix, unix_ms, utc, iso_local, rfc2822, human, day_number, day_short, day_full, timezone, formatted, year, month, month_name, day, week_number].hash
358
+ end
359
+
360
+ # Builds the object from hash
361
+ # @param [Hash] attributes Model attributes in the form of hash
362
+ # @return [Object] Returns the model itself
363
+ def self.build_from_hash(attributes)
364
+ return nil unless attributes.is_a?(Hash)
365
+ attributes = attributes.transform_keys(&:to_sym)
366
+ transformed_hash = {}
367
+ openapi_types.each_pair do |key, type|
368
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
369
+ transformed_hash["#{key}"] = nil
370
+ elsif type =~ /\AArray<(.*)>/i
371
+ # check to ensure the input is an array given that the attribute
372
+ # is documented as an array but the input is not
373
+ if attributes[attribute_map[key]].is_a?(Array)
374
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
375
+ end
376
+ elsif !attributes[attribute_map[key]].nil?
377
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
378
+ end
379
+ end
380
+ new(transformed_hash)
381
+ end
382
+
383
+ # Deserializes the data based on type
384
+ # @param string type Data type
385
+ # @param string value Value to be deserialized
386
+ # @return [Object] Deserialized data
387
+ def self._deserialize(type, value)
388
+ case type.to_sym
389
+ when :Time
390
+ Time.parse(value)
391
+ when :Date
392
+ Date.parse(value)
393
+ when :String
394
+ value.to_s
395
+ when :Integer
396
+ value.to_i
397
+ when :Float
398
+ value.to_f
399
+ when :Boolean
400
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
401
+ true
402
+ else
403
+ false
404
+ end
405
+ when :Object
406
+ # generic object (usually a Hash), return directly
407
+ value
408
+ when /\AArray<(?<inner_type>.+)>\z/
409
+ inner_type = Regexp.last_match[:inner_type]
410
+ value.map { |v| _deserialize(inner_type, v) }
411
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
412
+ k_type = Regexp.last_match[:k_type]
413
+ v_type = Regexp.last_match[:v_type]
414
+ {}.tap do |hash|
415
+ value.each do |k, v|
416
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
417
+ end
418
+ end
419
+ else # model
420
+ # models (e.g. Pet) or oneOf
421
+ klass = TimeLogic::Api.const_get(type)
422
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
423
+ end
424
+ end
425
+
426
+ # Returns the string representation of the object
427
+ # @return [String] String presentation of the object
428
+ def to_s
429
+ to_hash.to_s
430
+ end
431
+
432
+ # to_body is an alias to to_hash (backward compatibility)
433
+ # @return [Hash] Returns the object in the form of hash
434
+ def to_body
435
+ to_hash
436
+ end
437
+
438
+ # Returns the object in the form of hash
439
+ # @return [Hash] Returns the object in the form of hash
440
+ def to_hash
441
+ hash = {}
442
+ self.class.attribute_map.each_pair do |attr, param|
443
+ value = self.send(attr)
444
+ if value.nil?
445
+ is_nullable = self.class.openapi_nullable.include?(attr)
446
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
447
+ end
448
+
449
+ hash[param] = _to_hash(value)
450
+ end
451
+ hash
452
+ end
453
+
454
+ # Outputs non-array value in the form of hash
455
+ # For object, use to_hash. Otherwise, just return the value
456
+ # @param [Object] value Any valid value
457
+ # @return [Hash] Returns the value in the form of hash
458
+ def _to_hash(value)
459
+ if value.is_a?(Array)
460
+ value.compact.map { |v| _to_hash(v) }
461
+ elsif value.is_a?(Hash)
462
+ {}.tap do |hash|
463
+ value.each { |k, v| hash[k] = _to_hash(v) }
464
+ end
465
+ elsif value.respond_to? :to_hash
466
+ value.to_hash
467
+ else
468
+ value
469
+ end
470
+ end
471
+
472
+ end
473
+
474
+ end
@@ -0,0 +1,222 @@
1
+ =begin
2
+ #TimeLogic API | A World Time API
3
+
4
+ # Official public API contract for TimeLogic API.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TimeLogic::Api
17
+ # Resolved endpoint reference for diff calculations. This object intentionally includes only the resolved epoch-millisecond instant.
18
+ class DiffEndpointRef
19
+ attr_accessor :unix_ms
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'unix_ms' => :'unix_ms'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'unix_ms' => :'Integer'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TimeLogic::Api::DiffEndpointRef` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TimeLogic::Api::DiffEndpointRef`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'unix_ms')
62
+ self.unix_ms = attributes[:'unix_ms']
63
+ else
64
+ self.unix_ms = nil
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
72
+ invalid_properties = Array.new
73
+ if @unix_ms.nil?
74
+ invalid_properties.push('invalid value for "unix_ms", unix_ms cannot be nil.')
75
+ end
76
+
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ return false if @unix_ms.nil?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ unix_ms == o.unix_ms
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [unix_ms].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ attributes = attributes.transform_keys(&:to_sym)
114
+ transformed_hash = {}
115
+ openapi_types.each_pair do |key, type|
116
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
117
+ transformed_hash["#{key}"] = nil
118
+ elsif type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[attribute_map[key]].is_a?(Array)
122
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
123
+ end
124
+ elsif !attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
126
+ end
127
+ end
128
+ new(transformed_hash)
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def self._deserialize(type, value)
136
+ case type.to_sym
137
+ when :Time
138
+ Time.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :Boolean
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ # models (e.g. Pet) or oneOf
169
+ klass = TimeLogic::Api.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ if value.nil?
193
+ is_nullable = self.class.openapi_nullable.include?(attr)
194
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
+ end
196
+
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end