primary_connect_client 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,239 +0,0 @@
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 OrderOrderSpecimen
18
- # ID of the collected specimen
19
- attr_accessor :id
20
-
21
- # Source of the specimen
22
- attr_accessor :source
23
-
24
- # Body site from which the specimen was collected
25
- attr_accessor :body_site
26
-
27
- # Attribute mapping from ruby-style variable name to JSON key.
28
- def self.attribute_map
29
- {
30
- :'id' => :'id',
31
- :'source' => :'source',
32
- :'body_site' => :'body_site'
33
- }
34
- end
35
-
36
- # Returns all the JSON keys this model knows about
37
- def self.acceptable_attributes
38
- attribute_map.values
39
- end
40
-
41
- # Attribute type mapping.
42
- def self.openapi_types
43
- {
44
- :'id' => :'String',
45
- :'source' => :'String',
46
- :'body_site' => :'String'
47
- }
48
- end
49
-
50
- # List of attributes with nullable: true
51
- def self.openapi_nullable
52
- Set.new([
53
- ])
54
- end
55
-
56
- # Initializes the object
57
- # @param [Hash] attributes Model attributes in the form of hash
58
- def initialize(attributes = {})
59
- if (!attributes.is_a?(Hash))
60
- fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::OrderOrderSpecimen` initialize method"
61
- end
62
-
63
- # check to see if the attribute exists and convert string to symbol for hash key
64
- attributes = attributes.each_with_object({}) { |(k, v), h|
65
- if (!self.class.attribute_map.key?(k.to_sym))
66
- fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::OrderOrderSpecimen`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
- end
68
- h[k.to_sym] = v
69
- }
70
-
71
- if attributes.key?(:'id')
72
- self.id = attributes[:'id']
73
- end
74
-
75
- if attributes.key?(:'source')
76
- self.source = attributes[:'source']
77
- end
78
-
79
- if attributes.key?(:'body_site')
80
- self.body_site = attributes[:'body_site']
81
- end
82
- end
83
-
84
- # Show invalid properties with the reasons. Usually used together with valid?
85
- # @return Array for valid properties with the reasons
86
- def list_invalid_properties
87
- invalid_properties = Array.new
88
- invalid_properties
89
- end
90
-
91
- # Check to see if the all the properties in the model are valid
92
- # @return true if the model is valid
93
- def valid?
94
- true
95
- end
96
-
97
- # Checks equality by comparing each attribute.
98
- # @param [Object] Object to be compared
99
- def ==(o)
100
- return true if self.equal?(o)
101
- self.class == o.class &&
102
- id == o.id &&
103
- source == o.source &&
104
- body_site == o.body_site
105
- end
106
-
107
- # @see the `==` method
108
- # @param [Object] Object to be compared
109
- def eql?(o)
110
- self == o
111
- end
112
-
113
- # Calculates hash code according to all attributes.
114
- # @return [Integer] Hash code
115
- def hash
116
- [id, source, body_site].hash
117
- end
118
-
119
- # Builds the object from hash
120
- # @param [Hash] attributes Model attributes in the form of hash
121
- # @return [Object] Returns the model itself
122
- def self.build_from_hash(attributes)
123
- new.build_from_hash(attributes)
124
- end
125
-
126
- # Builds the object from hash
127
- # @param [Hash] attributes Model attributes in the form of hash
128
- # @return [Object] Returns the model itself
129
- def build_from_hash(attributes)
130
- return nil unless attributes.is_a?(Hash)
131
- self.class.openapi_types.each_pair do |key, type|
132
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
- self.send("#{key}=", nil)
134
- elsif type =~ /\AArray<(.*)>/i
135
- # check to ensure the input is an array given that the attribute
136
- # is documented as an array but the input is not
137
- if attributes[self.class.attribute_map[key]].is_a?(Array)
138
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
- end
140
- elsif !attributes[self.class.attribute_map[key]].nil?
141
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
- end
143
- end
144
-
145
- self
146
- end
147
-
148
- # Deserializes the data based on type
149
- # @param string type Data type
150
- # @param string value Value to be deserialized
151
- # @return [Object] Deserialized data
152
- def _deserialize(type, value)
153
- case type.to_sym
154
- when :Time
155
- Time.parse(value)
156
- when :Date
157
- Date.parse(value)
158
- when :String
159
- value.to_s
160
- when :Integer
161
- value.to_i
162
- when :Float
163
- value.to_f
164
- when :Boolean
165
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
- true
167
- else
168
- false
169
- end
170
- when :Object
171
- # generic object (usually a Hash), return directly
172
- value
173
- when /\AArray<(?<inner_type>.+)>\z/
174
- inner_type = Regexp.last_match[:inner_type]
175
- value.map { |v| _deserialize(inner_type, v) }
176
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
- k_type = Regexp.last_match[:k_type]
178
- v_type = Regexp.last_match[:v_type]
179
- {}.tap do |hash|
180
- value.each do |k, v|
181
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
- end
183
- end
184
- else # model
185
- # models (e.g. Pet) or oneOf
186
- klass = PrimaryConnectClient.const_get(type)
187
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
- end
189
- end
190
-
191
- # Returns the string representation of the object
192
- # @return [String] String presentation of the object
193
- def to_s
194
- to_hash.to_s
195
- end
196
-
197
- # to_body is an alias to to_hash (backward compatibility)
198
- # @return [Hash] Returns the object in the form of hash
199
- def to_body
200
- to_hash
201
- end
202
-
203
- # Returns the object in the form of hash
204
- # @return [Hash] Returns the object in the form of hash
205
- def to_hash
206
- hash = {}
207
- self.class.attribute_map.each_pair do |attr, param|
208
- value = self.send(attr)
209
- if value.nil?
210
- is_nullable = self.class.openapi_nullable.include?(attr)
211
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
- end
213
-
214
- hash[param] = _to_hash(value)
215
- end
216
- hash
217
- end
218
-
219
- # Outputs non-array value in the form of hash
220
- # For object, use to_hash. Otherwise, just return the value
221
- # @param [Object] value Any valid value
222
- # @return [Hash] Returns the value in the form of hash
223
- def _to_hash(value)
224
- if value.is_a?(Array)
225
- value.compact.map { |v| _to_hash(v) }
226
- elsif value.is_a?(Hash)
227
- {}.tap do |hash|
228
- value.each { |k, v| hash[k] = _to_hash(v) }
229
- end
230
- elsif value.respond_to? :to_hash
231
- value.to_hash
232
- else
233
- value
234
- end
235
- end
236
-
237
- end
238
-
239
- end
@@ -1,466 +0,0 @@
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 PatientDemographics
18
- attr_accessor :name
19
-
20
- attr_accessor :dob
21
-
22
- attr_accessor :ssn
23
-
24
- attr_accessor :sex
25
-
26
- attr_accessor :gender
27
-
28
- attr_accessor :sexual_orientation
29
-
30
- attr_accessor :races
31
-
32
- attr_accessor :race_details
33
-
34
- attr_accessor :ethnicity
35
-
36
- attr_accessor :ethnicity_detail
37
-
38
- attr_accessor :marital_status
39
-
40
- attr_accessor :is_deceased
41
-
42
- # ISO 8601
43
- attr_accessor :death_date_time
44
-
45
- attr_accessor :phone_numbers
46
-
47
- attr_accessor :email_addresses
48
-
49
- attr_accessor :language_code
50
-
51
- attr_accessor :citizenships
52
-
53
- attr_accessor :address
54
-
55
- class EnumAttributeValidator
56
- attr_reader :datatype
57
- attr_reader :allowable_values
58
-
59
- def initialize(datatype, allowable_values)
60
- @allowable_values = allowable_values.map do |value|
61
- case datatype.to_s
62
- when /Integer/i
63
- value.to_i
64
- when /Float/i
65
- value.to_f
66
- else
67
- value
68
- end
69
- end
70
- end
71
-
72
- def valid?(value)
73
- !value || allowable_values.include?(value)
74
- end
75
- end
76
-
77
- # Attribute mapping from ruby-style variable name to JSON key.
78
- def self.attribute_map
79
- {
80
- :'name' => :'name',
81
- :'dob' => :'dob',
82
- :'ssn' => :'ssn',
83
- :'sex' => :'sex',
84
- :'gender' => :'gender',
85
- :'sexual_orientation' => :'sexual_orientation',
86
- :'races' => :'races',
87
- :'race_details' => :'race_details',
88
- :'ethnicity' => :'ethnicity',
89
- :'ethnicity_detail' => :'ethnicity_detail',
90
- :'marital_status' => :'marital_status',
91
- :'is_deceased' => :'is_deceased',
92
- :'death_date_time' => :'death_date_time',
93
- :'phone_numbers' => :'phone_numbers',
94
- :'email_addresses' => :'email_addresses',
95
- :'language_code' => :'language_code',
96
- :'citizenships' => :'citizenships',
97
- :'address' => :'address'
98
- }
99
- end
100
-
101
- # Returns all the JSON keys this model knows about
102
- def self.acceptable_attributes
103
- attribute_map.values
104
- end
105
-
106
- # Attribute type mapping.
107
- def self.openapi_types
108
- {
109
- :'name' => :'Name',
110
- :'dob' => :'String',
111
- :'ssn' => :'String',
112
- :'sex' => :'String',
113
- :'gender' => :'String',
114
- :'sexual_orientation' => :'String',
115
- :'races' => :'Array<String>',
116
- :'race_details' => :'Array<String>',
117
- :'ethnicity' => :'String',
118
- :'ethnicity_detail' => :'Array<String>',
119
- :'marital_status' => :'String',
120
- :'is_deceased' => :'Boolean',
121
- :'death_date_time' => :'Time',
122
- :'phone_numbers' => :'Array<PhoneNumber>',
123
- :'email_addresses' => :'Array<String>',
124
- :'language_code' => :'String',
125
- :'citizenships' => :'Array<String>',
126
- :'address' => :'Address'
127
- }
128
- end
129
-
130
- # List of attributes with nullable: true
131
- def self.openapi_nullable
132
- Set.new([
133
- ])
134
- end
135
-
136
- # Initializes the object
137
- # @param [Hash] attributes Model attributes in the form of hash
138
- def initialize(attributes = {})
139
- if (!attributes.is_a?(Hash))
140
- fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::PatientDemographics` initialize method"
141
- end
142
-
143
- # check to see if the attribute exists and convert string to symbol for hash key
144
- attributes = attributes.each_with_object({}) { |(k, v), h|
145
- if (!self.class.attribute_map.key?(k.to_sym))
146
- fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::PatientDemographics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
147
- end
148
- h[k.to_sym] = v
149
- }
150
-
151
- if attributes.key?(:'name')
152
- self.name = attributes[:'name']
153
- end
154
-
155
- if attributes.key?(:'dob')
156
- self.dob = attributes[:'dob']
157
- end
158
-
159
- if attributes.key?(:'ssn')
160
- self.ssn = attributes[:'ssn']
161
- end
162
-
163
- if attributes.key?(:'sex')
164
- self.sex = attributes[:'sex']
165
- end
166
-
167
- if attributes.key?(:'gender')
168
- self.gender = attributes[:'gender']
169
- end
170
-
171
- if attributes.key?(:'sexual_orientation')
172
- self.sexual_orientation = attributes[:'sexual_orientation']
173
- end
174
-
175
- if attributes.key?(:'races')
176
- if (value = attributes[:'races']).is_a?(Array)
177
- self.races = value
178
- end
179
- end
180
-
181
- if attributes.key?(:'race_details')
182
- if (value = attributes[:'race_details']).is_a?(Array)
183
- self.race_details = value
184
- end
185
- end
186
-
187
- if attributes.key?(:'ethnicity')
188
- self.ethnicity = attributes[:'ethnicity']
189
- end
190
-
191
- if attributes.key?(:'ethnicity_detail')
192
- if (value = attributes[:'ethnicity_detail']).is_a?(Array)
193
- self.ethnicity_detail = value
194
- end
195
- end
196
-
197
- if attributes.key?(:'marital_status')
198
- self.marital_status = attributes[:'marital_status']
199
- end
200
-
201
- if attributes.key?(:'is_deceased')
202
- self.is_deceased = attributes[:'is_deceased']
203
- end
204
-
205
- if attributes.key?(:'death_date_time')
206
- self.death_date_time = attributes[:'death_date_time']
207
- end
208
-
209
- if attributes.key?(:'phone_numbers')
210
- if (value = attributes[:'phone_numbers']).is_a?(Array)
211
- self.phone_numbers = value
212
- end
213
- end
214
-
215
- if attributes.key?(:'email_addresses')
216
- if (value = attributes[:'email_addresses']).is_a?(Array)
217
- self.email_addresses = value
218
- end
219
- end
220
-
221
- if attributes.key?(:'language_code')
222
- self.language_code = attributes[:'language_code']
223
- end
224
-
225
- if attributes.key?(:'citizenships')
226
- if (value = attributes[:'citizenships']).is_a?(Array)
227
- self.citizenships = value
228
- end
229
- end
230
-
231
- if attributes.key?(:'address')
232
- self.address = attributes[:'address']
233
- end
234
- end
235
-
236
- # Show invalid properties with the reasons. Usually used together with valid?
237
- # @return Array for valid properties with the reasons
238
- def list_invalid_properties
239
- invalid_properties = Array.new
240
- invalid_properties
241
- end
242
-
243
- # Check to see if the all the properties in the model are valid
244
- # @return true if the model is valid
245
- def valid?
246
- sex_validator = EnumAttributeValidator.new('String', ["SEX_UNKNOWN", "SEX_FEMALE", "SEX_MALE", "SEX_OTHER", "SEX_NON_BINARY", "SEX_PREFER_NOT_TO_DISCLOSE"])
247
- return false unless sex_validator.valid?(@sex)
248
- gender_validator = EnumAttributeValidator.new('String', ["GENDER_UNKNOWN", "GENDER_FEMALE", "GENDER_MALE", "GENDER_OTHER", "GENDER_NON_BINARY", "GENDER_TRANSGENDER_MALE", "GENDER_TRANSGENDER_FEMALE", "GENDER_PREFER_NOT_TO_DISCLOSE"])
249
- return false unless gender_validator.valid?(@gender)
250
- sexual_orientation_validator = EnumAttributeValidator.new('String', ["ORIENTATION_UNKNOWN", "ORIENTATION_HOMOSEXUAL", "ORIENTATION_HETEROSEXUAL", "ORIENTATION_BISEXUAL", "ORIENTATION_QUESTIONING", "ORIENTATION_OTHER", "ORIENTATION_PREFER_NOT_TO_DISCLOSE"])
251
- return false unless sexual_orientation_validator.valid?(@sexual_orientation)
252
- ethnicity_validator = EnumAttributeValidator.new('String', ["ETHNICITY_UNKNOWN", "ETHNICITY_HISPANIC", "ETHNICITY_NON_HISPANIC", "ETHNICITY_PREFER_NOT_TO_DISCLOSE"])
253
- return false unless ethnicity_validator.valid?(@ethnicity)
254
- marital_status_validator = EnumAttributeValidator.new('String', ["MARITAL_STATUS_UNKNOWN", "MARITAL_STATUS_SEPARATED", "MARITAL_STATUS_UNMARRIED", "MARITAL_STATUS_COMMON_LAW", "MARITAL_STATUS_DIVORCED", "MARITAL_STATUS_LEGALLY_SEPARATED", "MARITAL_STATUS_LIVING_TOGETHER", "MARITAL_STATUS_INTERLOCUTORY", "MARITAL_STATUS_MARRIED", "MARITAL_STATUS_ANNULLED", "MARITAL_STATUS_OTHER", "MARITAL_STATUS_DOMESTIC_PARTNER", "MARITAL_STATUS_REGISTERED_DOMESTIC_PARTNER", "MARITAL_STATUS_SINGLE", "MARITAL_STATUS_UNREPORTED", "MARITAL_STATUS_WIDOWED"])
255
- return false unless marital_status_validator.valid?(@marital_status)
256
- true
257
- end
258
-
259
- # Custom attribute writer method checking allowed values (enum).
260
- # @param [Object] sex Object to be assigned
261
- def sex=(sex)
262
- validator = EnumAttributeValidator.new('String', ["SEX_UNKNOWN", "SEX_FEMALE", "SEX_MALE", "SEX_OTHER", "SEX_NON_BINARY", "SEX_PREFER_NOT_TO_DISCLOSE"])
263
- unless validator.valid?(sex)
264
- fail ArgumentError, "invalid value for \"sex\", must be one of #{validator.allowable_values}."
265
- end
266
- @sex = sex
267
- end
268
-
269
- # Custom attribute writer method checking allowed values (enum).
270
- # @param [Object] gender Object to be assigned
271
- def gender=(gender)
272
- validator = EnumAttributeValidator.new('String', ["GENDER_UNKNOWN", "GENDER_FEMALE", "GENDER_MALE", "GENDER_OTHER", "GENDER_NON_BINARY", "GENDER_TRANSGENDER_MALE", "GENDER_TRANSGENDER_FEMALE", "GENDER_PREFER_NOT_TO_DISCLOSE"])
273
- unless validator.valid?(gender)
274
- fail ArgumentError, "invalid value for \"gender\", must be one of #{validator.allowable_values}."
275
- end
276
- @gender = gender
277
- end
278
-
279
- # Custom attribute writer method checking allowed values (enum).
280
- # @param [Object] sexual_orientation Object to be assigned
281
- def sexual_orientation=(sexual_orientation)
282
- validator = EnumAttributeValidator.new('String', ["ORIENTATION_UNKNOWN", "ORIENTATION_HOMOSEXUAL", "ORIENTATION_HETEROSEXUAL", "ORIENTATION_BISEXUAL", "ORIENTATION_QUESTIONING", "ORIENTATION_OTHER", "ORIENTATION_PREFER_NOT_TO_DISCLOSE"])
283
- unless validator.valid?(sexual_orientation)
284
- fail ArgumentError, "invalid value for \"sexual_orientation\", must be one of #{validator.allowable_values}."
285
- end
286
- @sexual_orientation = sexual_orientation
287
- end
288
-
289
- # Custom attribute writer method checking allowed values (enum).
290
- # @param [Object] ethnicity Object to be assigned
291
- def ethnicity=(ethnicity)
292
- validator = EnumAttributeValidator.new('String', ["ETHNICITY_UNKNOWN", "ETHNICITY_HISPANIC", "ETHNICITY_NON_HISPANIC", "ETHNICITY_PREFER_NOT_TO_DISCLOSE"])
293
- unless validator.valid?(ethnicity)
294
- fail ArgumentError, "invalid value for \"ethnicity\", must be one of #{validator.allowable_values}."
295
- end
296
- @ethnicity = ethnicity
297
- end
298
-
299
- # Custom attribute writer method checking allowed values (enum).
300
- # @param [Object] marital_status Object to be assigned
301
- def marital_status=(marital_status)
302
- validator = EnumAttributeValidator.new('String', ["MARITAL_STATUS_UNKNOWN", "MARITAL_STATUS_SEPARATED", "MARITAL_STATUS_UNMARRIED", "MARITAL_STATUS_COMMON_LAW", "MARITAL_STATUS_DIVORCED", "MARITAL_STATUS_LEGALLY_SEPARATED", "MARITAL_STATUS_LIVING_TOGETHER", "MARITAL_STATUS_INTERLOCUTORY", "MARITAL_STATUS_MARRIED", "MARITAL_STATUS_ANNULLED", "MARITAL_STATUS_OTHER", "MARITAL_STATUS_DOMESTIC_PARTNER", "MARITAL_STATUS_REGISTERED_DOMESTIC_PARTNER", "MARITAL_STATUS_SINGLE", "MARITAL_STATUS_UNREPORTED", "MARITAL_STATUS_WIDOWED"])
303
- unless validator.valid?(marital_status)
304
- fail ArgumentError, "invalid value for \"marital_status\", must be one of #{validator.allowable_values}."
305
- end
306
- @marital_status = marital_status
307
- end
308
-
309
- # Checks equality by comparing each attribute.
310
- # @param [Object] Object to be compared
311
- def ==(o)
312
- return true if self.equal?(o)
313
- self.class == o.class &&
314
- name == o.name &&
315
- dob == o.dob &&
316
- ssn == o.ssn &&
317
- sex == o.sex &&
318
- gender == o.gender &&
319
- sexual_orientation == o.sexual_orientation &&
320
- races == o.races &&
321
- race_details == o.race_details &&
322
- ethnicity == o.ethnicity &&
323
- ethnicity_detail == o.ethnicity_detail &&
324
- marital_status == o.marital_status &&
325
- is_deceased == o.is_deceased &&
326
- death_date_time == o.death_date_time &&
327
- phone_numbers == o.phone_numbers &&
328
- email_addresses == o.email_addresses &&
329
- language_code == o.language_code &&
330
- citizenships == o.citizenships &&
331
- address == o.address
332
- end
333
-
334
- # @see the `==` method
335
- # @param [Object] Object to be compared
336
- def eql?(o)
337
- self == o
338
- end
339
-
340
- # Calculates hash code according to all attributes.
341
- # @return [Integer] Hash code
342
- def hash
343
- [name, dob, ssn, sex, gender, sexual_orientation, races, race_details, ethnicity, ethnicity_detail, marital_status, is_deceased, death_date_time, phone_numbers, email_addresses, language_code, citizenships, address].hash
344
- end
345
-
346
- # Builds the object from hash
347
- # @param [Hash] attributes Model attributes in the form of hash
348
- # @return [Object] Returns the model itself
349
- def self.build_from_hash(attributes)
350
- new.build_from_hash(attributes)
351
- end
352
-
353
- # Builds the object from hash
354
- # @param [Hash] attributes Model attributes in the form of hash
355
- # @return [Object] Returns the model itself
356
- def build_from_hash(attributes)
357
- return nil unless attributes.is_a?(Hash)
358
- self.class.openapi_types.each_pair do |key, type|
359
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
360
- self.send("#{key}=", nil)
361
- elsif type =~ /\AArray<(.*)>/i
362
- # check to ensure the input is an array given that the attribute
363
- # is documented as an array but the input is not
364
- if attributes[self.class.attribute_map[key]].is_a?(Array)
365
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
366
- end
367
- elsif !attributes[self.class.attribute_map[key]].nil?
368
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
369
- end
370
- end
371
-
372
- self
373
- end
374
-
375
- # Deserializes the data based on type
376
- # @param string type Data type
377
- # @param string value Value to be deserialized
378
- # @return [Object] Deserialized data
379
- def _deserialize(type, value)
380
- case type.to_sym
381
- when :Time
382
- Time.parse(value)
383
- when :Date
384
- Date.parse(value)
385
- when :String
386
- value.to_s
387
- when :Integer
388
- value.to_i
389
- when :Float
390
- value.to_f
391
- when :Boolean
392
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
393
- true
394
- else
395
- false
396
- end
397
- when :Object
398
- # generic object (usually a Hash), return directly
399
- value
400
- when /\AArray<(?<inner_type>.+)>\z/
401
- inner_type = Regexp.last_match[:inner_type]
402
- value.map { |v| _deserialize(inner_type, v) }
403
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
404
- k_type = Regexp.last_match[:k_type]
405
- v_type = Regexp.last_match[:v_type]
406
- {}.tap do |hash|
407
- value.each do |k, v|
408
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
409
- end
410
- end
411
- else # model
412
- # models (e.g. Pet) or oneOf
413
- klass = PrimaryConnectClient.const_get(type)
414
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
415
- end
416
- end
417
-
418
- # Returns the string representation of the object
419
- # @return [String] String presentation of the object
420
- def to_s
421
- to_hash.to_s
422
- end
423
-
424
- # to_body is an alias to to_hash (backward compatibility)
425
- # @return [Hash] Returns the object in the form of hash
426
- def to_body
427
- to_hash
428
- end
429
-
430
- # Returns the object in the form of hash
431
- # @return [Hash] Returns the object in the form of hash
432
- def to_hash
433
- hash = {}
434
- self.class.attribute_map.each_pair do |attr, param|
435
- value = self.send(attr)
436
- if value.nil?
437
- is_nullable = self.class.openapi_nullable.include?(attr)
438
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
439
- end
440
-
441
- hash[param] = _to_hash(value)
442
- end
443
- hash
444
- end
445
-
446
- # Outputs non-array value in the form of hash
447
- # For object, use to_hash. Otherwise, just return the value
448
- # @param [Object] value Any valid value
449
- # @return [Hash] Returns the value in the form of hash
450
- def _to_hash(value)
451
- if value.is_a?(Array)
452
- value.compact.map { |v| _to_hash(v) }
453
- elsif value.is_a?(Hash)
454
- {}.tap do |hash|
455
- value.each { |k, v| hash[k] = _to_hash(v) }
456
- end
457
- elsif value.respond_to? :to_hash
458
- value.to_hash
459
- else
460
- value
461
- end
462
- end
463
-
464
- end
465
-
466
- end