primary_connect_client 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +18 -7
  4. data/docs/Accession.md +18 -0
  5. data/docs/AccessionOrder.md +18 -0
  6. data/docs/DefaultApi.md +275 -0
  7. data/docs/Device.md +5 -3
  8. data/docs/Ids.md +18 -0
  9. data/docs/Measurement.md +22 -0
  10. data/docs/OrderOrder.md +4 -0
  11. data/docs/Result.md +3 -1
  12. data/docs/V2Device.md +5 -3
  13. data/lib/primary_connect_client/api/default_api.rb +249 -0
  14. data/lib/primary_connect_client/models/accession.rb +218 -0
  15. data/lib/primary_connect_client/models/accession_order.rb +219 -0
  16. data/lib/primary_connect_client/models/demographics.rb +2 -2
  17. data/lib/primary_connect_client/models/device.rb +21 -12
  18. data/lib/primary_connect_client/models/ids.rb +221 -0
  19. data/lib/primary_connect_client/models/measurement.rb +240 -0
  20. data/lib/primary_connect_client/models/order_order.rb +23 -1
  21. data/lib/primary_connect_client/models/result.rb +13 -4
  22. data/lib/primary_connect_client/models/v2_device.rb +21 -12
  23. data/lib/primary_connect_client/version.rb +1 -1
  24. data/lib/primary_connect_client.rb +4 -0
  25. data/primary_connect_client.gemspec +1 -1
  26. data/spec/api/default_api_spec.rb +45 -0
  27. data/spec/models/accession_order_spec.rb +34 -0
  28. data/spec/models/accession_spec.rb +34 -0
  29. data/spec/models/demographics_spec.rb +1 -1
  30. data/spec/models/device_spec.rb +7 -1
  31. data/spec/models/ids_spec.rb +34 -0
  32. data/spec/models/measurement_spec.rb +46 -0
  33. data/spec/models/order_order_spec.rb +12 -0
  34. data/spec/models/result_spec.rb +6 -0
  35. data/spec/models/v2_device_spec.rb +7 -1
  36. metadata +22 -6
@@ -19,6 +19,139 @@ module PrimaryConnectClient
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
+ # accession order by ULID
23
+ # @param id [String] Order ID
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [Accession] :accession
26
+ # @return [nil]
27
+ def accession_order(id, opts = {})
28
+ accession_order_with_http_info(id, opts)
29
+ nil
30
+ end
31
+
32
+ # accession order by ULID
33
+ # @param id [String] Order ID
34
+ # @param [Hash] opts the optional parameters
35
+ # @option opts [Accession] :accession
36
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
37
+ def accession_order_with_http_info(id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: DefaultApi.accession_order ...'
40
+ end
41
+ # verify the required parameter 'id' is set
42
+ if @api_client.config.client_side_validation && id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.accession_order"
44
+ end
45
+ # resource path
46
+ local_var_path = '/api/v1/orders/{id}/accession'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Content-Type'
54
+ content_type = @api_client.select_header_content_type(['application/json'])
55
+ if !content_type.nil?
56
+ header_params['Content-Type'] = content_type
57
+ end
58
+
59
+ # form parameters
60
+ form_params = opts[:form_params] || {}
61
+
62
+ # http body (model)
63
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'accession'])
64
+
65
+ # return_type
66
+ return_type = opts[:debug_return_type]
67
+
68
+ # auth_names
69
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
70
+
71
+ new_options = opts.merge(
72
+ :operation => :"DefaultApi.accession_order",
73
+ :header_params => header_params,
74
+ :query_params => query_params,
75
+ :form_params => form_params,
76
+ :body => post_body,
77
+ :auth_names => auth_names,
78
+ :return_type => return_type
79
+ )
80
+
81
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
82
+ if @api_client.config.debugging
83
+ @api_client.config.logger.debug "API called: DefaultApi#accession_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
84
+ end
85
+ return data, status_code, headers
86
+ end
87
+
88
+ # accession order by Specimen ID
89
+ # @param specimen_id [String] Specimen ID
90
+ # @param [Hash] opts the optional parameters
91
+ # @option opts [Accession] :accession
92
+ # @return [nil]
93
+ def accession_order_by_specimen_id(specimen_id, opts = {})
94
+ accession_order_by_specimen_id_with_http_info(specimen_id, opts)
95
+ nil
96
+ end
97
+
98
+ # accession order by Specimen ID
99
+ # @param specimen_id [String] Specimen ID
100
+ # @param [Hash] opts the optional parameters
101
+ # @option opts [Accession] :accession
102
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
103
+ def accession_order_by_specimen_id_with_http_info(specimen_id, opts = {})
104
+ if @api_client.config.debugging
105
+ @api_client.config.logger.debug 'Calling API: DefaultApi.accession_order_by_specimen_id ...'
106
+ end
107
+ # verify the required parameter 'specimen_id' is set
108
+ if @api_client.config.client_side_validation && specimen_id.nil?
109
+ fail ArgumentError, "Missing the required parameter 'specimen_id' when calling DefaultApi.accession_order_by_specimen_id"
110
+ end
111
+ # resource path
112
+ local_var_path = '/api/v1/orders/accession'
113
+
114
+ # query parameters
115
+ query_params = opts[:query_params] || {}
116
+ query_params[:'specimen_id'] = specimen_id
117
+
118
+ # header parameters
119
+ header_params = opts[:header_params] || {}
120
+ # HTTP header 'Content-Type'
121
+ content_type = @api_client.select_header_content_type(['application/json'])
122
+ if !content_type.nil?
123
+ header_params['Content-Type'] = content_type
124
+ end
125
+
126
+ # form parameters
127
+ form_params = opts[:form_params] || {}
128
+
129
+ # http body (model)
130
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'accession'])
131
+
132
+ # return_type
133
+ return_type = opts[:debug_return_type]
134
+
135
+ # auth_names
136
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
137
+
138
+ new_options = opts.merge(
139
+ :operation => :"DefaultApi.accession_order_by_specimen_id",
140
+ :header_params => header_params,
141
+ :query_params => query_params,
142
+ :form_params => form_params,
143
+ :body => post_body,
144
+ :auth_names => auth_names,
145
+ :return_type => return_type
146
+ )
147
+
148
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
149
+ if @api_client.config.debugging
150
+ @api_client.config.logger.debug "API called: DefaultApi#accession_order_by_specimen_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
151
+ end
152
+ return data, status_code, headers
153
+ end
154
+
22
155
  # cancel order
