ultracart_api 4.0.208 → 4.0.209

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -4
  3. data/docs/AutoOrder.md +2 -0
  4. data/docs/AutoOrderItem.md +2 -0
  5. data/docs/ConversationApi.md +429 -0
  6. data/docs/ConversationPbxVoicemailMessage.md +42 -0
  7. data/docs/ConversationPbxVoicemailMessageResponse.md +26 -0
  8. data/docs/ConversationPbxVoicemailMessageSummariesResponse.md +26 -0
  9. data/docs/ConversationPbxVoicemailMessageSummary.md +36 -0
  10. data/lib/ultracart_api/api/conversation_api.rb +384 -0
  11. data/lib/ultracart_api/models/auto_order.rb +11 -1
  12. data/lib/ultracart_api/models/auto_order_item.rb +11 -1
  13. data/lib/ultracart_api/models/conversation_pbx_phone_number_response.rb +1 -1
  14. data/lib/ultracart_api/models/conversation_pbx_phone_numbers_response.rb +1 -1
  15. data/lib/ultracart_api/models/conversation_pbx_time_based_response.rb +1 -1
  16. data/lib/ultracart_api/models/conversation_pbx_time_baseds_response.rb +1 -1
  17. data/lib/ultracart_api/models/conversation_pbx_time_range_response.rb +1 -1
  18. data/lib/ultracart_api/models/conversation_pbx_time_ranges_response.rb +1 -1
  19. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailbox.rb +29 -5
  20. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailbox_response.rb +1 -1
  21. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailboxes_response.rb +1 -1
  22. data/lib/ultracart_api/models/conversation_pbx_voicemail_message.rb +374 -0
  23. data/lib/ultracart_api/models/conversation_pbx_voicemail_message_response.rb +256 -0
  24. data/lib/ultracart_api/models/conversation_pbx_voicemail_message_summaries_response.rb +258 -0
  25. data/lib/ultracart_api/models/conversation_pbx_voicemail_message_summary.rb +344 -0
  26. data/lib/ultracart_api/version.rb +1 -1
  27. data/lib/ultracart_api.rb +4 -0
  28. metadata +10 -2
@@ -48,6 +48,28 @@ module UltracartClient
48
48
  # Voicemail say voice
49
49
  attr_accessor :voicemail_say_voice
50
50
 
51
+ class EnumAttributeValidator
52
+ attr_reader :datatype
53
+ attr_reader :allowable_values
54
+
55
+ def initialize(datatype, allowable_values)
56
+ @allowable_values = allowable_values.map do |value|
57
+ case datatype.to_s
58
+ when /Integer/i
59
+ value.to_i
60
+ when /Float/i
61
+ value.to_f
62
+ else
63
+ value
64
+ end
65
+ end
66
+ end
67
+
68
+ def valid?(value)
69
+ !value || allowable_values.include?(value)
70
+ end
71
+ end
72
+
51
73
  # Attribute mapping from ruby-style variable name to JSON key.
52
74
  def self.attribute_map
