primary_connect_client 0.8.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +61 -16
  4. data/docs/Address.md +32 -0
  5. data/docs/CodedValue.md +22 -0
  6. data/docs/DefaultApi.md +568 -0
  7. data/docs/Demographics.md +52 -0
  8. data/docs/Error.md +18 -0
  9. data/docs/Event.md +26 -0
  10. data/docs/Events.md +18 -0
  11. data/docs/Identifier.md +20 -0
  12. data/docs/Location.md +26 -0
  13. data/docs/Meta.md +34 -0
  14. data/docs/MetaDestinations.md +22 -0
  15. data/docs/MetaMessage.md +20 -0
  16. data/docs/MetaSource.md +20 -0
  17. data/docs/MetaTransmission.md +18 -0
  18. data/docs/Name.md +22 -0
  19. data/docs/Order.md +24 -0
  20. data/docs/OrderIds.md +18 -0
  21. data/docs/OrderOrder.md +58 -0
  22. data/docs/OrderOrderClinicalInfo.md +26 -0
  23. data/docs/OrderOrderDiagnoses.md +22 -0
  24. data/docs/OrderOrderOrderingFacility.md +22 -0
  25. data/docs/OrderOrderSpecimen.md +22 -0
  26. data/docs/OrderWithEventErrors.md +20 -0
  27. data/docs/Orders.md +18 -0
  28. data/docs/OrdersOrders.md +22 -0
  29. data/docs/Patient.md +24 -0
  30. data/docs/PatientContacts.md +28 -0
  31. data/docs/PatientDemographics.md +52 -0
  32. data/docs/PhoneNumber.md +20 -0
  33. data/docs/Provider.md +32 -0
  34. data/docs/Result.md +52 -0
  35. data/docs/ResultIds.md +18 -0
  36. data/docs/ResultReferenceRange.md +22 -0
  37. data/docs/ResultReport.md +22 -0
  38. data/docs/ResultSpecimen.md +22 -0
  39. data/docs/Results.md +20 -0
  40. data/docs/Specimen.md +22 -0
  41. data/docs/Visit.md +36 -0
  42. data/docs/VisitCompany.md +24 -0
  43. data/docs/VisitGuarantor.md +40 -0
  44. data/docs/VisitGuarantorEmployer.md +22 -0
  45. data/docs/VisitInsurances.md +40 -0
  46. data/docs/VisitInsured.md +30 -0
  47. data/docs/VisitPlan.md +22 -0
  48. data/git_push.sh +5 -6
  49. data/lib/primary_connect_client/api/default_api.rb +143 -67
  50. data/lib/primary_connect_client/api_client.rb +5 -6
  51. data/lib/primary_connect_client/api_error.rb +1 -1
  52. data/lib/primary_connect_client/configuration.rb +3 -2
  53. data/lib/primary_connect_client/models/address.rb +281 -0
  54. data/lib/primary_connect_client/models/coded_value.rb +238 -0
  55. data/lib/primary_connect_client/models/demographics.rb +466 -0
  56. data/lib/primary_connect_client/models/error.rb +218 -0
  57. data/lib/primary_connect_client/models/event.rb +254 -0
  58. data/lib/primary_connect_client/models/events.rb +221 -0
  59. data/lib/primary_connect_client/models/identifier.rb +228 -0
  60. data/lib/primary_connect_client/models/location.rb +255 -0
  61. data/lib/primary_connect_client/models/meta.rb +327 -0
  62. data/lib/primary_connect_client/models/meta_destinations.rb +242 -0
  63. data/lib/primary_connect_client/models/meta_message.rb +227 -0
  64. data/lib/primary_connect_client/models/meta_source.rb +227 -0
  65. data/lib/primary_connect_client/models/meta_transmission.rb +218 -0
  66. data/lib/primary_connect_client/models/name.rb +237 -0
  67. data/lib/primary_connect_client/models/order.rb +245 -0
  68. data/lib/primary_connect_client/models/order_ids.rb +221 -0
  69. data/lib/primary_connect_client/models/order_order.rb +496 -0
  70. data/lib/primary_connect_client/models/order_order_clinical_info.rb +260 -0
  71. data/lib/primary_connect_client/models/order_order_diagnoses.rb +272 -0
  72. data/lib/primary_connect_client/models/order_order_ordering_facility.rb +239 -0
  73. data/lib/primary_connect_client/models/order_order_specimen.rb +239 -0
  74. data/lib/primary_connect_client/models/order_with_event_errors.rb +229 -0
  75. data/lib/primary_connect_client/models/orders.rb +221 -0
  76. data/lib/primary_connect_client/models/orders_orders.rb +236 -0
  77. data/lib/primary_connect_client/models/patient.rb +253 -0
  78. data/lib/primary_connect_client/models/patient_contacts.rb +305 -0
  79. data/lib/primary_connect_client/models/patient_demographics.rb +466 -0
  80. data/lib/primary_connect_client/models/phone_number.rb +262 -0
  81. data/lib/primary_connect_client/models/provider.rb +288 -0
  82. data/lib/primary_connect_client/models/result.rb +443 -0
  83. data/lib/primary_connect_client/models/result_ids.rb +221 -0
  84. data/lib/primary_connect_client/models/result_reference_range.rb +240 -0
  85. data/lib/primary_connect_client/models/result_report.rb +240 -0
  86. data/lib/primary_connect_client/models/result_specimen.rb +239 -0
  87. data/lib/primary_connect_client/models/results.rb +230 -0
  88. data/lib/primary_connect_client/models/specimen.rb +239 -0
  89. data/lib/primary_connect_client/models/visit.rb +306 -0
  90. data/lib/primary_connect_client/models/visit_company.rb +248 -0
  91. data/lib/primary_connect_client/models/visit_guarantor.rb +358 -0
  92. data/lib/primary_connect_client/models/visit_guarantor_employer.rb +238 -0
  93. data/lib/primary_connect_client/models/visit_insurances.rb +386 -0
  94. data/lib/primary_connect_client/models/visit_insured.rb +322 -0
  95. data/lib/primary_connect_client/models/visit_plan.rb +238 -0
  96. data/lib/primary_connect_client/version.rb +12 -2
  97. data/lib/primary_connect_client.rb +45 -3
  98. data/primary_connect_client.gemspec +7 -5
  99. data/spec/api/default_api_spec.rb +44 -41
  100. data/spec/api_client_spec.rb +3 -3
  101. data/spec/configuration_spec.rb +1 -1
  102. data/spec/models/address_spec.rb +76 -0
  103. data/spec/models/coded_value_spec.rb +46 -0
  104. data/spec/models/demographics_spec.rb +168 -0
  105. data/spec/models/error_spec.rb +34 -0
  106. data/spec/models/event_spec.rb +58 -0
  107. data/spec/models/events_spec.rb +34 -0
  108. data/spec/models/identifier_spec.rb +40 -0
  109. data/spec/models/location_spec.rb +58 -0
  110. data/spec/models/meta_destinations_spec.rb +46 -0
  111. data/spec/models/meta_message_spec.rb +40 -0
  112. data/spec/models/meta_source_spec.rb +40 -0
  113. data/spec/models/meta_spec.rb +86 -0
  114. data/spec/models/meta_transmission_spec.rb +34 -0
  115. data/spec/models/name_spec.rb +46 -0
  116. data/spec/models/order_ids_spec.rb +34 -0
  117. data/spec/models/order_order_clinical_info_spec.rb +58 -0
  118. data/spec/models/order_order_diagnoses_spec.rb +50 -0
  119. data/spec/models/order_order_ordering_facility_spec.rb +46 -0
  120. data/spec/models/order_order_spec.rb +170 -0
  121. data/spec/models/order_order_specimen_spec.rb +46 -0
  122. data/spec/models/order_spec.rb +52 -0
  123. data/spec/models/order_with_event_errors_spec.rb +40 -0
  124. data/spec/models/orders_orders_spec.rb +46 -0
  125. data/spec/models/orders_spec.rb +34 -0
  126. data/spec/models/patient_contacts_spec.rb +68 -0
  127. data/spec/models/patient_demographics_spec.rb +168 -0
  128. data/spec/models/patient_spec.rb +52 -0
  129. data/spec/models/phone_number_spec.rb +44 -0
  130. data/spec/models/provider_spec.rb +76 -0
  131. data/spec/models/result_ids_spec.rb +34 -0
  132. data/spec/models/result_reference_range_spec.rb +46 -0
  133. data/spec/models/result_report_spec.rb +46 -0
  134. data/spec/models/result_spec.rb +148 -0
  135. data/spec/models/result_specimen_spec.rb +46 -0
  136. data/spec/models/results_spec.rb +40 -0
  137. data/spec/models/specimen_spec.rb +46 -0
  138. data/spec/models/visit_company_spec.rb +52 -0
  139. data/spec/models/visit_guarantor_employer_spec.rb +46 -0
  140. data/spec/models/visit_guarantor_spec.rb +104 -0
  141. data/spec/models/visit_insurances_spec.rb +112 -0
  142. data/spec/models/visit_insured_spec.rb +78 -0
  143. data/spec/models/visit_plan_spec.rb +46 -0
  144. data/spec/models/visit_spec.rb +88 -0
  145. data/spec/spec_helper.rb +1 -1
  146. metadata +177 -20
  147. data/Gemfile.lock +0 -74
