ultracart_api 4.0.201 → 4.0.203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -4
  3. data/docs/ConversationApi.md +3565 -549
  4. data/docs/ConversationPbxAgent.md +34 -0
  5. data/docs/ConversationPbxAgentResponse.md +26 -0
  6. data/docs/ConversationPbxAgentsResponse.md +26 -0
  7. data/docs/ConversationPbxAudio.md +34 -0
  8. data/docs/ConversationPbxAudioResponse.md +26 -0
  9. data/docs/ConversationPbxAudiosResponse.md +26 -0
  10. data/docs/ConversationPbxCustomerSnapshotRequest.md +32 -0
  11. data/docs/ConversationPbxCustomerSnapshotResponse.md +30 -0
  12. data/docs/ConversationPbxMenu.md +36 -0
  13. data/docs/ConversationPbxMenuMapping.md +24 -0
  14. data/docs/ConversationPbxMenuResponse.md +26 -0
  15. data/docs/ConversationPbxMenusResponse.md +26 -0
  16. data/docs/ConversationPbxPhoneNumber.md +26 -0
  17. data/docs/ConversationPbxPhoneNumberResponse.md +26 -0
  18. data/docs/ConversationPbxPhoneNumbersResponse.md +26 -0
  19. data/docs/ConversationPbxQueue.md +56 -0
  20. data/docs/ConversationPbxQueueMembers.md +20 -0
  21. data/docs/ConversationPbxQueueResponse.md +26 -0
  22. data/docs/ConversationPbxQueuesResponse.md +26 -0
  23. data/docs/ConversationPbxTimeBased.md +24 -0
  24. data/docs/ConversationPbxTimeBasedMapping.md +24 -0
  25. data/docs/ConversationPbxTimeBasedMappingConfig.md +20 -0
  26. data/docs/ConversationPbxTimeBasedResponse.md +26 -0
  27. data/docs/ConversationPbxTimeBasedsResponse.md +26 -0
  28. data/docs/ConversationPbxTimeRange.md +26 -0
  29. data/docs/ConversationPbxTimeRangeConfig.md +28 -0
  30. data/docs/ConversationPbxTimeRangeResponse.md +26 -0
  31. data/docs/ConversationPbxTimeRangesResponse.md +26 -0
  32. data/docs/ConversationPbxVoicemailMailbox.md +38 -0
  33. data/docs/ConversationPbxVoicemailMailboxResponse.md +26 -0
  34. data/docs/ConversationPbxVoicemailMailboxesResponse.md +26 -0
  35. data/docs/WorkflowAgentAuth.md +22 -0
  36. data/docs/WorkflowAgentAuthResponse.md +26 -0
  37. data/docs/WorkflowApi.md +138 -0
  38. data/docs/WorkflowTaskTagsResponse.md +26 -0
  39. data/lib/ultracart_api/api/conversation_api.rb +3422 -649
  40. data/lib/ultracart_api/api/workflow_api.rb +116 -0
  41. data/lib/ultracart_api/models/conversation_pbx_agent.rb +360 -0
  42. data/lib/ultracart_api/models/conversation_pbx_agent_response.rb +256 -0
  43. data/lib/ultracart_api/models/conversation_pbx_agents_response.rb +258 -0
  44. data/lib/ultracart_api/models/conversation_pbx_audio.rb +390 -0
  45. data/lib/ultracart_api/models/conversation_pbx_audio_response.rb +256 -0
  46. data/lib/ultracart_api/models/conversation_pbx_audios_response.rb +258 -0
  47. data/lib/ultracart_api/models/conversation_pbx_customer_snapshot_request.rb +283 -0
  48. data/lib/ultracart_api/models/conversation_pbx_customer_snapshot_response.rb +278 -0
  49. data/lib/ultracart_api/models/conversation_pbx_menu.rb +402 -0
  50. data/lib/ultracart_api/models/conversation_pbx_menu_mapping.rb +250 -0
  51. data/lib/ultracart_api/models/conversation_pbx_menu_response.rb +256 -0
  52. data/lib/ultracart_api/models/conversation_pbx_menus_response.rb +258 -0
  53. data/lib/ultracart_api/models/conversation_pbx_phone_number.rb +335 -0
  54. data/lib/ultracart_api/models/conversation_pbx_phone_number_response.rb +256 -0
  55. data/lib/ultracart_api/models/conversation_pbx_phone_numbers_response.rb +258 -0
  56. data/lib/ultracart_api/models/conversation_pbx_queue.rb +559 -0
  57. data/lib/ultracart_api/models/conversation_pbx_queue_members.rb +232 -0
  58. data/lib/ultracart_api/models/conversation_pbx_queue_response.rb +256 -0
  59. data/lib/ultracart_api/models/conversation_pbx_queues_response.rb +258 -0
  60. data/lib/ultracart_api/models/conversation_pbx_time_based.rb +246 -0
  61. data/lib/ultracart_api/models/conversation_pbx_time_based_mapping.rb +310 -0
  62. data/lib/ultracart_api/models/conversation_pbx_time_based_mapping_config.rb +231 -0
  63. data/lib/ultracart_api/models/conversation_pbx_time_based_response.rb +256 -0
  64. data/lib/ultracart_api/models/conversation_pbx_time_baseds_response.rb +258 -0
  65. data/lib/ultracart_api/models/conversation_pbx_time_range.rb +322 -0
  66. data/lib/ultracart_api/models/conversation_pbx_time_range_config.rb +270 -0
  67. data/lib/ultracart_api/models/conversation_pbx_time_range_response.rb +256 -0
  68. data/lib/ultracart_api/models/conversation_pbx_time_ranges_response.rb +258 -0
  69. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailbox.rb +440 -0
  70. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailbox_response.rb +256 -0
  71. data/lib/ultracart_api/models/conversation_pbx_voicemail_mailboxes_response.rb +258 -0
  72. data/lib/ultracart_api/models/workflow_agent_auth.rb +237 -0
  73. data/lib/ultracart_api/models/workflow_agent_auth_response.rb +256 -0
  74. data/lib/ultracart_api/models/workflow_task_tags_response.rb +259 -0
  75. data/lib/ultracart_api/version.rb +1 -1
  76. data/lib/ultracart_api.rb +34 -0
  77. metadata +70 -2
