primary_connect_client 0.8.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +74 -20
  4. data/docs/Address.md +32 -0
  5. data/docs/CodedValue.md +22 -0
  6. data/docs/DefaultApi.md +637 -0
  7. data/docs/Demographics.md +52 -0
  8. data/docs/Device.md +30 -0
  9. data/docs/Dosage.md +30 -0
  10. data/docs/Error.md +18 -0
  11. data/docs/Event.md +26 -0
  12. data/docs/Events.md +18 -0
  13. data/docs/Identifier.md +20 -0
  14. data/docs/Location.md +28 -0
  15. data/docs/Medication.md +22 -0
  16. data/docs/MedicationAdministration.md +32 -0
  17. data/docs/Meta.md +34 -0
  18. data/docs/MetaDestinations.md +22 -0
  19. data/docs/MetaMessage.md +20 -0
  20. data/docs/MetaSource.md +20 -0
  21. data/docs/MetaTransmission.md +18 -0
  22. data/docs/Name.md +22 -0
  23. data/docs/Order.md +26 -0
  24. data/docs/OrderIds.md +18 -0
  25. data/docs/OrderOrder.md +62 -0
  26. data/docs/OrderOrderClinicalInfo.md +26 -0
  27. data/docs/OrderOrderDiagnoses.md +22 -0
  28. data/docs/OrderOrderOrderingFacility.md +22 -0
  29. data/docs/OrderOrderSpecimen.md +22 -0
  30. data/docs/OrderWithEventErrors.md +20 -0
  31. data/docs/Orders.md +18 -0
  32. data/docs/OrdersOrders.md +22 -0
  33. data/docs/Patient.md +24 -0
  34. data/docs/PatientContacts.md +28 -0
  35. data/docs/PatientDemographics.md +52 -0
  36. data/docs/PhoneNumber.md +20 -0
  37. data/docs/Provider.md +32 -0
  38. data/docs/Result.md +52 -0
  39. data/docs/ResultIds.md +18 -0
  40. data/docs/ResultReferenceRange.md +22 -0
  41. data/docs/ResultReport.md +22 -0
  42. data/docs/ResultSpecimen.md +22 -0
  43. data/docs/Results.md +20 -0
  44. data/docs/Specimen.md +22 -0
  45. data/docs/Subject.md +49 -0
  46. data/docs/SubjectOneOf.md +18 -0
  47. data/docs/SubjectOneOf1.md +18 -0
  48. data/docs/V2Device.md +30 -0
  49. data/docs/V2Dosage.md +30 -0
  50. data/docs/V2Medication.md +22 -0
  51. data/docs/V2MedicationAdministration.md +32 -0
  52. data/docs/Visit.md +36 -0
  53. data/docs/VisitCompany.md +24 -0
  54. data/docs/VisitGuarantor.md +40 -0
  55. data/docs/VisitGuarantorEmployer.md +22 -0
  56. data/docs/VisitInsurances.md +40 -0
  57. data/docs/VisitInsured.md +30 -0
  58. data/docs/VisitPlan.md +22 -0
  59. data/git_push.sh +5 -6
  60. data/lib/primary_connect_client/api/default_api.rb +207 -67
  61. data/lib/primary_connect_client/api_client.rb +5 -6
  62. data/lib/primary_connect_client/api_error.rb +1 -1
  63. data/lib/primary_connect_client/configuration.rb +3 -2
  64. data/lib/primary_connect_client/models/address.rb +281 -0
  65. data/lib/primary_connect_client/models/coded_value.rb +238 -0
  66. data/lib/primary_connect_client/models/demographics.rb +466 -0
  67. data/lib/primary_connect_client/models/device.rb +276 -0
  68. data/lib/primary_connect_client/models/dosage.rb +275 -0
  69. data/lib/primary_connect_client/models/error.rb +218 -0
  70. data/lib/primary_connect_client/models/event.rb +254 -0
  71. data/lib/primary_connect_client/models/events.rb +221 -0
  72. data/lib/primary_connect_client/models/identifier.rb +228 -0
  73. data/lib/primary_connect_client/models/location.rb +264 -0
  74. data/lib/primary_connect_client/models/medication.rb +238 -0
  75. data/lib/primary_connect_client/models/medication_administration.rb +286 -0
  76. data/lib/primary_connect_client/models/meta.rb +327 -0
  77. data/lib/primary_connect_client/models/meta_destinations.rb +242 -0
  78. data/lib/primary_connect_client/models/meta_message.rb +227 -0
  79. data/lib/primary_connect_client/models/meta_source.rb +227 -0
  80. data/lib/primary_connect_client/models/meta_transmission.rb +218 -0
  81. data/lib/primary_connect_client/models/name.rb +237 -0
  82. data/lib/primary_connect_client/models/order.rb +255 -0
  83. data/lib/primary_connect_client/models/order_ids.rb +221 -0
  84. data/lib/primary_connect_client/models/order_order.rb +518 -0
  85. data/lib/primary_connect_client/models/order_order_clinical_info.rb +260 -0
  86. data/lib/primary_connect_client/models/order_order_diagnoses.rb +272 -0
  87. data/lib/primary_connect_client/models/order_order_ordering_facility.rb +239 -0
  88. data/lib/primary_connect_client/models/order_order_specimen.rb +239 -0
  89. data/lib/primary_connect_client/models/order_with_event_errors.rb +229 -0
  90. data/lib/primary_connect_client/models/orders.rb +221 -0
  91. data/lib/primary_connect_client/models/orders_orders.rb +236 -0
  92. data/lib/primary_connect_client/models/patient.rb +253 -0
  93. data/lib/primary_connect_client/models/patient_contacts.rb +305 -0
  94. data/lib/primary_connect_client/models/patient_demographics.rb +466 -0
  95. data/lib/primary_connect_client/models/phone_number.rb +262 -0
  96. data/lib/primary_connect_client/models/provider.rb +288 -0
  97. data/lib/primary_connect_client/models/result.rb +443 -0
  98. data/lib/primary_connect_client/models/result_ids.rb +221 -0
  99. data/lib/primary_connect_client/models/result_reference_range.rb +240 -0
  100. data/lib/primary_connect_client/models/result_report.rb +240 -0
  101. data/lib/primary_connect_client/models/result_specimen.rb +239 -0
  102. data/lib/primary_connect_client/models/results.rb +230 -0
  103. data/lib/primary_connect_client/models/specimen.rb +239 -0
  104. data/lib/primary_connect_client/models/subject.rb +105 -0
  105. data/lib/primary_connect_client/models/subject_one_of.rb +218 -0
  106. data/lib/primary_connect_client/models/subject_one_of1.rb +218 -0
  107. data/lib/primary_connect_client/models/v2_device.rb +276 -0
  108. data/lib/primary_connect_client/models/v2_dosage.rb +275 -0
  109. data/lib/primary_connect_client/models/v2_medication.rb +238 -0
  110. data/lib/primary_connect_client/models/v2_medication_administration.rb +286 -0
  111. data/lib/primary_connect_client/models/visit.rb +306 -0
  112. data/lib/primary_connect_client/models/visit_company.rb +248 -0
  113. data/lib/primary_connect_client/models/visit_guarantor.rb +358 -0
  114. data/lib/primary_connect_client/models/visit_guarantor_employer.rb +238 -0
  115. data/lib/primary_connect_client/models/visit_insurances.rb +386 -0
  116. data/lib/primary_connect_client/models/visit_insured.rb +322 -0
  117. data/lib/primary_connect_client/models/visit_plan.rb +238 -0
  118. data/lib/primary_connect_client/version.rb +12 -2
  119. data/lib/primary_connect_client.rb +56 -3
  120. data/primary_connect_client.gemspec +8 -5
  121. data/spec/api/default_api_spec.rb +56 -41
  122. data/spec/api_client_spec.rb +3 -3
  123. data/spec/configuration_spec.rb +1 -1
  124. data/spec/models/address_spec.rb +76 -0
  125. data/spec/models/coded_value_spec.rb +46 -0
  126. data/spec/models/demographics_spec.rb +168 -0
  127. data/spec/models/device_spec.rb +70 -0
  128. data/spec/models/dosage_spec.rb +70 -0
  129. data/spec/models/error_spec.rb +34 -0
  130. data/spec/models/event_spec.rb +58 -0
  131. data/spec/models/events_spec.rb +34 -0
  132. data/spec/models/identifier_spec.rb +40 -0
  133. data/spec/models/location_spec.rb +64 -0
  134. data/spec/models/medication_administration_spec.rb +76 -0
  135. data/spec/models/medication_spec.rb +46 -0
  136. data/spec/models/meta_destinations_spec.rb +46 -0
  137. data/spec/models/meta_message_spec.rb +40 -0
  138. data/spec/models/meta_source_spec.rb +40 -0
  139. data/spec/models/meta_spec.rb +86 -0
  140. data/spec/models/meta_transmission_spec.rb +34 -0
  141. data/spec/models/name_spec.rb +46 -0
  142. data/spec/models/order_ids_spec.rb +34 -0
  143. data/spec/models/order_order_clinical_info_spec.rb +58 -0
  144. data/spec/models/order_order_diagnoses_spec.rb +50 -0
  145. data/spec/models/order_order_ordering_facility_spec.rb +46 -0
  146. data/spec/models/order_order_spec.rb +182 -0
  147. data/spec/models/order_order_specimen_spec.rb +46 -0
  148. data/spec/models/order_spec.rb +58 -0
  149. data/spec/models/order_with_event_errors_spec.rb +40 -0
  150. data/spec/models/orders_orders_spec.rb +46 -0
  151. data/spec/models/orders_spec.rb +34 -0
  152. data/spec/models/patient_contacts_spec.rb +68 -0
  153. data/spec/models/patient_demographics_spec.rb +168 -0
  154. data/spec/models/patient_spec.rb +52 -0
  155. data/spec/models/phone_number_spec.rb +44 -0
  156. data/spec/models/provider_spec.rb +76 -0
  157. data/spec/models/result_ids_spec.rb +34 -0
  158. data/spec/models/result_reference_range_spec.rb +46 -0
  159. data/spec/models/result_report_spec.rb +46 -0
  160. data/spec/models/result_spec.rb +148 -0
  161. data/spec/models/result_specimen_spec.rb +46 -0
  162. data/spec/models/results_spec.rb +40 -0
  163. data/spec/models/specimen_spec.rb +46 -0
  164. data/spec/models/subject_one_of1_spec.rb +34 -0
  165. data/spec/models/subject_one_of_spec.rb +34 -0
  166. data/spec/models/subject_spec.rb +31 -0
  167. data/spec/models/v2_device_spec.rb +70 -0
  168. data/spec/models/v2_dosage_spec.rb +70 -0
  169. data/spec/models/v2_medication_administration_spec.rb +76 -0
  170. data/spec/models/v2_medication_spec.rb +46 -0
  171. data/spec/models/visit_company_spec.rb +52 -0
  172. data/spec/models/visit_guarantor_employer_spec.rb +46 -0
  173. data/spec/models/visit_guarantor_spec.rb +104 -0
  174. data/spec/models/visit_insurances_spec.rb +112 -0
  175. data/spec/models/visit_insured_spec.rb +78 -0
  176. data/spec/models/visit_plan_spec.rb +46 -0
  177. data/spec/models/visit_spec.rb +88 -0
  178. data/spec/spec_helper.rb +1 -1
  179. metadata +228 -7
  180. data/Gemfile.lock +0 -74
