crisphive 0.1.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 (108) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +219 -0
  4. data/Rakefile +10 -0
  5. data/crisphive.gemspec +40 -0
  6. data/git_push.sh +57 -0
  7. data/lib/crisphive/api/business_skill_api.rb +211 -0
  8. data/lib/crisphive/api/customer_api.rb +371 -0
  9. data/lib/crisphive/api/job_request_business_api.rb +449 -0
  10. data/lib/crisphive/api/job_types_api.rb +141 -0
  11. data/lib/crisphive/api/service_area_api.rb +148 -0
  12. data/lib/crisphive/api/technician_api.rb +163 -0
  13. data/lib/crisphive/api/vehicle_api.rb +157 -0
  14. data/lib/crisphive/api_client.rb +437 -0
  15. data/lib/crisphive/api_error.rb +58 -0
  16. data/lib/crisphive/configuration.rb +393 -0
  17. data/lib/crisphive/models/create_customer200_response.rb +250 -0
  18. data/lib/crisphive/models/create_job_request200_response.rb +250 -0
  19. data/lib/crisphive/models/customer.rb +235 -0
  20. data/lib/crisphive/models/customer_address.rb +295 -0
  21. data/lib/crisphive/models/customer_address_request.rb +475 -0
  22. data/lib/crisphive/models/customer_contact.rb +255 -0
  23. data/lib/crisphive/models/customer_create_request.rb +383 -0
  24. data/lib/crisphive/models/customer_create_response.rb +215 -0
  25. data/lib/crisphive/models/customer_list.rb +247 -0
  26. data/lib/crisphive/models/customer_list_item.rb +341 -0
  27. data/lib/crisphive/models/customer_profile.rb +321 -0
  28. data/lib/crisphive/models/customer_spending.rb +299 -0
  29. data/lib/crisphive/models/customer_tier_progress.rb +235 -0
  30. data/lib/crisphive/models/customer_update_request.rb +434 -0
  31. data/lib/crisphive/models/get_customer200_response.rb +250 -0
  32. data/lib/crisphive/models/get_job_request200_response.rb +250 -0
  33. data/lib/crisphive/models/get_job_request_timeline200_response.rb +250 -0
  34. data/lib/crisphive/models/get_job_type200_response.rb +250 -0
  35. data/lib/crisphive/models/get_service_area200_response.rb +250 -0
  36. data/lib/crisphive/models/get_technician200_response.rb +250 -0
  37. data/lib/crisphive/models/get_vehicle200_response.rb +250 -0
  38. data/lib/crisphive/models/job_date.rb +225 -0
  39. data/lib/crisphive/models/job_date_business_range.rb +263 -0
  40. data/lib/crisphive/models/job_date_period.rb +41 -0
  41. data/lib/crisphive/models/job_date_period_entry.rb +247 -0
  42. data/lib/crisphive/models/job_request.rb +537 -0
  43. data/lib/crisphive/models/job_request_action_audit_by.rb +259 -0
  44. data/lib/crisphive/models/job_request_action_audit_entry.rb +235 -0
  45. data/lib/crisphive/models/job_request_action_summary.rb +281 -0
  46. data/lib/crisphive/models/job_request_address_summary.rb +295 -0
  47. data/lib/crisphive/models/job_request_archive_summary.rb +245 -0
  48. data/lib/crisphive/models/job_request_arrival_window.rb +235 -0
  49. data/lib/crisphive/models/job_request_assigned_vehicle.rb +225 -0
  50. data/lib/crisphive/models/job_request_assignment_summary.rb +255 -0
  51. data/lib/crisphive/models/job_request_booking_windows.rb +247 -0
  52. data/lib/crisphive/models/job_request_business_time_range.rb +279 -0
  53. data/lib/crisphive/models/job_request_changes.rb +237 -0
  54. data/lib/crisphive/models/job_request_create_request.rb +339 -0
  55. data/lib/crisphive/models/job_request_create_response.rb +245 -0
  56. data/lib/crisphive/models/job_request_crew_member.rb +352 -0
  57. data/lib/crisphive/models/job_request_customer_summary.rb +245 -0
  58. data/lib/crisphive/models/job_request_day_windows.rb +227 -0
  59. data/lib/crisphive/models/job_request_job_date_business_range_request.rb +279 -0
  60. data/lib/crisphive/models/job_request_job_date_period_request.rb +268 -0
  61. data/lib/crisphive/models/job_request_job_date_request.rb +269 -0
  62. data/lib/crisphive/models/job_request_list.rb +227 -0
  63. data/lib/crisphive/models/job_request_period.rb +261 -0
  64. data/lib/crisphive/models/job_request_quote_summary.rb +245 -0
  65. data/lib/crisphive/models/job_request_rating_summary.rb +245 -0
  66. data/lib/crisphive/models/job_request_schedule.rb +289 -0
  67. data/lib/crisphive/models/job_request_session.rb +274 -0
  68. data/lib/crisphive/models/job_request_skill_summary.rb +255 -0
  69. data/lib/crisphive/models/job_request_status_summary.rb +225 -0
  70. data/lib/crisphive/models/job_request_technician_info.rb +265 -0
  71. data/lib/crisphive/models/job_request_timeline.rb +257 -0
  72. data/lib/crisphive/models/job_request_timeline_action.rb +311 -0
  73. data/lib/crisphive/models/job_request_timeline_event.rb +291 -0
  74. data/lib/crisphive/models/job_type.rb +309 -0
  75. data/lib/crisphive/models/list_customers200_response.rb +250 -0
  76. data/lib/crisphive/models/list_job_request_booking_windows200_response.rb +250 -0
  77. data/lib/crisphive/models/list_job_request_changes200_response.rb +250 -0
  78. data/lib/crisphive/models/list_job_requests200_response.rb +250 -0
  79. data/lib/crisphive/models/list_job_types200_response.rb +252 -0
  80. data/lib/crisphive/models/list_service_areas200_response.rb +250 -0
  81. data/lib/crisphive/models/list_skill_categories200_response.rb +250 -0
  82. data/lib/crisphive/models/list_skills200_response.rb +250 -0
  83. data/lib/crisphive/models/list_skills_by_category200_response.rb +250 -0
  84. data/lib/crisphive/models/list_technicians200_response.rb +250 -0
  85. data/lib/crisphive/models/list_vehicles200_response.rb +250 -0
  86. data/lib/crisphive/models/pagination.rb +250 -0
  87. data/lib/crisphive/models/response_envelope.rb +244 -0
  88. data/lib/crisphive/models/service_area.rb +315 -0
  89. data/lib/crisphive/models/service_area_list.rb +227 -0
  90. data/lib/crisphive/models/skill.rb +278 -0
  91. data/lib/crisphive/models/skill_by_category_list.rb +225 -0
  92. data/lib/crisphive/models/skill_category.rb +250 -0
  93. data/lib/crisphive/models/skill_category_list.rb +225 -0
  94. data/lib/crisphive/models/skill_list.rb +217 -0
  95. data/lib/crisphive/models/skill_summary.rb +255 -0
  96. data/lib/crisphive/models/technician.rb +499 -0
  97. data/lib/crisphive/models/technician_address.rb +275 -0
  98. data/lib/crisphive/models/technician_lead_ref.rb +225 -0
  99. data/lib/crisphive/models/technician_list.rb +247 -0
  100. data/lib/crisphive/models/technician_service_area_ref.rb +225 -0
  101. data/lib/crisphive/models/technician_status.rb +41 -0
  102. data/lib/crisphive/models/vehicle.rb +413 -0
  103. data/lib/crisphive/models/vehicle_list.rb +247 -0
  104. data/lib/crisphive/models/vehicle_owner.rb +225 -0
  105. data/lib/crisphive/version.rb +15 -0
  106. data/lib/crisphive.rb +134 -0
  107. data/spec/spec_helper.rb +111 -0
  108. metadata +220 -0