@@ -0,0 +1,496 @@
1
+ =begin
2
+ #Primary Connect API V1
3
+
4
+ #Client Library to interface with Primary Connect
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PrimaryConnectClient
17
+ class OrderOrder
18
+ # ID of the order assigned by the placing system
19
+ attr_accessor :id
20
+
21
+ # ID assigned by the application fulfilling the order
22
+ attr_accessor :application_order_id
23
+
24
+ # The status of an order.
25
+ attr_accessor :status
26
+
27
+ # Timestamp when the order was placed
28
+ attr_accessor :transaction_date_time
29
+
30
+ # Timestamp when the specimen was collected
31
+ attr_accessor :collection_date_time
32
+
33
+ # Timestamp when the results were composed into a report and released.
34
+ attr_accessor :completion_date_time
35
+
36
+ # YYYY-MM-DD, Date when the order becomes invalid
37
+ attr_accessor :expiration_date
38
+
39
+ attr_accessor :specimen
40
+
41
+ attr_accessor :procedure
42
+
43
+ attr_accessor :ordering_provider
44
+
45
+ # Array of providers to be copied on the results
46
+ attr_accessor :result_copy_providers
47
+
48
+ attr_accessor :ordering_facility
49
+
50
+ # Priority of the order
51
+ attr_accessor :priority
52
+
53
+ # List of diagnoses associated with this order
54
+ attr_accessor :diagnoses
55
+
56
+ # Clinically relevant comments regarding the order
57
+ attr_accessor :clinical_comments
58
+
59
+ # Order-level notes
60
+ attr_accessor :notes
61
+
62
+ # List of supplementary clinical information associated with the order. Often these are answers to Ask at Order Entry (AOE) questions.
63
+ attr_accessor :clinical_info
64
+
65
+ # Current overall status of the order
66
+ attr_accessor :results_status
67
+
68
+ # Specificity of the response requested from the receiving system
69
+ attr_accessor :response_flag
70
+
71
+ attr_accessor :external_ids
72
+
73
+ # List of result components
74
+ attr_accessor :results
75
+
76
+ class EnumAttributeValidator
77
+ attr_reader :datatype
78
+ attr_reader :allowable_values
79
+
80
+ def initialize(datatype, allowable_values)
81
+ @allowable_values = allowable_values.map do |value|
82
+ case datatype.to_s
83
+ when /Integer/i
84
+ value.to_i
85
+ when /Float/i
86
+ value.to_f
87
+ else
88
+ value
89
+ end
90
+ end
91
+ end
92
+
93
+ def valid?(value)
94
+ !value || allowable_values.include?(value)
95
+ end
96
+ end
97
+
98
+ # Attribute mapping from ruby-style variable name to JSON key.
99
+ def self.attribute_map
100
+ {
101
+ :'id' => :'id',
102
+ :'application_order_id' => :'applicationOrderId',
103
+ :'status' => :'status',
104
+ :'transaction_date_time' => :'transactionDateTime',
105
+ :'collection_date_time' => :'collectionDateTime',
106
+ :'completion_date_time' => :'completionDateTime',
107
+ :'expiration_date' => :'expirationDate',
108
+ :'specimen' => :'specimen',
109
+ :'procedure' => :'procedure',
110
+ :'ordering_provider' => :'orderingProvider',
111
+ :'result_copy_providers' => :'resultCopyProviders',
112
+ :'ordering_facility' => :'orderingFacility',
113
+ :'priority' => :'priority',
114
+ :'diagnoses' => :'diagnoses',
115
+ :'clinical_comments' => :'clinicalComments',
116
+ :'notes' => :'notes',
117
+ :'clinical_info' => :'clinicalInfo',
118
+ :'results_status' => :'resultsStatus',
119
+ :'response_flag' => :'responseFlag',
120
+ :'external_ids' => :'externalIds',
121
+ :'results' => :'results'
122
+ }
123
+ end
124
+
125
+ # Returns all the JSON keys this model knows about
126
+ def self.acceptable_attributes
127
+ attribute_map.values
128
+ end
129
+
130
+ # Attribute type mapping.
131
+ def self.openapi_types
132
+ {
133
+ :'id' => :'String',
134
+ :'application_order_id' => :'String',
135
+ :'status' => :'String',
136
+ :'transaction_date_time' => :'Time',
137
+ :'collection_date_time' => :'Time',
138
+ :'completion_date_time' => :'Time',
139
+ :'expiration_date' => :'String',
140
+ :'specimen' => :'Specimen',
141
+ :'procedure' => :'CodedValue',
142
+ :'ordering_provider' => :'Provider',
143
+ :'result_copy_providers' => :'Array<Provider>',
144
+ :'ordering_facility' => :'OrderOrderOrderingFacility',
145
+ :'priority' => :'String',
146
+ :'diagnoses' => :'Array<OrderOrderDiagnoses>',
147
+ :'clinical_comments' => :'String',
148
+ :'notes' => :'Array<String>',
149
+ :'clinical_info' => :'Array<OrderOrderClinicalInfo>',
150
+ :'results_status' => :'String',
151
+ :'response_flag' => :'String',
152
+ :'external_ids' => :'Array<Identifier>',
153
+ :'results' => :'Array<Result>'
154
+ }
155
+ end
156
+
157
+ # List of attributes with nullable: true
158
+ def self.openapi_nullable
159
+ Set.new([
160
+ ])
161
+ end
162
+
163
+ # Initializes the object
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ def initialize(attributes = {})
166
+ if (!attributes.is_a?(Hash))
167
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::OrderOrder` initialize method"
168
+ end
169
+
170
+ # check to see if the attribute exists and convert string to symbol for hash key
171
+ attributes = attributes.each_with_object({}) { |(k, v), h|
172
+ if (!self.class.attribute_map.key?(k.to_sym))
173
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::OrderOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
174
+ end
175
+ h[k.to_sym] = v
176
+ }
177
+
178
+ if attributes.key?(:'id')
179
+ self.id = attributes[:'id']
180
+ end
181
+
182
+ if attributes.key?(:'application_order_id')
183
+ self.application_order_id = attributes[:'application_order_id']
184
+ end
185
+
186
+ if attributes.key?(:'status')
187
+ self.status = attributes[:'status']
188
+ end
189
+
190
+ if attributes.key?(:'transaction_date_time')
191
+ self.transaction_date_time = attributes[:'transaction_date_time']
192
+ end
193
+
194
+ if attributes.key?(:'collection_date_time')
195
+ self.collection_date_time = attributes[:'collection_date_time']
196
+ end
197
+
198
+ if attributes.key?(:'completion_date_time')
199
+ self.completion_date_time = attributes[:'completion_date_time']
200
+ end
201
+
202
+ if attributes.key?(:'expiration_date')
203
+ self.expiration_date = attributes[:'expiration_date']
204
+ end
205
+
206
+ if attributes.key?(:'specimen')
207
+ self.specimen = attributes[:'specimen']
208
+ end
209
+
210
+ if attributes.key?(:'procedure')
211
+ self.procedure = attributes[:'procedure']
212
+ end
213
+
214
+ if attributes.key?(:'ordering_provider')
215
+ self.ordering_provider = attributes[:'ordering_provider']
216
+ end
217
+
218
+ if attributes.key?(:'result_copy_providers')
219
+ if (value = attributes[:'result_copy_providers']).is_a?(Array)
220
+ self.result_copy_providers = value
221
+ end
222
+ end
223
+
224
+ if attributes.key?(:'ordering_facility')
225
+ self.ordering_facility = attributes[:'ordering_facility']
226
+ end
227
+
228
+ if attributes.key?(:'priority')
229
+ self.priority = attributes[:'priority']
230
+ end
231
+
232
+ if attributes.key?(:'diagnoses')
233
+ if (value = attributes[:'diagnoses']).is_a?(Array)
234
+ self.diagnoses = value
235
+ end
236
+ end
237
+
238
+ if attributes.key?(:'clinical_comments')
239
+ self.clinical_comments = attributes[:'clinical_comments']
240
+ end
241
+
242
+ if attributes.key?(:'notes')
243
+ if (value = attributes[:'notes']).is_a?(Array)
244
+ self.notes = value
245
+ end
246
+ end
247
+
248
+ if attributes.key?(:'clinical_info')
249
+ if (value = attributes[:'clinical_info']).is_a?(Array)
250
+ self.clinical_info = value
251
+ end
252
+ end
253
+
254
+ if attributes.key?(:'results_status')
255
+ self.results_status = attributes[:'results_status']
256
+ end
257
+
258
+ if attributes.key?(:'response_flag')
259
+ self.response_flag = attributes[:'response_flag']
260
+ end
261
+
262
+ if attributes.key?(:'external_ids')
263
+ if (value = attributes[:'external_ids']).is_a?(Array)
264
+ self.external_ids = value
265
+ end
266
+ end
267
+
268
+ if attributes.key?(:'results')
269
+ if (value = attributes[:'results']).is_a?(Array)
270
+ self.results = value
271
+ end
272
+ end
273
+ end
274
+
275
+ # Show invalid properties with the reasons. Usually used together with valid?
276
+ # @return Array for valid properties with the reasons
277
+ def list_invalid_properties
278
+ invalid_properties = Array.new
279
+ invalid_properties
280
+ end
281
+
282
+ # Check to see if the all the properties in the model are valid
283
+ # @return true if the model is valid
284
+ def valid?
285
+ status_validator = EnumAttributeValidator.new('String', ["STATUS_UNKNOWN", "STATUS_UPDATE", "STATUS_CANCEL", "STATUS_RESULTED", "STATUS_NEW"])
286
+ return false unless status_validator.valid?(@status)
287
+ priority_validator = EnumAttributeValidator.new('String', ["PRIORITY_UNKNOWN", "PRIORITY_ASAP", "PRIORITY_ROUTINE", "PRIORITY_PREOPERATIVE", "PRIORITY_TIMING_CRITICAL", "PRIORITY_STAT"])
288
+ return false unless priority_validator.valid?(@priority)
289
+ results_status_validator = EnumAttributeValidator.new('String', ["UNAVAILABLE", "PRELIMINARY", "IN_PROCESS", "CORRECTED", "CANCELED", "FINAL"])
290
+ return false unless results_status_validator.valid?(@results_status)
291
+ response_flag_validator = EnumAttributeValidator.new('String', ["UNKNOWN", "EXCEPTIONS", "REPLACEMENTS", "ASSOCIATED_SEGMENTS", "CONFIRMATIONS", "ACKNOWLEDGEMENT"])
292
+ return false unless response_flag_validator.valid?(@response_flag)
293
+ true
294
+ end
295
+
296
+ # Custom attribute writer method checking allowed values (enum).
297
+ # @param [Object] status Object to be assigned
298
+ def status=(status)
299
+ validator = EnumAttributeValidator.new('String', ["STATUS_UNKNOWN", "STATUS_UPDATE", "STATUS_CANCEL", "STATUS_RESULTED", "STATUS_NEW"])
300
+ unless validator.valid?(status)
301
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
302
+ end
303
+ @status = status
304
+ end
305
+
306
+ # Custom attribute writer method checking allowed values (enum).
307
+ # @param [Object] priority Object to be assigned
308
+ def priority=(priority)
309
+ validator = EnumAttributeValidator.new('String', ["PRIORITY_UNKNOWN", "PRIORITY_ASAP", "PRIORITY_ROUTINE", "PRIORITY_PREOPERATIVE", "PRIORITY_TIMING_CRITICAL", "PRIORITY_STAT"])
310
+ unless validator.valid?(priority)
311
+ fail ArgumentError, "invalid value for \"priority\", must be one of #{validator.allowable_values}."
312
+ end
313
+ @priority = priority
314
+ end
315
+
316
+ # Custom attribute writer method checking allowed values (enum).
317
+ # @param [Object] results_status Object to be assigned
318
+ def results_status=(results_status)
319
+ validator = EnumAttributeValidator.new('String', ["UNAVAILABLE", "PRELIMINARY", "IN_PROCESS", "CORRECTED", "CANCELED", "FINAL"])
320
+ unless validator.valid?(results_status)
321
+ fail ArgumentError, "invalid value for \"results_status\", must be one of #{validator.allowable_values}."
322
+ end
323
+ @results_status = results_status
324
+ end
325
+
326
+ # Custom attribute writer method checking allowed values (enum).
327
+ # @param [Object] response_flag Object to be assigned
328
+ def response_flag=(response_flag)
329
+ validator = EnumAttributeValidator.new('String', ["UNKNOWN", "EXCEPTIONS", "REPLACEMENTS", "ASSOCIATED_SEGMENTS", "CONFIRMATIONS", "ACKNOWLEDGEMENT"])
330
+ unless validator.valid?(response_flag)
331
+ fail ArgumentError, "invalid value for \"response_flag\", must be one of #{validator.allowable_values}."
332
+ end
333
+ @response_flag = response_flag
334
+ end
335
+
336
+ # Checks equality by comparing each attribute.
337
+ # @param [Object] Object to be compared
338
+ def ==(o)
339
+ return true if self.equal?(o)
340
+ self.class == o.class &&
341
+ id == o.id &&
342
+ application_order_id == o.application_order_id &&
343
+ status == o.status &&
344
+ transaction_date_time == o.transaction_date_time &&
345
+ collection_date_time == o.collection_date_time &&
346
+ completion_date_time == o.completion_date_time &&
347
+ expiration_date == o.expiration_date &&
348
+ specimen == o.specimen &&
349
+ procedure == o.procedure &&
350
+ ordering_provider == o.ordering_provider &&
351
+ result_copy_providers == o.result_copy_providers &&
352
+ ordering_facility == o.ordering_facility &&
353
+ priority == o.priority &&
354
+ diagnoses == o.diagnoses &&
355
+ clinical_comments == o.clinical_comments &&
356
+ notes == o.notes &&
357
+ clinical_info == o.clinical_info &&
358
+ results_status == o.results_status &&
359
+ response_flag == o.response_flag &&
360
+ external_ids == o.external_ids &&
361
+ results == o.results
362
+ end
363
+
364
+ # @see the `==` method
365
+ # @param [Object] Object to be compared
366
+ def eql?(o)
367
+ self == o
368
+ end
369
+
370
+ # Calculates hash code according to all attributes.
371
+ # @return [Integer] Hash code
372
+ def hash
373
+ [id, application_order_id, status, transaction_date_time, collection_date_time, completion_date_time, expiration_date, specimen, procedure, ordering_provider, result_copy_providers, ordering_facility, priority, diagnoses, clinical_comments, notes, clinical_info, results_status, response_flag, external_ids, results].hash
374
+ end
375
+
376
+ # Builds the object from hash
377
+ # @param [Hash] attributes Model attributes in the form of hash
378
+ # @return [Object] Returns the model itself
379
+ def self.build_from_hash(attributes)
380
+ new.build_from_hash(attributes)
381
+ end
382
+
383
+ # Builds the object from hash
384
+ # @param [Hash] attributes Model attributes in the form of hash
385
+ # @return [Object] Returns the model itself
386
+ def build_from_hash(attributes)
387
+ return nil unless attributes.is_a?(Hash)
388
+ self.class.openapi_types.each_pair do |key, type|
389
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
390
+ self.send("#{key}=", nil)
391
+ elsif type =~ /\AArray<(.*)>/i
392
+ # check to ensure the input is an array given that the attribute
393
+ # is documented as an array but the input is not
394
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
395
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
396
+ end
397
+ elsif !attributes[self.class.attribute_map[key]].nil?
398
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
399
+ end
400
+ end
401
+
402
+ self
403
+ end
404
+
405
+ # Deserializes the data based on type
406
+ # @param string type Data type
407
+ # @param string value Value to be deserialized
408
+ # @return [Object] Deserialized data
409
+ def _deserialize(type, value)
410
+ case type.to_sym
411
+ when :Time
412
+ Time.parse(value)
413
+ when :Date
414
+ Date.parse(value)
415
+ when :String
416
+ value.to_s
417
+ when :Integer
418
+ value.to_i
419
+ when :Float
420
+ value.to_f
421
+ when :Boolean
422
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
423
+ true
424
+ else
425
+ false
426
+ end
427
+ when :Object
428
+ # generic object (usually a Hash), return directly
429
+ value
430
+ when /\AArray<(?<inner_type>.+)>\z/
431
+ inner_type = Regexp.last_match[:inner_type]
432
+ value.map { |v| _deserialize(inner_type, v) }
433
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
434
+ k_type = Regexp.last_match[:k_type]
435
+ v_type = Regexp.last_match[:v_type]
436
+ {}.tap do |hash|
437
+ value.each do |k, v|
438
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
439
+ end
440
+ end
441
+ else # model
442
+ # models (e.g. Pet) or oneOf
443
+ klass = PrimaryConnectClient.const_get(type)
444
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
445
+ end
446
+ end
447
+
448
+ # Returns the string representation of the object
449
+ # @return [String] String presentation of the object
450
+ def to_s
451
+ to_hash.to_s
452
+ end
453
+
454
+ # to_body is an alias to to_hash (backward compatibility)
455
+ # @return [Hash] Returns the object in the form of hash
456
+ def to_body
457
+ to_hash
458
+ end
459
+
460
+ # Returns the object in the form of hash
461
+ # @return [Hash] Returns the object in the form of hash
462
+ def to_hash
463
+ hash = {}
464
+ self.class.attribute_map.each_pair do |attr, param|
465
+ value = self.send(attr)
466
+ if value.nil?
467
+ is_nullable = self.class.openapi_nullable.include?(attr)
468
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
469
+ end
470
+
471
+ hash[param] = _to_hash(value)
472
+ end
473
+ hash
474
+ end
475
+
476
+ # Outputs non-array value in the form of hash
477
+ # For object, use to_hash. Otherwise, just return the value
478
+ # @param [Object] value Any valid value
479
+ # @return [Hash] Returns the value in the form of hash
480
+ def _to_hash(value)
481
+ if value.is_a?(Array)
482
+ value.compact.map { |v| _to_hash(v) }
483
+ elsif value.is_a?(Hash)
484
+ {}.tap do |hash|
485
+ value.each { |k, v| hash[k] = _to_hash(v) }
486
+ end
487
+ elsif value.respond_to? :to_hash
488
+ value.to_hash
489
+ else
490
+ value
491
+ end
492
+ end
493
+
494
+ end
495
+
496
+ end