@@ -0,0 +1,258 @@
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 ConversationPbxMenusResponse
18
+ attr_accessor :error
19
+
20
+ attr_accessor :menus
21
+
22
+ attr_accessor :metadata
23
+
24
+ # Indicates if API call was successful
25
+ attr_accessor :success
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
+ :'menus' => :'menus',
34
+ :'metadata' => :'metadata',
35
+ :'success' => :'success',
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
+ :'menus' => :'Array<ConversationPbxMenu>',
50
+ :'metadata' => :'ResponseMetadata',
51
+ :'success' => :'Boolean',
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::ConversationPbxMenusResponse` 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::ConversationPbxMenusResponse`. 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?(:'menus')
82
+ if (value = attributes[:'menus']).is_a?(Array)
83
+ self.menus = value
84
+ end
85
+ end
86
+
87
+ if attributes.key?(:'metadata')
88
+ self.metadata = attributes[:'metadata']
89
+ end
90
+
91
+ if attributes.key?(:'success')
92
+ self.success = attributes[:'success']
93
+ end
94
+
95
+ if attributes.key?(:'warning')
96
+ self.warning = attributes[:'warning']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ true
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ error == o.error &&
119
+ menus == o.menus &&
120
+ metadata == o.metadata &&
121
+ success == o.success &&
122
+ warning == o.warning
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(o)
128
+ self == o
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [error, menus, metadata, success, warning].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ new.build_from_hash(attributes)
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ self.class.openapi_types.each_pair do |key, type|
151
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
152
+ self.send("#{key}=", nil)
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ end
162
+ end
163
+
164
+ self
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def _deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = UltracartClient.const_get(type)
206
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
@@ -0,0 +1,335 @@
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 ConversationPbxPhoneNumber
18
+ # Action
19
+ attr_accessor :action
20
+
21
+ # Action target
22
+ attr_accessor :action_target
23
+
24
+ # Conversation Pbx Phone Number UUID
25
+ attr_accessor :conversation_pbx_time_range_uuid
26
+
27
+ # Merchant Id
28
+ attr_accessor :merchant_id
29
+
30
+ # Phone number
31
+ attr_accessor :phone_number
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'action' => :'action',
37
+ :'action_target' => :'action_target',
38
+ :'conversation_pbx_time_range_uuid' => :'conversation_pbx_time_range_uuid',
39
+ :'merchant_id' => :'merchant_id',
40
+ :'phone_number' => :'phone_number'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'action' => :'String',
53
+ :'action_target' => :'String',
54
+ :'conversation_pbx_time_range_uuid' => :'String',
55
+ :'merchant_id' => :'String',
56
+ :'phone_number' => :'String'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationPbxPhoneNumber` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationPbxPhoneNumber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'action')
82
+ self.action = attributes[:'action']
83
+ end
84
+
85
+ if attributes.key?(:'action_target')
86
+ self.action_target = attributes[:'action_target']
87
+ end
88
+
89
+ if attributes.key?(:'conversation_pbx_time_range_uuid')
90
+ self.conversation_pbx_time_range_uuid = attributes[:'conversation_pbx_time_range_uuid']
91
+ end
92
+
93
+ if attributes.key?(:'merchant_id')
94
+ self.merchant_id = attributes[:'merchant_id']
95
+ end
96
+
97
+ if attributes.key?(:'phone_number')
98
+ self.phone_number = attributes[:'phone_number']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ if !@action.nil? && @action.to_s.length > 30
107
+ invalid_properties.push('invalid value for "action", the character length must be smaller than or equal to 30.')
108
+ end
109
+
110
+ if !@action_target.nil? && @action_target.to_s.length > 50
111
+ invalid_properties.push('invalid value for "action_target", the character length must be smaller than or equal to 50.')
112
+ end
113
+
114
+ if !@conversation_pbx_time_range_uuid.nil? && @conversation_pbx_time_range_uuid.to_s.length > 50
115
+ invalid_properties.push('invalid value for "conversation_pbx_time_range_uuid", the character length must be smaller than or equal to 50.')
116
+ end
117
+
118
+ if !@merchant_id.nil? && @merchant_id.to_s.length > 5
119
+ invalid_properties.push('invalid value for "merchant_id", the character length must be smaller than or equal to 5.')
120
+ end
121
+
122
+ if !@phone_number.nil? && @phone_number.to_s.length > 50
123
+ invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 50.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ return false if !@action.nil? && @action.to_s.length > 30
133
+ return false if !@action_target.nil? && @action_target.to_s.length > 50
134
+ return false if !@conversation_pbx_time_range_uuid.nil? && @conversation_pbx_time_range_uuid.to_s.length > 50
135
+ return false if !@merchant_id.nil? && @merchant_id.to_s.length > 5
136
+ return false if !@phone_number.nil? && @phone_number.to_s.length > 50
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method with validation
141
+ # @param [Object] action Value to be assigned
142
+ def action=(action)
143
+ if !action.nil? && action.to_s.length > 30
144
+ fail ArgumentError, 'invalid value for "action", the character length must be smaller than or equal to 30.'
145
+ end
146
+
147
+ @action = action
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] action_target Value to be assigned
152
+ def action_target=(action_target)
153
+ if !action_target.nil? && action_target.to_s.length > 50
154
+ fail ArgumentError, 'invalid value for "action_target", the character length must be smaller than or equal to 50.'
155
+ end
156
+
157
+ @action_target = action_target
158
+ end
159
+
160
+ # Custom attribute writer method with validation
161
+ # @param [Object] conversation_pbx_time_range_uuid Value to be assigned
162
+ def conversation_pbx_time_range_uuid=(conversation_pbx_time_range_uuid)
163
+ if !conversation_pbx_time_range_uuid.nil? && conversation_pbx_time_range_uuid.to_s.length > 50
164
+ fail ArgumentError, 'invalid value for "conversation_pbx_time_range_uuid", the character length must be smaller than or equal to 50.'
165
+ end
166
+
167
+ @conversation_pbx_time_range_uuid = conversation_pbx_time_range_uuid
168
+ end
169
+
170
+ # Custom attribute writer method with validation
171
+ # @param [Object] merchant_id Value to be assigned
172
+ def merchant_id=(merchant_id)
173
+ if !merchant_id.nil? && merchant_id.to_s.length > 5
174
+ fail ArgumentError, 'invalid value for "merchant_id", the character length must be smaller than or equal to 5.'
175
+ end
176
+
177
+ @merchant_id = merchant_id
178
+ end
179
+
180
+ # Custom attribute writer method with validation
181
+ # @param [Object] phone_number Value to be assigned
182
+ def phone_number=(phone_number)
183
+ if !phone_number.nil? && phone_number.to_s.length > 50
184
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 50.'
185
+ end
186
+
187
+ @phone_number = phone_number
188
+ end
189
+
190
+ # Checks equality by comparing each attribute.
191
+ # @param [Object] Object to be compared
192
+ def ==(o)
193
+ return true if self.equal?(o)
194
+ self.class == o.class &&
195
+ action == o.action &&
196
+ action_target == o.action_target &&
197
+ conversation_pbx_time_range_uuid == o.conversation_pbx_time_range_uuid &&
198
+ merchant_id == o.merchant_id &&
199
+ phone_number == o.phone_number
200
+ end
201
+
202
+ # @see the `==` method
203
+ # @param [Object] Object to be compared
204
+ def eql?(o)
205
+ self == o
206
+ end
207
+
208
+ # Calculates hash code according to all attributes.
209
+ # @return [Integer] Hash code
210
+ def hash
211
+ [action, action_target, conversation_pbx_time_range_uuid, merchant_id, phone_number].hash
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 self.build_from_hash(attributes)
218
+ new.build_from_hash(attributes)
219
+ end
220
+
221
+ # Builds the object from hash
222
+ # @param [Hash] attributes Model attributes in the form of hash
223
+ # @return [Object] Returns the model itself
224
+ def build_from_hash(attributes)
225
+ return nil unless attributes.is_a?(Hash)
226
+ attributes = attributes.transform_keys(&:to_sym)
227
+ self.class.openapi_types.each_pair do |key, type|
228
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
229
+ self.send("#{key}=", nil)
230
+ elsif type =~ /\AArray<(.*)>/i
231
+ # check to ensure the input is an array given that the attribute
232
+ # is documented as an array but the input is not
233
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
234
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
235
+ end
236
+ elsif !attributes[self.class.attribute_map[key]].nil?
237
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
238
+ end
239
+ end
240
+
241
+ self
242
+ end
243
+
244
+ # Deserializes the data based on type
245
+ # @param string type Data type
246
+ # @param string value Value to be deserialized
247
+ # @return [Object] Deserialized data
248
+ def _deserialize(type, value)
249
+ case type.to_sym
250
+ when :Time
251
+ Time.parse(value)
252
+ when :Date
253
+ Date.parse(value)
254
+ when :String
255
+ value.to_s
256
+ when :Integer
257
+ value.to_i
258
+ when :Float
259
+ value.to_f
260
+ when :Boolean
261
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
262
+ true
263
+ else
264
+ false
265
+ end
266
+ when :Object
267
+ # generic object (usually a Hash), return directly
268
+ value
269
+ when /\AArray<(?<inner_type>.+)>\z/
270
+ inner_type = Regexp.last_match[:inner_type]
271
+ value.map { |v| _deserialize(inner_type, v) }
272
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
273
+ k_type = Regexp.last_match[:k_type]
274
+ v_type = Regexp.last_match[:v_type]
275
+ {}.tap do |hash|
276
+ value.each do |k, v|
277
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
278
+ end
279
+ end
280
+ else # model
281
+ # models (e.g. Pet) or oneOf
282
+ klass = UltracartClient.const_get(type)
283
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
284
+ end
285
+ end
286
+
287
+ # Returns the string representation of the object
288
+ # @return [String] String presentation of the object
289
+ def to_s
290
+ to_hash.to_s
291
+ end
292
+
293
+ # to_body is an alias to to_hash (backward compatibility)
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_body
296
+ to_hash
297
+ end
298
+
299
+ # Returns the object in the form of hash
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_hash
302
+ hash = {}
303
+ self.class.attribute_map.each_pair do |attr, param|
304
+ value = self.send(attr)
305
+ if value.nil?
306
+ is_nullable = self.class.openapi_nullable.include?(attr)
307
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
308
+ end
309
+
310
+ hash[param] = _to_hash(value)
311
+ end
312
+ hash
313
+ end
314
+
315
+ # Outputs non-array value in the form of hash
316
+ # For object, use to_hash. Otherwise, just return the value
317
+ # @param [Object] value Any valid value
318
+ # @return [Hash] Returns the value in the form of hash
319
+ def _to_hash(value)
320
+ if value.is_a?(Array)
321
+ value.compact.map { |v| _to_hash(v) }
322
+ elsif value.is_a?(Hash)
323
+ {}.tap do |hash|
324
+ value.each { |k, v| hash[k] = _to_hash(v) }
325
+ end
326
+ elsif value.respond_to? :to_hash
327
+ value.to_hash
328
+ else
329
+ value
330
+ end
331
+ end
332
+
333
+ end
334
+
335
+ end