@@ -0,0 +1,499 @@
1
+ =begin
2
+ #CrispHive Developer API
3
+
4
+ #Public REST API for integrating CrispHive from your own backend. Authenticate every request with a secret API key as a Bearer token (`Authorization: Bearer chsk_live_…`). The key prefix selects the data environment: `chsk_live_…` → production (live), `chsk_test_…` → sandbox (isolated test). **Key scopes (restricted keys).** A key is either *full-access* (can call every endpoint below) or *restricted* to a set of permission codes chosen at creation — the same codes as the dashboard permission grid (e.g. `customers_view`, `job_create`, `team_manage`). A restricted key calling an endpoint outside its scope gets `403`. The full code list is the permission catalog (`GET /permission/modules` on the dashboard API). Create, scope, and revoke keys from the business dashboard. Every response is wrapped in the envelope `{ \"error_code\": 0, \"message\": \"Success\", \"data\": <payload> }`.
5
+
6
+ The version of the OpenAPI document: 1.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 Crisphive
17
+ class Technician
18
+ # Technician's start-location postal address.
19
+ attr_accessor :address
20
+
21
+ # Smart-assignment tier, or null if unset.
22
+ attr_accessor :assignment_tier
23
+
24
+ # UUIDs of this technician's buddies (the techs they prefer to work alongside).
25
+ attr_accessor :buddy_ids
26
+
27
+ # UUID of the permission group (role) this technician is assigned to.
28
+ attr_accessor :business_group_id
29
+
30
+ # UUID of the business this technician belongs to.
31
+ attr_accessor :business_id
32
+
33
+ # When the technician record was created (RFC3339).
34
+ attr_accessor :created_at
35
+
36
+ # Set (RFC3339) only when the technician has been soft-removed; omitted otherwise.
37
+ attr_accessor :deleted_at
38
+
39
+ # Email address; null if not set.
40
+ attr_accessor :email
41
+
42
+ # Technician's full name.
43
+ attr_accessor :full_name
44
+
45
+ # Technician membership UUID — the stable identifier used in every technician endpoint.
46
+ attr_accessor :id
47
+
48
+ # Free-form job title (e.g. \"Senior HVAC Technician\"). Empty if unset.
49
+ attr_accessor :job_title
50
+
51
+ # Date the technician joined (YYYY-MM-DD); null if unset.
52
+ attr_accessor :join_date
53
+
54
+ # When the technician last logged in (RFC3339); null if never.
55
+ attr_accessor :last_login_at
56
+
57
+ # Leads this technician is a buddy of (id + name).
58
+ attr_accessor :leads
59
+
60
+ # Phone number in the form it was supplied; null if not set.
61
+ attr_accessor :phone
62
+
63
+ # Resolved role/group name (e.g. \"Technician\", \"Owner\").
64
+ attr_accessor :role
65
+
66
+ # Service areas this technician is assigned to (id + name).
67
+ attr_accessor :service_areas
68
+
69
+ # Start-location latitude in decimal degrees; null if no coordinates are saved.
70
+ attr_accessor :start_location_lat
71
+
72
+ # Start-location longitude in decimal degrees; null if no coordinates are saved.
73
+ attr_accessor :start_location_long
74
+
75
+ # Where the technician's day starts: \"home\" (their address) or \"office\" (the business address). Null if unset.
76
+ attr_accessor :start_location_type
77
+
78
+ # Membership lifecycle status.
79
+ attr_accessor :status
80
+
81
+ # When the technician record was last modified (RFC3339).
82
+ attr_accessor :updated_at
83
+
84
+ # UUID of the underlying user account.
85
+ attr_accessor :user_id
86
+
87
+ # UUIDs of the vehicles this technician uses.
88
+ attr_accessor :vehicle_ids
89
+
90
+ class EnumAttributeValidator
91
+ attr_reader :datatype
92
+ attr_reader :allowable_values
93
+
94
+ def initialize(datatype, allowable_values)
95
+ @allowable_values = allowable_values.map do |value|
96
+ case datatype.to_s
97
+ when /Integer/i
98
+ value.to_i
99
+ when /Float/i
100
+ value.to_f
101
+ else
102
+ value
103
+ end
104
+ end
105
+ end
106
+
107
+ def valid?(value)
108
+ !value || allowable_values.include?(value)
109
+ end
110
+ end
111
+
112
+ # Attribute mapping from ruby-style variable name to JSON key.
113
+ def self.attribute_map
114
+ {
115
+ :'address' => :'address',
116
+ :'assignment_tier' => :'assignment_tier',
117
+ :'buddy_ids' => :'buddy_ids',
118
+ :'business_group_id' => :'business_group_id',
119
+ :'business_id' => :'business_id',
120
+ :'created_at' => :'created_at',
121
+ :'deleted_at' => :'deleted_at',
122
+ :'email' => :'email',
123
+ :'full_name' => :'full_name',
124
+ :'id' => :'id',
125
+ :'job_title' => :'job_title',
126
+ :'join_date' => :'join_date',
127
+ :'last_login_at' => :'last_login_at',
128
+ :'leads' => :'leads',
129
+ :'phone' => :'phone',
130
+ :'role' => :'role',
131
+ :'service_areas' => :'service_areas',
132
+ :'start_location_lat' => :'start_location_lat',
133
+ :'start_location_long' => :'start_location_long',
134
+ :'start_location_type' => :'start_location_type',
135
+ :'status' => :'status',
136
+ :'updated_at' => :'updated_at',
137
+ :'user_id' => :'user_id',
138
+ :'vehicle_ids' => :'vehicle_ids'
139
+ }
140
+ end
141
+
142
+ # Returns all the JSON keys this model knows about
143
+ def self.acceptable_attributes
144
+ attribute_map.values
145
+ end
146
+
147
+ # Attribute type mapping.
148
+ def self.openapi_types
149
+ {
150
+ :'address' => :'TechnicianAddress',
151
+ :'assignment_tier' => :'String',
152
+ :'buddy_ids' => :'Array<String>',
153
+ :'business_group_id' => :'String',
154
+ :'business_id' => :'String',
155
+ :'created_at' => :'Time',
156
+ :'deleted_at' => :'Time',
157
+ :'email' => :'String',
158
+ :'full_name' => :'String',
159
+ :'id' => :'String',
160
+ :'job_title' => :'String',
161
+ :'join_date' => :'Date',
162
+ :'last_login_at' => :'Time',
163
+ :'leads' => :'Array<TechnicianLeadRef>',
164
+ :'phone' => :'String',
165
+ :'role' => :'String',
166
+ :'service_areas' => :'Array<TechnicianServiceAreaRef>',
167
+ :'start_location_lat' => :'Float',
168
+ :'start_location_long' => :'Float',
169
+ :'start_location_type' => :'String',
170
+ :'status' => :'TechnicianStatus',
171
+ :'updated_at' => :'Time',
172
+ :'user_id' => :'String',
173
+ :'vehicle_ids' => :'Array<String>'
174
+ }
175
+ end
176
+
177
+ # List of attributes with nullable: true
178
+ def self.openapi_nullable
179
+ Set.new([
180
+ ])
181
+ end
182
+
183
+ # Initializes the object
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ def initialize(attributes = {})
186
+ if (!attributes.is_a?(Hash))
187
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::Technician` initialize method"
188
+ end
189
+
190
+ # check to see if the attribute exists and convert string to symbol for hash key
191
+ attributes = attributes.each_with_object({}) { |(k, v), h|
192
+ if (!self.class.attribute_map.key?(k.to_sym))
193
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::Technician`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
194
+ end
195
+ h[k.to_sym] = v
196
+ }
197
+
198
+ if attributes.key?(:'address')
199
+ self.address = attributes[:'address']
200
+ end
201
+
202
+ if attributes.key?(:'assignment_tier')
203
+ self.assignment_tier = attributes[:'assignment_tier']
204
+ end
205
+
206
+ if attributes.key?(:'buddy_ids')
207
+ if (value = attributes[:'buddy_ids']).is_a?(Array)
208
+ self.buddy_ids = value
209
+ end
210
+ end
211
+
212
+ if attributes.key?(:'business_group_id')
213
+ self.business_group_id = attributes[:'business_group_id']
214
+ end
215
+
216
+ if attributes.key?(:'business_id')
217
+ self.business_id = attributes[:'business_id']
218
+ end
219
+
220
+ if attributes.key?(:'created_at')
221
+ self.created_at = attributes[:'created_at']
222
+ end
223
+
224
+ if attributes.key?(:'deleted_at')
225
+ self.deleted_at = attributes[:'deleted_at']
226
+ end
227
+
228
+ if attributes.key?(:'email')
229
+ self.email = attributes[:'email']
230
+ end
231
+
232
+ if attributes.key?(:'full_name')
233
+ self.full_name = attributes[:'full_name']
234
+ end
235
+
236
+ if attributes.key?(:'id')
237
+ self.id = attributes[:'id']
238
+ end
239
+
240
+ if attributes.key?(:'job_title')
241
+ self.job_title = attributes[:'job_title']
242
+ end
243
+
244
+ if attributes.key?(:'join_date')
245
+ self.join_date = attributes[:'join_date']
246
+ end
247
+
248
+ if attributes.key?(:'last_login_at')
249
+ self.last_login_at = attributes[:'last_login_at']
250
+ end
251
+
252
+ if attributes.key?(:'leads')
253
+ if (value = attributes[:'leads']).is_a?(Array)
254
+ self.leads = value
255
+ end
256
+ end
257
+
258
+ if attributes.key?(:'phone')
259
+ self.phone = attributes[:'phone']
260
+ end
261
+
262
+ if attributes.key?(:'role')
263
+ self.role = attributes[:'role']
264
+ end
265
+
266
+ if attributes.key?(:'service_areas')
267
+ if (value = attributes[:'service_areas']).is_a?(Array)
268
+ self.service_areas = value
269
+ end
270
+ end
271
+
272
+ if attributes.key?(:'start_location_lat')
273
+ self.start_location_lat = attributes[:'start_location_lat']
274
+ end
275
+
276
+ if attributes.key?(:'start_location_long')
277
+ self.start_location_long = attributes[:'start_location_long']
278
+ end
279
+
280
+ if attributes.key?(:'start_location_type')
281
+ self.start_location_type = attributes[:'start_location_type']
282
+ end
283
+
284
+ if attributes.key?(:'status')
285
+ self.status = attributes[:'status']
286
+ end
287
+
288
+ if attributes.key?(:'updated_at')
289
+ self.updated_at = attributes[:'updated_at']
290
+ end
291
+
292
+ if attributes.key?(:'user_id')
293
+ self.user_id = attributes[:'user_id']
294
+ end
295
+
296
+ if attributes.key?(:'vehicle_ids')
297
+ if (value = attributes[:'vehicle_ids']).is_a?(Array)
298
+ self.vehicle_ids = value
299
+ end
300
+ end
301
+ end
302
+
303
+ # Show invalid properties with the reasons. Usually used together with valid?
304
+ # @return Array for valid properties with the reasons
305
+ def list_invalid_properties
306
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
307
+ invalid_properties = Array.new
308
+ invalid_properties
309
+ end
310
+
311
+ # Check to see if the all the properties in the model are valid
312
+ # @return true if the model is valid
313
+ def valid?
314
+ warn '[DEPRECATED] the `valid?` method is obsolete'
315
+ assignment_tier_validator = EnumAttributeValidator.new('String', ["lead", "buddy", "float"])
316
+ return false unless assignment_tier_validator.valid?(@assignment_tier)
317
+ start_location_type_validator = EnumAttributeValidator.new('String', ["home", "office"])
318
+ return false unless start_location_type_validator.valid?(@start_location_type)
319
+ true
320
+ end
321
+
322
+ # Custom attribute writer method checking allowed values (enum).
323
+ # @param [Object] assignment_tier Object to be assigned
324
+ def assignment_tier=(assignment_tier)
325
+ validator = EnumAttributeValidator.new('String', ["lead", "buddy", "float"])
326
+ unless validator.valid?(assignment_tier)
327
+ fail ArgumentError, "invalid value for \"assignment_tier\", must be one of #{validator.allowable_values}."
328
+ end
329
+ @assignment_tier = assignment_tier
330
+ end
331
+
332
+ # Custom attribute writer method checking allowed values (enum).
333
+ # @param [Object] start_location_type Object to be assigned
334
+ def start_location_type=(start_location_type)
335
+ validator = EnumAttributeValidator.new('String', ["home", "office"])
336
+ unless validator.valid?(start_location_type)
337
+ fail ArgumentError, "invalid value for \"start_location_type\", must be one of #{validator.allowable_values}."
338
+ end
339
+ @start_location_type = start_location_type
340
+ end
341
+
342
+ # Checks equality by comparing each attribute.
343
+ # @param [Object] Object to be compared
344
+ def ==(o)
345
+ return true if self.equal?(o)
346
+ self.class == o.class &&
347
+ address == o.address &&
348
+ assignment_tier == o.assignment_tier &&
349
+ buddy_ids == o.buddy_ids &&
350
+ business_group_id == o.business_group_id &&
351
+ business_id == o.business_id &&
352
+ created_at == o.created_at &&
353
+ deleted_at == o.deleted_at &&
354
+ email == o.email &&
355
+ full_name == o.full_name &&
356
+ id == o.id &&
357
+ job_title == o.job_title &&
358
+ join_date == o.join_date &&
359
+ last_login_at == o.last_login_at &&
360
+ leads == o.leads &&
361
+ phone == o.phone &&
362
+ role == o.role &&
363
+ service_areas == o.service_areas &&
364
+ start_location_lat == o.start_location_lat &&
365
+ start_location_long == o.start_location_long &&
366
+ start_location_type == o.start_location_type &&
367
+ status == o.status &&
368
+ updated_at == o.updated_at &&
369
+ user_id == o.user_id &&
370
+ vehicle_ids == o.vehicle_ids
371
+ end
372
+
373
+ # @see the `==` method
374
+ # @param [Object] Object to be compared
375
+ def eql?(o)
376
+ self == o
377
+ end
378
+
379
+ # Calculates hash code according to all attributes.
380
+ # @return [Integer] Hash code
381
+ def hash
382
+ [address, assignment_tier, buddy_ids, business_group_id, business_id, created_at, deleted_at, email, full_name, id, job_title, join_date, last_login_at, leads, phone, role, service_areas, start_location_lat, start_location_long, start_location_type, status, updated_at, user_id, vehicle_ids].hash
383
+ end
384
+
385
+ # Builds the object from hash
386
+ # @param [Hash] attributes Model attributes in the form of hash
387
+ # @return [Object] Returns the model itself
388
+ def self.build_from_hash(attributes)
389
+ return nil unless attributes.is_a?(Hash)
390
+ attributes = attributes.transform_keys(&:to_sym)
391
+ transformed_hash = {}
392
+ openapi_types.each_pair do |key, type|
393
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
394
+ transformed_hash["#{key}"] = nil
395
+ elsif type =~ /\AArray<(.*)>/i
396
+ # check to ensure the input is an array given that the attribute
397
+ # is documented as an array but the input is not
398
+ if attributes[attribute_map[key]].is_a?(Array)
399
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
400
+ end
401
+ elsif !attributes[attribute_map[key]].nil?
402
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
403
+ end
404
+ end
405
+ new(transformed_hash)
406
+ end
407
+
408
+ # Deserializes the data based on type
409
+ # @param string type Data type
410
+ # @param string value Value to be deserialized
411
+ # @return [Object] Deserialized data
412
+ def self._deserialize(type, value)
413
+ case type.to_sym
414
+ when :Time
415
+ Time.parse(value)
416
+ when :Date
417
+ Date.parse(value)
418
+ when :String
419
+ value.to_s
420
+ when :Integer
421
+ value.to_i
422
+ when :Float
423
+ value.to_f
424
+ when :Boolean
425
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
426
+ true
427
+ else
428
+ false
429
+ end
430
+ when :Object
431
+ # generic object (usually a Hash), return directly
432
+ value
433
+ when /\AArray<(?<inner_type>.+)>\z/
434
+ inner_type = Regexp.last_match[:inner_type]
435
+ value.map { |v| _deserialize(inner_type, v) }
436
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
437
+ k_type = Regexp.last_match[:k_type]
438
+ v_type = Regexp.last_match[:v_type]
439
+ {}.tap do |hash|
440
+ value.each do |k, v|
441
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
442
+ end
443
+ end
444
+ else # model
445
+ # models (e.g. Pet) or oneOf
446
+ klass = Crisphive.const_get(type)
447
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
448
+ end
449
+ end
450
+
451
+ # Returns the string representation of the object
452
+ # @return [String] String presentation of the object
453
+ def to_s
454
+ to_hash.to_s
455
+ end
456
+
457
+ # to_body is an alias to to_hash (backward compatibility)
458
+ # @return [Hash] Returns the object in the form of hash
459
+ def to_body
460
+ to_hash
461
+ end
462
+
463
+ # Returns the object in the form of hash
464
+ # @return [Hash] Returns the object in the form of hash
465
+ def to_hash
466
+ hash = {}
467
+ self.class.attribute_map.each_pair do |attr, param|
468
+ value = self.send(attr)
469
+ if value.nil?
470
+ is_nullable = self.class.openapi_nullable.include?(attr)
471
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
472
+ end
473
+
474
+ hash[param] = _to_hash(value)
475
+ end
476
+ hash
477
+ end
478
+
479
+ # Outputs non-array value in the form of hash
480
+ # For object, use to_hash. Otherwise, just return the value
481
+ # @param [Object] value Any valid value
482
+ # @return [Hash] Returns the value in the form of hash
483
+ def _to_hash(value)
484
+ if value.is_a?(Array)
485
+ value.compact.map { |v| _to_hash(v) }
486
+ elsif value.is_a?(Hash)
487
+ {}.tap do |hash|
488
+ value.each { |k, v| hash[k] = _to_hash(v) }
489
+ end
490
+ elsif value.respond_to? :to_hash
491
+ value.to_hash
492
+ else
493
+ value
494
+ end
495
+ end
496
+
497
+ end
498
+
499
+ end