53
75
  {
@@ -200,6 +222,8 @@ module UltracartClient
200
222
  return false if !@send_notices_to_email.nil? && @send_notices_to_email.to_s.length > 250
201
223
  return false if !@voicemail_follow_play_audio_uuid.nil? && @voicemail_follow_play_audio_uuid.to_s.length > 50
202
224
  return false if !@voicemail_mailbox_id.nil? && @voicemail_mailbox_id.to_s.length > 50
225
+ voicemail_mailbox_type_validator = EnumAttributeValidator.new('String', ["agent", "shared"])
226
+ return false unless voicemail_mailbox_type_validator.valid?(@voicemail_mailbox_type)
203
227
  return false if !@voicemail_mailbox_type.nil? && @voicemail_mailbox_type.to_s.length > 50
204
228
  return false if !@voicemail_prompt_play_audio_uuid.nil? && @voicemail_prompt_play_audio_uuid.to_s.length > 50
205
229
  return false if !@voicemail_say_voice.nil? && @voicemail_say_voice.to_s.length > 50
@@ -256,13 +280,13 @@ module UltracartClient
256
280
  @voicemail_mailbox_id = voicemail_mailbox_id
257
281
  end
258
282
 
259
- # Custom attribute writer method with validation
260
- # @param [Object] voicemail_mailbox_type Value to be assigned
283
+ # Custom attribute writer method checking allowed values (enum).
284
+ # @param [Object] voicemail_mailbox_type Object to be assigned
261
285
  def voicemail_mailbox_type=(voicemail_mailbox_type)
262
- if !voicemail_mailbox_type.nil? && voicemail_mailbox_type.to_s.length > 50
263
- fail ArgumentError, 'invalid value for "voicemail_mailbox_type", the character length must be smaller than or equal to 50.'
286
+ validator = EnumAttributeValidator.new('String', ["agent", "shared"])
287
+ unless validator.valid?(voicemail_mailbox_type)
288
+ fail ArgumentError, "invalid value for \"voicemail_mailbox_type\", must be one of #{validator.allowable_values}."
264
289
  end
265
-
266
290
  @voicemail_mailbox_type = voicemail_mailbox_type
267
291
  end
268
292
 
@@ -32,7 +32,7 @@ module UltracartClient
32
32
  :'error' => :'error',
33
33
  :'metadata' => :'metadata',
34
34
  :'success' => :'success',
35
- :'voicemail_mailbox' => :'voicemailMailbox',
35
+ :'voicemail_mailbox' => :'voicemail_mailbox',
36
36
  :'warning' => :'warning'
37
37
  }
38
38
  end
@@ -32,7 +32,7 @@ module UltracartClient
32
32
  :'error' => :'error',
33
33
  :'metadata' => :'metadata',
34
34
  :'success' => :'success',
35
- :'voicemail_mailboxes' => :'voicemailMailboxes',
35
+ :'voicemail_mailboxes' => :'voicemail_mailboxes',
36
36
  :'warning' => :'warning'
37
37
  }
38
38
  end