23
156
  # @param id [String] Order ID
24
157
  # @param [Hash] opts the optional parameters
@@ -80,6 +213,61 @@ module PrimaryConnectClient
80
213
  return data, status_code, headers
81
214
  end
82
215
 
216
+ # create Measurement
217
+ # @param [Hash] opts the optional parameters
218
+ # @return [Ids]
219
+ def create_measurement(opts = {})
220
+ data, _status_code, _headers = create_measurement_with_http_info(opts)
221
+ data
222
+ end
223
+
224
+ # create Measurement
225
+ # @param [Hash] opts the optional parameters
226
+ # @return [Array<(Ids, Integer, Hash)>] Ids data, response status code and response headers
227
+ def create_measurement_with_http_info(opts = {})
228
+ if @api_client.config.debugging
229
+ @api_client.config.logger.debug 'Calling API: DefaultApi.create_measurement ...'
230
+ end
231
+ # resource path
232
+ local_var_path = '/api/v1/measurements'
233
+
234
+ # query parameters
235
+ query_params = opts[:query_params] || {}
236
+
237
+ # header parameters
238
+ header_params = opts[:header_params] || {}
239
+ # HTTP header 'Accept' (if needed)
240
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
241
+
242
+ # form parameters
243
+ form_params = opts[:form_params] || {}
244
+
245
+ # http body (model)
246
+ post_body = opts[:debug_body]
247
+
248
+ # return_type
249
+ return_type = opts[:debug_return_type] || 'Ids'
250
+
251
+ # auth_names
252
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
253
+
254
+ new_options = opts.merge(
255
+ :operation => :"DefaultApi.create_measurement",
256
+ :header_params => header_params,
257
+ :query_params => query_params,
258
+ :form_params => form_params,
259
+ :body => post_body,
260
+ :auth_names => auth_names,
261
+ :return_type => return_type
262
+ )
263
+
264
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
265
+ if @api_client.config.debugging
266
+ @api_client.config.logger.debug "API called: DefaultApi#create_measurement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
267
+ end
268
+ return data, status_code, headers
269
+ end
270
+
83
271
  # create order
84
272
  # @param [Hash] opts the optional parameters
85
273
  # @option opts [Order] :order
@@ -271,6 +459,67 @@ module PrimaryConnectClient
271
459
  return data, status_code, headers
272
460
  end
273
461
 
