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,537 @@
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 JobRequest
18
+ # ActionAudit is the per-action audit log keyed by action_key. `complete` fixed action không xuất hiện ở đây — actor lookup qua CompletedByUserID.
19
+ attr_accessor :action_audit
20
+
21
+ # The job's service address snapshot.
22
+ attr_accessor :address
23
+
24
+ # The job's archive state.
25
+ attr_accessor :archive
26
+
27
+ # AssignedVehicle is the carpool vehicle (the lead drives). Omitted when the job has no vehicle.
28
+ attr_accessor :assigned_vehicle
29
+
30
+ # Who/what is assigned to the job.
31
+ attr_accessor :assignment
32
+
33
+ # UUID of the owning business.
34
+ attr_accessor :business_id
35
+
36
+ # When the job was completed (UTC); null until completed.
37
+ attr_accessor :completed_at
38
+
39
+ # UUID of the user who fired complete; null until completed.
40
+ attr_accessor :completed_by_user_id
41
+
42
+ # When the job was created (UTC).
43
+ attr_accessor :created_at
44
+
45
+ # Crew is the multi-person crew on the job (lead first). A single-person job has one member. Omitted when no session plan exists.
46
+ attr_accessor :crew
47
+
48
+ # The job's current workflow status.
49
+ attr_accessor :current_status
50
+
51
+ # The job's customer contact snapshot.
52
+ attr_accessor :customer
53
+
54
+ # Ready-to-share customer URL embedding the magic token. Omitted if not issued.
55
+ attr_accessor :customer_url
56
+
57
+ # When the job was soft-deleted (UTC); omitted unless deleted.
58
+ attr_accessor :deleted_at
59
+
60
+ # Free-text job description; null if none.
61
+ attr_accessor :description
62
+
63
+ # Job request UUID.
64
+ attr_accessor :id
65
+
66
+ # UUID of the job type, or null if unclassified.
67
+ attr_accessor :job_type_id
68
+
69
+ # Job type display name (resolved to locale). Omitted if unclassified.
70
+ attr_accessor :job_type_name
71
+
72
+ # The action(s) the job is currently waiting on. Omitted in a terminal status.
73
+ attr_accessor :next_actions
74
+
75
+ # Job priority.
76
+ attr_accessor :priority
77
+
78
+ # The time-bundle quoted for the job.
79
+ attr_accessor :quote
80
+
81
+ # The customer's rating of the completed job.
82
+ attr_accessor :rating
83
+
84
+ # When/how the job is scheduled and its per-day plan.
85
+ attr_accessor :schedule
86
+
87
+ # Human-friendly short code. Omitted if not assigned.
88
+ attr_accessor :short_code
89
+
90
+ # Desired skills for the job (resolved id+name).
91
+ attr_accessor :skills
92
+
93
+ # Optimistic-lock version; pass back as status_version on transitions to avoid races.
94
+ attr_accessor :status_version
95
+
96
+ # When the job was last modified (UTC).
97
+ attr_accessor :updated_at
98
+
99
+ # UUID of the workflow snapshot driving this job's state machine.
100
+ attr_accessor :workflow_id
101
+
102
+ # Workflow display name.
103
+ attr_accessor :workflow_name
104
+
105
+ class EnumAttributeValidator
106
+ attr_reader :datatype
107
+ attr_reader :allowable_values
108
+
109
+ def initialize(datatype, allowable_values)
110
+ @allowable_values = allowable_values.map do |value|
111
+ case datatype.to_s
112
+ when /Integer/i
113
+ value.to_i
114
+ when /Float/i
115
+ value.to_f
116
+ else
117
+ value
118
+ end
119
+ end
120
+ end
121
+
122
+ def valid?(value)
123
+ !value || allowable_values.include?(value)
124
+ end
125
+ end
126
+
127
+ # Attribute mapping from ruby-style variable name to JSON key.
128
+ def self.attribute_map
129
+ {
130
+ :'action_audit' => :'action_audit',
131
+ :'address' => :'address',
132
+ :'archive' => :'archive',
133
+ :'assigned_vehicle' => :'assigned_vehicle',
134
+ :'assignment' => :'assignment',
135
+ :'business_id' => :'business_id',
136
+ :'completed_at' => :'completed_at',
137
+ :'completed_by_user_id' => :'completed_by_user_id',
138
+ :'created_at' => :'created_at',
139
+ :'crew' => :'crew',
140
+ :'current_status' => :'current_status',
141
+ :'customer' => :'customer',
142
+ :'customer_url' => :'customer_url',
143
+ :'deleted_at' => :'deleted_at',
144
+ :'description' => :'description',
145
+ :'id' => :'id',
146
+ :'job_type_id' => :'job_type_id',
147
+ :'job_type_name' => :'job_type_name',
148
+ :'next_actions' => :'next_actions',
149
+ :'priority' => :'priority',
150
+ :'quote' => :'quote',
151
+ :'rating' => :'rating',
152
+ :'schedule' => :'schedule',
153
+ :'short_code' => :'short_code',
154
+ :'skills' => :'skills',
155
+ :'status_version' => :'status_version',
156
+ :'updated_at' => :'updated_at',
157
+ :'workflow_id' => :'workflow_id',
158
+ :'workflow_name' => :'workflow_name'
159
+ }
160
+ end
161
+
162
+ # Returns all the JSON keys this model knows about
163
+ def self.acceptable_attributes
164
+ attribute_map.values
165
+ end
166
+
167
+ # Attribute type mapping.
168
+ def self.openapi_types
169
+ {
170
+ :'action_audit' => :'Hash<String, JobRequestActionAuditEntry>',
171
+ :'address' => :'JobRequestAddressSummary',
172
+ :'archive' => :'JobRequestArchiveSummary',
173
+ :'assigned_vehicle' => :'JobRequestAssignedVehicle',
174
+ :'assignment' => :'JobRequestAssignmentSummary',
175
+ :'business_id' => :'String',
176
+ :'completed_at' => :'Time',
177
+ :'completed_by_user_id' => :'String',
178
+ :'created_at' => :'Time',
179
+ :'crew' => :'Array<JobRequestCrewMember>',
180
+ :'current_status' => :'JobRequestStatusSummary',
181
+ :'customer' => :'JobRequestCustomerSummary',
182
+ :'customer_url' => :'String',
183
+ :'deleted_at' => :'Time',
184
+ :'description' => :'String',
185
+ :'id' => :'String',
186
+ :'job_type_id' => :'String',
187
+ :'job_type_name' => :'String',
188
+ :'next_actions' => :'Array<JobRequestActionSummary>',
189
+ :'priority' => :'String',
190
+ :'quote' => :'JobRequestQuoteSummary',
191
+ :'rating' => :'JobRequestRatingSummary',
192
+ :'schedule' => :'JobRequestSchedule',
193
+ :'short_code' => :'String',
194
+ :'skills' => :'Array<JobRequestSkillSummary>',
195
+ :'status_version' => :'Integer',
196
+ :'updated_at' => :'Time',
197
+ :'workflow_id' => :'String',
198
+ :'workflow_name' => :'String'
199
+ }
200
+ end
201
+
202
+ # List of attributes with nullable: true
203
+ def self.openapi_nullable
204
+ Set.new([
205
+ ])
206
+ end
207
+
208
+ # Initializes the object
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ def initialize(attributes = {})
211
+ if (!attributes.is_a?(Hash))
212
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::JobRequest` initialize method"
213
+ end
214
+
215
+ # check to see if the attribute exists and convert string to symbol for hash key
216
+ attributes = attributes.each_with_object({}) { |(k, v), h|
217
+ if (!self.class.attribute_map.key?(k.to_sym))
218
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::JobRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
219
+ end
220
+ h[k.to_sym] = v
221
+ }
222
+
223
+ if attributes.key?(:'action_audit')
224
+ if (value = attributes[:'action_audit']).is_a?(Hash)
225
+ self.action_audit = value
226
+ end
227
+ end
228
+
229
+ if attributes.key?(:'address')
230
+ self.address = attributes[:'address']
231
+ end
232
+
233
+ if attributes.key?(:'archive')
234
+ self.archive = attributes[:'archive']
235
+ end
236
+
237
+ if attributes.key?(:'assigned_vehicle')
238
+ self.assigned_vehicle = attributes[:'assigned_vehicle']
239
+ end
240
+
241
+ if attributes.key?(:'assignment')
242
+ self.assignment = attributes[:'assignment']
243
+ end
244
+
245
+ if attributes.key?(:'business_id')
246
+ self.business_id = attributes[:'business_id']
247
+ end
248
+
249
+ if attributes.key?(:'completed_at')
250
+ self.completed_at = attributes[:'completed_at']
251
+ end
252
+
253
+ if attributes.key?(:'completed_by_user_id')
254
+ self.completed_by_user_id = attributes[:'completed_by_user_id']
255
+ end
256
+
257
+ if attributes.key?(:'created_at')
258
+ self.created_at = attributes[:'created_at']
259
+ end
260
+
261
+ if attributes.key?(:'crew')
262
+ if (value = attributes[:'crew']).is_a?(Array)
263
+ self.crew = value
264
+ end
265
+ end
266
+
267
+ if attributes.key?(:'current_status')
268
+ self.current_status = attributes[:'current_status']
269
+ end
270
+
271
+ if attributes.key?(:'customer')
272
+ self.customer = attributes[:'customer']
273
+ end
274
+
275
+ if attributes.key?(:'customer_url')
276
+ self.customer_url = attributes[:'customer_url']
277
+ end
278
+
279
+ if attributes.key?(:'deleted_at')
280
+ self.deleted_at = attributes[:'deleted_at']
281
+ end
282
+
283
+ if attributes.key?(:'description')
284
+ self.description = attributes[:'description']
285
+ end
286
+
287
+ if attributes.key?(:'id')
288
+ self.id = attributes[:'id']
289
+ end
290
+
291
+ if attributes.key?(:'job_type_id')
292
+ self.job_type_id = attributes[:'job_type_id']
293
+ end
294
+
295
+ if attributes.key?(:'job_type_name')
296
+ self.job_type_name = attributes[:'job_type_name']
297
+ end
298
+
299
+ if attributes.key?(:'next_actions')
300
+ if (value = attributes[:'next_actions']).is_a?(Array)
301
+ self.next_actions = value
302
+ end
303
+ end
304
+
305
+ if attributes.key?(:'priority')
306
+ self.priority = attributes[:'priority']
307
+ end
308
+
309
+ if attributes.key?(:'quote')
310
+ self.quote = attributes[:'quote']
311
+ end
312
+
313
+ if attributes.key?(:'rating')
314
+ self.rating = attributes[:'rating']
315
+ end
316
+
317
+ if attributes.key?(:'schedule')
318
+ self.schedule = attributes[:'schedule']
319
+ end
320
+
321
+ if attributes.key?(:'short_code')
322
+ self.short_code = attributes[:'short_code']
323
+ end
324
+
325
+ if attributes.key?(:'skills')
326
+ if (value = attributes[:'skills']).is_a?(Array)
327
+ self.skills = value
328
+ end
329
+ end
330
+
331
+ if attributes.key?(:'status_version')
332
+ self.status_version = attributes[:'status_version']
333
+ end
334
+
335
+ if attributes.key?(:'updated_at')
336
+ self.updated_at = attributes[:'updated_at']
337
+ end
338
+
339
+ if attributes.key?(:'workflow_id')
340
+ self.workflow_id = attributes[:'workflow_id']
341
+ end
342
+
343
+ if attributes.key?(:'workflow_name')
344
+ self.workflow_name = attributes[:'workflow_name']
345
+ end
346
+ end
347
+
348
+ # Show invalid properties with the reasons. Usually used together with valid?
349
+ # @return Array for valid properties with the reasons
350
+ def list_invalid_properties
351
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
352
+ invalid_properties = Array.new
353
+ invalid_properties
354
+ end
355
+
356
+ # Check to see if the all the properties in the model are valid
357
+ # @return true if the model is valid
358
+ def valid?
359
+ warn '[DEPRECATED] the `valid?` method is obsolete'
360
+ priority_validator = EnumAttributeValidator.new('String', ["normal", "emergency"])
361
+ return false unless priority_validator.valid?(@priority)
362
+ true
363
+ end
364
+
365
+ # Custom attribute writer method checking allowed values (enum).
366
+ # @param [Object] priority Object to be assigned
367
+ def priority=(priority)
368
+ validator = EnumAttributeValidator.new('String', ["normal", "emergency"])
369
+ unless validator.valid?(priority)
370
+ fail ArgumentError, "invalid value for \"priority\", must be one of #{validator.allowable_values}."
371
+ end
372
+ @priority = priority
373
+ end
374
+
375
+ # Checks equality by comparing each attribute.
376
+ # @param [Object] Object to be compared
377
+ def ==(o)
378
+ return true if self.equal?(o)
379
+ self.class == o.class &&
380
+ action_audit == o.action_audit &&
381
+ address == o.address &&
382
+ archive == o.archive &&
383
+ assigned_vehicle == o.assigned_vehicle &&
384
+ assignment == o.assignment &&
385
+ business_id == o.business_id &&
386
+ completed_at == o.completed_at &&
387
+ completed_by_user_id == o.completed_by_user_id &&
388
+ created_at == o.created_at &&
389
+ crew == o.crew &&
390
+ current_status == o.current_status &&
391
+ customer == o.customer &&
392
+ customer_url == o.customer_url &&
393
+ deleted_at == o.deleted_at &&
394
+ description == o.description &&
395
+ id == o.id &&
396
+ job_type_id == o.job_type_id &&
397
+ job_type_name == o.job_type_name &&
398
+ next_actions == o.next_actions &&
399
+ priority == o.priority &&
400
+ quote == o.quote &&
401
+ rating == o.rating &&
402
+ schedule == o.schedule &&
403
+ short_code == o.short_code &&
404
+ skills == o.skills &&
405
+ status_version == o.status_version &&
406
+ updated_at == o.updated_at &&
407
+ workflow_id == o.workflow_id &&
408
+ workflow_name == o.workflow_name
409
+ end
410
+
411
+ # @see the `==` method
412
+ # @param [Object] Object to be compared
413
+ def eql?(o)
414
+ self == o
415
+ end
416
+
417
+ # Calculates hash code according to all attributes.
418
+ # @return [Integer] Hash code
419
+ def hash
420
+ [action_audit, address, archive, assigned_vehicle, assignment, business_id, completed_at, completed_by_user_id, created_at, crew, current_status, customer, customer_url, deleted_at, description, id, job_type_id, job_type_name, next_actions, priority, quote, rating, schedule, short_code, skills, status_version, updated_at, workflow_id, workflow_name].hash
421
+ end
422
+
423
+ # Builds the object from hash
424
+ # @param [Hash] attributes Model attributes in the form of hash
425
+ # @return [Object] Returns the model itself
426
+ def self.build_from_hash(attributes)
427
+ return nil unless attributes.is_a?(Hash)
428
+ attributes = attributes.transform_keys(&:to_sym)
429
+ transformed_hash = {}
430
+ openapi_types.each_pair do |key, type|
431
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
432
+ transformed_hash["#{key}"] = nil
433
+ elsif type =~ /\AArray<(.*)>/i
434
+ # check to ensure the input is an array given that the attribute
435
+ # is documented as an array but the input is not
436
+ if attributes[attribute_map[key]].is_a?(Array)
437
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
438
+ end
439
+ elsif !attributes[attribute_map[key]].nil?
440
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
441
+ end
442
+ end
443
+ new(transformed_hash)
444
+ end
445
+
446
+ # Deserializes the data based on type
447
+ # @param string type Data type
448
+ # @param string value Value to be deserialized
449
+ # @return [Object] Deserialized data
450
+ def self._deserialize(type, value)
451
+ case type.to_sym
452
+ when :Time
453
+ Time.parse(value)
454
+ when :Date
455
+ Date.parse(value)
456
+ when :String
457
+ value.to_s
458
+ when :Integer
459
+ value.to_i
460
+ when :Float
461
+ value.to_f
462
+ when :Boolean
463
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
464
+ true
465
+ else
466
+ false
467
+ end
468
+ when :Object
469
+ # generic object (usually a Hash), return directly
470
+ value
471
+ when /\AArray<(?<inner_type>.+)>\z/
472
+ inner_type = Regexp.last_match[:inner_type]
473
+ value.map { |v| _deserialize(inner_type, v) }
474
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
475
+ k_type = Regexp.last_match[:k_type]
476
+ v_type = Regexp.last_match[:v_type]
477
+ {}.tap do |hash|
478
+ value.each do |k, v|
479
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
480
+ end
481
+ end
482
+ else # model
483
+ # models (e.g. Pet) or oneOf
484
+ klass = Crisphive.const_get(type)
485
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
486
+ end
487
+ end
488
+
489
+ # Returns the string representation of the object
490
+ # @return [String] String presentation of the object
491
+ def to_s
492
+ to_hash.to_s
493
+ end
494
+
495
+ # to_body is an alias to to_hash (backward compatibility)
496
+ # @return [Hash] Returns the object in the form of hash
497
+ def to_body
498
+ to_hash
499
+ end
500
+
501
+ # Returns the object in the form of hash
502
+ # @return [Hash] Returns the object in the form of hash
503
+ def to_hash
504
+ hash = {}
505
+ self.class.attribute_map.each_pair do |attr, param|
506
+ value = self.send(attr)
507
+ if value.nil?
508
+ is_nullable = self.class.openapi_nullable.include?(attr)
509
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
510
+ end
511
+
512
+ hash[param] = _to_hash(value)
513
+ end
514
+ hash
515
+ end
516
+
517
+ # Outputs non-array value in the form of hash
518
+ # For object, use to_hash. Otherwise, just return the value
519
+ # @param [Object] value Any valid value
520
+ # @return [Hash] Returns the value in the form of hash
521
+ def _to_hash(value)
522
+ if value.is_a?(Array)
523
+ value.compact.map { |v| _to_hash(v) }
524
+ elsif value.is_a?(Hash)
525
+ {}.tap do |hash|
526
+ value.each { |k, v| hash[k] = _to_hash(v) }
527
+ end
528
+ elsif value.respond_to? :to_hash
529
+ value.to_hash
530
+ else
531
+ value
532
+ end
533
+ end
534
+
535
+ end
536
+
537
+ end