@@ -0,0 +1,327 @@
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 Meta
18
+ attr_accessor :event_type
19
+
20
+ attr_accessor :event_date_and_time
21
+
22
+ attr_accessor :test
23
+
24
+ attr_accessor :source
25
+
26
+ attr_accessor :destinations
27
+
28
+ attr_accessor :message
29
+
30
+ attr_accessor :transmission
31
+
32
+ attr_accessor :facility_code
33
+
34
+ # Arbitrary key/value pairs to store with the Order
35
+ attr_accessor :echo
36
+
37
+ class EnumAttributeValidator
38
+ attr_reader :datatype
39
+ attr_reader :allowable_values
40
+
41
+ def initialize(datatype, allowable_values)
42
+ @allowable_values = allowable_values.map do |value|
43
+ case datatype.to_s
44
+ when /Integer/i
45
+ value.to_i
46
+ when /Float/i
47
+ value.to_f
48
+ else
49
+ value
50
+ end
51
+ end
52
+ end
53
+
54
+ def valid?(value)
55
+ !value || allowable_values.include?(value)
56
+ end
57
+ end
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'event_type' => :'eventType',
63
+ :'event_date_and_time' => :'eventDateAndTime',
64
+ :'test' => :'test',
65
+ :'source' => :'source',
66
+ :'destinations' => :'destinations',
67
+ :'message' => :'message',
68
+ :'transmission' => :'transmission',
69
+ :'facility_code' => :'facilityCode',
70
+ :'echo' => :'echo'
71
+ }
72
+ end
73
+
74
+ # Returns all the JSON keys this model knows about
75
+ def self.acceptable_attributes
76
+ attribute_map.values
77
+ end
78
+
79
+ # Attribute type mapping.
80
+ def self.openapi_types
81
+ {
82
+ :'event_type' => :'String',
83
+ :'event_date_and_time' => :'Time',
84
+ :'test' => :'Boolean',
85
+ :'source' => :'MetaSource',
86
+ :'destinations' => :'Array<MetaDestinations>',
87
+ :'message' => :'MetaMessage',
88
+ :'transmission' => :'MetaTransmission',
89
+ :'facility_code' => :'String',
90
+ :'echo' => :'Object'
91
+ }
92
+ end
93
+
94
+ # List of attributes with nullable: true
95
+ def self.openapi_nullable
96
+ Set.new([
97
+ ])
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::Meta` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ attributes = attributes.each_with_object({}) { |(k, v), h|
109
+ if (!self.class.attribute_map.key?(k.to_sym))
110
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::Meta`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
111
+ end
112
+ h[k.to_sym] = v
113
+ }
114
+
115
+ if attributes.key?(:'event_type')
116
+ self.event_type = attributes[:'event_type']
117
+ end
118
+
119
+ if attributes.key?(:'event_date_and_time')
120
+ self.event_date_and_time = attributes[:'event_date_and_time']
121
+ end
122
+
123
+ if attributes.key?(:'test')
124
+ self.test = attributes[:'test']
125
+ end
126
+
127
+ if attributes.key?(:'source')
128
+ self.source = attributes[:'source']
129
+ end
130
+
131
+ if attributes.key?(:'destinations')
132
+ if (value = attributes[:'destinations']).is_a?(Array)
133
+ self.destinations = value
134
+ end
135
+ end
136
+
137
+ if attributes.key?(:'message')
138
+ self.message = attributes[:'message']
139
+ end
140
+
141
+ if attributes.key?(:'transmission')
142
+ self.transmission = attributes[:'transmission']
143
+ end
144
+
145
+ if attributes.key?(:'facility_code')
146
+ self.facility_code = attributes[:'facility_code']
147
+ end
148
+
149
+ if attributes.key?(:'echo')
150
+ self.echo = attributes[:'echo']
151
+ end
152
+ end
153
+
154
+ # Show invalid properties with the reasons. Usually used together with valid?
155
+ # @return Array for valid properties with the reasons
156
+ def list_invalid_properties
157
+ invalid_properties = Array.new
158
+ invalid_properties
159
+ end
160
+
161
+ # Check to see if the all the properties in the model are valid
162
+ # @return true if the model is valid
163
+ def valid?
164
+ event_type_validator = EnumAttributeValidator.new('String', ["EVENT_TYPE_UNKNOWN", "EVENT_TYPE_NEW_UNSOLICITED", "EVENT_TYPE_UPDATE", "EVENT_TYPE_CANCEL", "EVENT_TYPE_QUERY", "EVENT_TYPE_NEW"])
165
+ return false unless event_type_validator.valid?(@event_type)
166
+ true
167
+ end
168
+
169
+ # Custom attribute writer method checking allowed values (enum).
170
+ # @param [Object] event_type Object to be assigned
171
+ def event_type=(event_type)
172
+ validator = EnumAttributeValidator.new('String', ["EVENT_TYPE_UNKNOWN", "EVENT_TYPE_NEW_UNSOLICITED", "EVENT_TYPE_UPDATE", "EVENT_TYPE_CANCEL", "EVENT_TYPE_QUERY", "EVENT_TYPE_NEW"])
173
+ unless validator.valid?(event_type)
174
+ fail ArgumentError, "invalid value for \"event_type\", must be one of #{validator.allowable_values}."
175
+ end
176
+ @event_type = event_type
177
+ end
178
+
179
+ # Checks equality by comparing each attribute.
180
+ # @param [Object] Object to be compared
181
+ def ==(o)
182
+ return true if self.equal?(o)
183
+ self.class == o.class &&
184
+ event_type == o.event_type &&
185
+ event_date_and_time == o.event_date_and_time &&
186
+ test == o.test &&
187
+ source == o.source &&
188
+ destinations == o.destinations &&
189
+ message == o.message &&
190
+ transmission == o.transmission &&
191
+ facility_code == o.facility_code &&
192
+ echo == o.echo
193
+ end
194
+
195
+ # @see the `==` method
196
+ # @param [Object] Object to be compared
197
+ def eql?(o)
198
+ self == o
199
+ end
200
+
201
+ # Calculates hash code according to all attributes.
202
+ # @return [Integer] Hash code
203
+ def hash
204
+ [event_type, event_date_and_time, test, source, destinations, message, transmission, facility_code, echo].hash
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
210
+ def self.build_from_hash(attributes)
211
+ new.build_from_hash(attributes)
212
+ end
213
+
214
+ # Builds the object from hash
215
+ # @param [Hash] attributes Model attributes in the form of hash
216
+ # @return [Object] Returns the model itself
217
+ def build_from_hash(attributes)
218
+ return nil unless attributes.is_a?(Hash)
219
+ self.class.openapi_types.each_pair do |key, type|
220
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
221
+ self.send("#{key}=", nil)
222
+ elsif type =~ /\AArray<(.*)>/i
223
+ # check to ensure the input is an array given that the attribute
224
+ # is documented as an array but the input is not
225
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
226
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
227
+ end
228
+ elsif !attributes[self.class.attribute_map[key]].nil?
229
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
230
+ end
231
+ end
232
+
233
+ self
234
+ end
235
+
236
+ # Deserializes the data based on type
237
+ # @param string type Data type
238
+ # @param string value Value to be deserialized
239
+ # @return [Object] Deserialized data
240
+ def _deserialize(type, value)
241
+ case type.to_sym
242
+ when :Time
243
+ Time.parse(value)
244
+ when :Date
245
+ Date.parse(value)
246
+ when :String
247
+ value.to_s
248
+ when :Integer
249
+ value.to_i
250
+ when :Float
251
+ value.to_f
252
+ when :Boolean
253
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
254
+ true
255
+ else
256
+ false
257
+ end
258
+ when :Object
259
+ # generic object (usually a Hash), return directly
260
+ value
261
+ when /\AArray<(?<inner_type>.+)>\z/
262
+ inner_type = Regexp.last_match[:inner_type]
263
+ value.map { |v| _deserialize(inner_type, v) }
264
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
265
+ k_type = Regexp.last_match[:k_type]
266
+ v_type = Regexp.last_match[:v_type]
267
+ {}.tap do |hash|
268
+ value.each do |k, v|
269
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
270
+ end
271
+ end
272
+ else # model
273
+ # models (e.g. Pet) or oneOf
274
+ klass = PrimaryConnectClient.const_get(type)
275
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
276
+ end
277
+ end
278
+
279
+ # Returns the string representation of the object
280
+ # @return [String] String presentation of the object
281
+ def to_s
282
+ to_hash.to_s
283
+ end
284
+
285
+ # to_body is an alias to to_hash (backward compatibility)
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_body
288
+ to_hash
289
+ end
290
+
291
+ # Returns the object in the form of hash
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_hash
294
+ hash = {}
295
+ self.class.attribute_map.each_pair do |attr, param|
296
+ value = self.send(attr)
297
+ if value.nil?
298
+ is_nullable = self.class.openapi_nullable.include?(attr)
299
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
300
+ end
301
+
302
+ hash[param] = _to_hash(value)
303
+ end
304
+ hash
305
+ end
306
+
307
+ # Outputs non-array value in the form of hash
308
+ # For object, use to_hash. Otherwise, just return the value
309
+ # @param [Object] value Any valid value
310
+ # @return [Hash] Returns the value in the form of hash
311
+ def _to_hash(value)
312
+ if value.is_a?(Array)
313
+ value.compact.map { |v| _to_hash(v) }
314
+ elsif value.is_a?(Hash)
315
+ {}.tap do |hash|
316
+ value.each { |k, v| hash[k] = _to_hash(v) }
317
+ end
318
+ elsif value.respond_to? :to_hash
319
+ value.to_hash
320
+ else
321
+ value
322
+ end
323
+ end
324
+
325
+ end
326
+
327
+ end
@@ -0,0 +1,242 @@
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 MetaDestinations
18
+ attr_accessor :id
19
+
20
+ attr_accessor :name
21
+
22
+ # Arbitrary key/value pairs for Lab specific use
23
+ attr_accessor :config
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'id' => :'id',
29
+ :'name' => :'name',
30
+ :'config' => :'config'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'id' => :'String',
43
+ :'name' => :'String',
44
+ :'config' => :'Object'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::MetaDestinations` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::MetaDestinations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'id')
70
+ self.id = attributes[:'id']
71
+ end
72
+
73
+ if attributes.key?(:'name')
74
+ self.name = attributes[:'name']
75
+ end
76
+
77
+ if attributes.key?(:'config')
78
+ self.config = attributes[:'config']
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ invalid_properties = Array.new
86
+ if @id.nil?
87
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
88
+ end
89
+
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ return false if @id.nil?
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ id == o.id &&
106
+ name == o.name &&
107
+ config == o.config
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [id, name, config].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ new.build_from_hash(attributes)
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ self.class.openapi_types.each_pair do |key, type|
135
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
136
+ self.send("#{key}=", nil)
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ # models (e.g. Pet) or oneOf
189
+ klass = PrimaryConnectClient.const_get(type)
190
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+ end
241
+
242
+ end