@@ -0,0 +1,374 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ConversationPbxVoicemailMessage
18
+ # Call SID
19
+ attr_accessor :call_sid
20
+
21
+ # Duration in seconds
22
+ attr_accessor :duration
23
+
24
+ # From phone number in E.164
25
+ attr_accessor :from
26
+
27
+ # From caller id (if available)
28
+ attr_accessor :from_caller_id
29
+
30
+ # True if the voicemail has been listened to in the user interface
31
+ attr_accessor :listened
32
+
33
+ # Merchant ID
34
+ attr_accessor :merchant_id
35
+
36
+ # Recording SID
37
+ attr_accessor :recording_sid
38
+
39
+ # Recording size in bytes
40
+ attr_accessor :recording_size_bytes
41
+
42
+ # Recording Status
43
+ attr_accessor :recording_status
44
+
45
+ # Recording URL (expires in 4 hours)
46
+ attr_accessor :recording_url
47
+
48
+ # JSON version of the transcript
49
+ attr_accessor :transcript_json
50
+
51
+ # Formatted text of the transcript
52
+ attr_accessor :transcript_text
53
+
54
+ # Voicemail date/time
55
+ attr_accessor :voicemail_dts
56
+
57
+ class EnumAttributeValidator
58
+ attr_reader :datatype
59
+ attr_reader :allowable_values
60
+
61
+ def initialize(datatype, allowable_values)
62
+ @allowable_values = allowable_values.map do |value|
63
+ case datatype.to_s
64
+ when /Integer/i
65
+ value.to_i
66
+ when /Float/i
67
+ value.to_f
68
+ else
69
+ value
70
+ end
71
+ end
72
+ end
73
+
74
+ def valid?(value)
75
+ !value || allowable_values.include?(value)
76
+ end
77
+ end
78
+
79
+ # Attribute mapping from ruby-style variable name to JSON key.
80
+ def self.attribute_map
81
+ {
82
+ :'call_sid' => :'call_sid',
83
+ :'duration' => :'duration',
84
+ :'from' => :'from',
85
+ :'from_caller_id' => :'from_caller_id',
86
+ :'listened' => :'listened',
87
+ :'merchant_id' => :'merchant_id',
88
+ :'recording_sid' => :'recording_sid',
89
+ :'recording_size_bytes' => :'recording_size_bytes',
90
+ :'recording_status' => :'recording_status',
91
+ :'recording_url' => :'recording_url',
92
+ :'transcript_json' => :'transcript_json',
93
+ :'transcript_text' => :'transcript_text',
94
+ :'voicemail_dts' => :'voicemail_dts'
95
+ }
96
+ end
97
+
98
+ # Returns all the JSON keys this model knows about
99
+ def self.acceptable_attributes
100
+ attribute_map.values
101
+ end
102
+
103
+ # Attribute type mapping.
104
+ def self.openapi_types
105
+ {
106
+ :'call_sid' => :'String',
107
+ :'duration' => :'Integer',
108
+ :'from' => :'String',
109
+ :'from_caller_id' => :'String',
110
+ :'listened' => :'Boolean',
111
+ :'merchant_id' => :'String',
112
+ :'recording_sid' => :'String',
113
+ :'recording_size_bytes' => :'Integer',
114
+ :'recording_status' => :'String',
115
+ :'recording_url' => :'String',
116
+ :'transcript_json' => :'String',
117
+ :'transcript_text' => :'String',
118
+ :'voicemail_dts' => :'String'
119
+ }
120
+ end
121
+
122
+ # List of attributes with nullable: true
123
+ def self.openapi_nullable
124
+ Set.new([
125
+ ])
126
+ end
127
+
128
+ # Initializes the object
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ def initialize(attributes = {})
131
+ if (!attributes.is_a?(Hash))
132
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationPbxVoicemailMessage` initialize method"
133
+ end
134
+
135
+ # check to see if the attribute exists and convert string to symbol for hash key
136
+ attributes = attributes.each_with_object({}) { |(k, v), h|
137
+ if (!self.class.attribute_map.key?(k.to_sym))
138
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationPbxVoicemailMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
139
+ end
140
+ h[k.to_sym] = v
141
+ }
142
+
143
+ if attributes.key?(:'call_sid')
144
+ self.call_sid = attributes[:'call_sid']
145
+ end
146
+
147
+ if attributes.key?(:'duration')
148
+ self.duration = attributes[:'duration']
149
+ end
150
+
151
+ if attributes.key?(:'from')
152
+ self.from = attributes[:'from']
153
+ end
154
+
155
+ if attributes.key?(:'from_caller_id')
156
+ self.from_caller_id = attributes[:'from_caller_id']
157
+ end
158
+
159
+ if attributes.key?(:'listened')
160
+ self.listened = attributes[:'listened']
161
+ end
162
+
163
+ if attributes.key?(:'merchant_id')
164
+ self.merchant_id = attributes[:'merchant_id']
165
+ end
166
+
167
+ if attributes.key?(:'recording_sid')
168
+ self.recording_sid = attributes[:'recording_sid']
169
+ end
170
+
171
+ if attributes.key?(:'recording_size_bytes')
172
+ self.recording_size_bytes = attributes[:'recording_size_bytes']
173
+ end
174
+
175
+ if attributes.key?(:'recording_status')
176
+ self.recording_status = attributes[:'recording_status']
177
+ end
178
+
179
+ if attributes.key?(:'recording_url')
180
+ self.recording_url = attributes[:'recording_url']
181
+ end
182
+
183
+ if attributes.key?(:'transcript_json')
184
+ self.transcript_json = attributes[:'transcript_json']
185
+ end
186
+
187
+ if attributes.key?(:'transcript_text')
188
+ self.transcript_text = attributes[:'transcript_text']
189
+ end
190
+
191
+ if attributes.key?(:'voicemail_dts')
192
+ self.voicemail_dts = attributes[:'voicemail_dts']
193
+ end
194
+ end
195
+
196
+ # Show invalid properties with the reasons. Usually used together with valid?
197
+ # @return Array for valid properties with the reasons
198
+ def list_invalid_properties
199
+ invalid_properties = Array.new
200
+ invalid_properties
201
+ end
202
+
203
+ # Check to see if the all the properties in the model are valid
204
+ # @return true if the model is valid
205
+ def valid?
206
+ recording_status_validator = EnumAttributeValidator.new('String', ["completed"])
207
+ return false unless recording_status_validator.valid?(@recording_status)
208
+ true
209
+ end
210
+
211
+ # Custom attribute writer method checking allowed values (enum).
212
+ # @param [Object] recording_status Object to be assigned
213
+ def recording_status=(recording_status)
214
+ validator = EnumAttributeValidator.new('String', ["completed"])
215
+ unless validator.valid?(recording_status)
216
+ fail ArgumentError, "invalid value for \"recording_status\", must be one of #{validator.allowable_values}."
217
+ end
218
+ @recording_status = recording_status
219
+ end
220
+
221
+ # Checks equality by comparing each attribute.
222
+ # @param [Object] Object to be compared
223
+ def ==(o)
224
+ return true if self.equal?(o)
225
+ self.class == o.class &&
226
+ call_sid == o.call_sid &&
227
+ duration == o.duration &&
228
+ from == o.from &&
229
+ from_caller_id == o.from_caller_id &&
230
+ listened == o.listened &&
231
+ merchant_id == o.merchant_id &&
232
+ recording_sid == o.recording_sid &&
233
+ recording_size_bytes == o.recording_size_bytes &&
234
+ recording_status == o.recording_status &&
235
+ recording_url == o.recording_url &&
236
+ transcript_json == o.transcript_json &&
237
+ transcript_text == o.transcript_text &&
238
+ voicemail_dts == o.voicemail_dts
239
+ end
240
+
241
+ # @see the `==` method
242
+ # @param [Object] Object to be compared
243
+ def eql?(o)
244
+ self == o
245
+ end
246
+
247
+ # Calculates hash code according to all attributes.
248
+ # @return [Integer] Hash code
249
+ def hash
250
+ [call_sid, duration, from, from_caller_id, listened, merchant_id, recording_sid, recording_size_bytes, recording_status, recording_url, transcript_json, transcript_text, voicemail_dts].hash
251
+ end
252
+
253
+ # Builds the object from hash
254
+ # @param [Hash] attributes Model attributes in the form of hash
255
+ # @return [Object] Returns the model itself
256
+ def self.build_from_hash(attributes)
257
+ new.build_from_hash(attributes)
258
+ end
259
+
260
+ # Builds the object from hash
261
+ # @param [Hash] attributes Model attributes in the form of hash
262
+ # @return [Object] Returns the model itself
263
+ def build_from_hash(attributes)
264
+ return nil unless attributes.is_a?(Hash)
265
+ attributes = attributes.transform_keys(&:to_sym)
266
+ self.class.openapi_types.each_pair do |key, type|
267
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
268
+ self.send("#{key}=", nil)
269
+ elsif type =~ /\AArray<(.*)>/i
270
+ # check to ensure the input is an array given that the attribute
271
+ # is documented as an array but the input is not
272
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
273
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
274
+ end
275
+ elsif !attributes[self.class.attribute_map[key]].nil?
276
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
277
+ end
278
+ end
279
+
280
+ self
281
+ end
282
+
283
+ # Deserializes the data based on type
284
+ # @param string type Data type
285
+ # @param string value Value to be deserialized
286
+ # @return [Object] Deserialized data
287
+ def _deserialize(type, value)
288
+ case type.to_sym
289
+ when :Time
290
+ Time.parse(value)
291
+ when :Date
292
+ Date.parse(value)
293
+ when :String
294
+ value.to_s
295
+ when :Integer
296
+ value.to_i
297
+ when :Float
298
+ value.to_f
299
+ when :Boolean
300
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
301
+ true
302
+ else
303
+ false
304
+ end
305
+ when :Object
306
+ # generic object (usually a Hash), return directly
307
+ value
308
+ when /\AArray<(?<inner_type>.+)>\z/
309
+ inner_type = Regexp.last_match[:inner_type]
310
+ value.map { |v| _deserialize(inner_type, v) }
311
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
312
+ k_type = Regexp.last_match[:k_type]
313
+ v_type = Regexp.last_match[:v_type]
314
+ {}.tap do |hash|
315
+ value.each do |k, v|
316
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
317
+ end
318
+ end
319
+ else # model
320
+ # models (e.g. Pet) or oneOf
321
+ klass = UltracartClient.const_get(type)
322
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
323
+ end
324
+ end
325
+
326
+ # Returns the string representation of the object
327
+ # @return [String] String presentation of the object
328
+ def to_s
329
+ to_hash.to_s
330
+ end
331
+
332
+ # to_body is an alias to to_hash (backward compatibility)
333
+ # @return [Hash] Returns the object in the form of hash
334
+ def to_body
335
+ to_hash
336
+ end
337
+
338
+ # Returns the object in the form of hash
339
+ # @return [Hash] Returns the object in the form of hash
340
+ def to_hash
341
+ hash = {}
342
+ self.class.attribute_map.each_pair do |attr, param|
343
+ value = self.send(attr)
344
+ if value.nil?
345
+ is_nullable = self.class.openapi_nullable.include?(attr)
346
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
347
+ end
348
+
349
+ hash[param] = _to_hash(value)
350
+ end
351
+ hash
352
+ end
353
+
354
+ # Outputs non-array value in the form of hash
355
+ # For object, use to_hash. Otherwise, just return the value
356
+ # @param [Object] value Any valid value
357
+ # @return [Hash] Returns the value in the form of hash
358
+ def _to_hash(value)
359
+ if value.is_a?(Array)
360
+ value.compact.map { |v| _to_hash(v) }
361
+ elsif value.is_a?(Hash)
362
+ {}.tap do |hash|
363
+ value.each { |k, v| hash[k] = _to_hash(v) }
364
+ end
365
+ elsif value.respond_to? :to_hash
366
+ value.to_hash
367
+ else
368
+ value
369
+ end
370
+ end
371
+
372
+ end
373
+
374
+ end
@@ -0,0 +1,256 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ConversationPbxVoicemailMessageResponse
18
+ attr_accessor :error
19
+
20
+ attr_accessor :metadata
21
+
22
+ # Indicates if API call was successful
23
+ attr_accessor :success
24
+
25
+ attr_accessor :voicemail_message
26
+
27
+ attr_accessor :warning
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'error' => :'error',
33
+ :'metadata' => :'metadata',
34
+ :'success' => :'success',
35
+ :'voicemail_message' => :'voicemail_message',
36
+ :'warning' => :'warning'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'error' => :'Error',
49
+ :'metadata' => :'ResponseMetadata',
50
+ :'success' => :'Boolean',
51
+ :'voicemail_message' => :'ConversationPbxVoicemailMessage',
52
+ :'warning' => :'Warning'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationPbxVoicemailMessageResponse` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationPbxVoicemailMessageResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'error')
78
+ self.error = attributes[:'error']
79
+ end
80
+
81
+ if attributes.key?(:'metadata')
82
+ self.metadata = attributes[:'metadata']
83
+ end
84
+
85
+ if attributes.key?(:'success')
86
+ self.success = attributes[:'success']
87
+ end
88
+
89
+ if attributes.key?(:'voicemail_message')
90
+ self.voicemail_message = attributes[:'voicemail_message']
91
+ end
92
+
93
+ if attributes.key?(:'warning')
94
+ self.warning = attributes[:'warning']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ error == o.error &&
117
+ metadata == o.metadata &&
118
+ success == o.success &&
119
+ voicemail_message == o.voicemail_message &&
120
+ warning == o.warning
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [error, metadata, success, voicemail_message, warning].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ new.build_from_hash(attributes)
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ self.class.openapi_types.each_pair do |key, type|
149
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
150
+ self.send("#{key}=", nil)
151
+ elsif type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
153
+ # is documented as an array but the input is not
154
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
155
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
156
+ end
157
+ elsif !attributes[self.class.attribute_map[key]].nil?
158
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
159
+ end
160
+ end
161
+
162
+ self
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def _deserialize(type, value)
170
+ case type.to_sym
171
+ when :Time
172
+ Time.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ # models (e.g. Pet) or oneOf
203
+ klass = UltracartClient.const_get(type)
204
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end