462
+ # show measurement
463
+ # @param id [String] Measurement ID
464
+ # @param [Hash] opts the optional parameters
465
+ # @return [Measurement]
466
+ def get_measurement(id, opts = {})
467
+ data, _status_code, _headers = get_measurement_with_http_info(id, opts)
468
+ data
469
+ end
470
+
471
+ # show measurement
472
+ # @param id [String] Measurement ID
473
+ # @param [Hash] opts the optional parameters
474
+ # @return [Array<(Measurement, Integer, Hash)>] Measurement data, response status code and response headers
475
+ def get_measurement_with_http_info(id, opts = {})
476
+ if @api_client.config.debugging
477
+ @api_client.config.logger.debug 'Calling API: DefaultApi.get_measurement ...'
478
+ end
479
+ # verify the required parameter 'id' is set
480
+ if @api_client.config.client_side_validation && id.nil?
481
+ fail ArgumentError, "Missing the required parameter 'id' when calling DefaultApi.get_measurement"
482
+ end
483
+ # resource path
484
+ local_var_path = '/api/v1/measurements/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
485
+
486
+ # query parameters
487
+ query_params = opts[:query_params] || {}
488
+
489
+ # header parameters
490
+ header_params = opts[:header_params] || {}
491
+ # HTTP header 'Accept' (if needed)
492
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
493
+
494
+ # form parameters
495
+ form_params = opts[:form_params] || {}
496
+
497
+ # http body (model)
498
+ post_body = opts[:debug_body]
499
+
500
+ # return_type
501
+ return_type = opts[:debug_return_type] || 'Measurement'
502
+
503
+ # auth_names
504
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
505
+
506
+ new_options = opts.merge(
507
+ :operation => :"DefaultApi.get_measurement",
508
+ :header_params => header_params,
509
+ :query_params => query_params,
510
+ :form_params => form_params,
511
+ :body => post_body,
512
+ :auth_names => auth_names,
513
+ :return_type => return_type
514
+ )
515
+
516
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
517
+ if @api_client.config.debugging
518
+ @api_client.config.logger.debug "API called: DefaultApi#get_measurement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
519
+ end
520
+ return data, status_code, headers
521
+ end
522
+
274
523
  # show order
275
524
  # @param id [String] Order ID
276
525
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,218 @@
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 Accession
18
+ attr_accessor :order
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'order' => :'order'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'order' => :'AccessionOrder'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::Accession` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::Accession`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'order')
61
+ self.order = attributes[:'order']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ order == o.order
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [order].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.openapi_types.each_pair do |key, type|
111
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
112
+ self.send("#{key}=", nil)
113
+ elsif type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
117
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
118
+ end
119
+ elsif !attributes[self.class.attribute_map[key]].nil?
120
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
121
+ end
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :Time
134
+ Time.parse(value)
135
+ when :Date
136
+ Date.parse(value)
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :Boolean
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ # models (e.g. Pet) or oneOf
165
+ klass = PrimaryConnectClient.const_get(type)
166
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
167
+ end
168
+ end
169
+
170
+ # Returns the string representation of the object
171
+ # @return [String] String presentation of the object
172
+ def to_s
173
+ to_hash.to_s
174
+ end
175
+
176
+ # to_body is an alias to to_hash (backward compatibility)
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_body
179
+ to_hash
180
+ end
181
+
182
+ # Returns the object in the form of hash
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_hash
185
+ hash = {}
186
+ self.class.attribute_map.each_pair do |attr, param|
187
+ value = self.send(attr)
188
+ if value.nil?
189
+ is_nullable = self.class.openapi_nullable.include?(attr)
190
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
191
+ end
192
+
193
+ hash[param] = _to_hash(value)
194
+ end
195
+ hash
196
+ end
197
+
198
+ # Outputs non-array value in the form of hash
199
+ # For object, use to_hash. Otherwise, just return the value
200
+ # @param [Object] value Any valid value
201
+ # @return [Hash] Returns the value in the form of hash
202
+ def _to_hash(value)
203
+ if value.is_a?(Array)
204
+ value.compact.map { |v| _to_hash(v) }
205
+ elsif value.is_a?(Hash)
206
+ {}.tap do |hash|
207
+ value.each { |k, v| hash[k] = _to_hash(v) }
208
+ end
209
+ elsif value.respond_to? :to_hash
210
+ value.to_hash
211
+ else
212
+ value
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end
@@ -0,0 +1,219 @@
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 AccessionOrder
18
+ # Timestamp when the specimen was received by the destination. (ISO-8601)
19
+ attr_accessor :accession_date_time
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'accession_date_time' => :'accessionDateTime'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'accession_date_time' => :'Time'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PrimaryConnectClient::AccessionOrder` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PrimaryConnectClient::AccessionOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'accession_date_time')
62
+ self.accession_date_time = attributes[:'accession_date_time']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ accession_date_time == o.accession_date_time
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [accession_date_time].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
113
+ self.send("#{key}=", nil)
114
+ elsif type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :Time
135
+ Time.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ # models (e.g. Pet) or oneOf
166
+ klass = PrimaryConnectClient.const_get(type)
167
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end