ultracart_api 3.11.51 → 3.11.54

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -4
  3. data/docs/ConversationApi.md +110 -0
  4. data/docs/ConversationPbxAgent.md +1 -0
  5. data/docs/ConversationPbxCall.md +29 -0
  6. data/docs/ConversationPbxCallAgent.md +16 -0
  7. data/docs/ConversationPbxCallAiCost.md +11 -0
  8. data/docs/ConversationPbxCallAiEngagement.md +17 -0
  9. data/docs/ConversationPbxCallAiToolCall.md +16 -0
  10. data/docs/ConversationPbxCallAiWhisper.md +11 -0
  11. data/docs/ConversationPbxCallCaller.md +12 -0
  12. data/docs/ConversationPbxCallFinancial.md +14 -0
  13. data/docs/ConversationPbxCallHold.md +11 -0
  14. data/docs/ConversationPbxCallQueue.md +13 -0
  15. data/docs/ConversationPbxCallRecording.md +14 -0
  16. data/docs/ConversationPbxCallResponse.md +12 -0
  17. data/docs/ConversationPbxCallRouting.md +10 -0
  18. data/docs/ConversationPbxCallSearchRequest.md +23 -0
  19. data/docs/ConversationPbxCallSearchResponse.md +12 -0
  20. data/docs/ConversationPbxCallTimeline.md +13 -0
  21. data/docs/ConversationPbxCallTranscript.md +14 -0
  22. data/docs/ConversationPbxCallTranscriptSegment.md +14 -0
  23. data/docs/ConversationPbxCallTransfer.md +12 -0
  24. data/docs/ConversationPbxPhoneNumber.md +1 -0
  25. data/lib/ultracart_api/api/conversation_api.rb +119 -0
  26. data/lib/ultracart_api/models/conversation_pbx_agent.rb +11 -1
  27. data/lib/ultracart_api/models/conversation_pbx_call.rb +403 -0
  28. data/lib/ultracart_api/models/conversation_pbx_call_agent.rb +265 -0
  29. data/lib/ultracart_api/models/conversation_pbx_call_ai_cost.rb +215 -0
  30. data/lib/ultracart_api/models/conversation_pbx_call_ai_engagement.rb +312 -0
  31. data/lib/ultracart_api/models/conversation_pbx_call_ai_tool_call.rb +265 -0
  32. data/lib/ultracart_api/models/conversation_pbx_call_ai_whisper.rb +215 -0
  33. data/lib/ultracart_api/models/conversation_pbx_call_caller.rb +225 -0
  34. data/lib/ultracart_api/models/conversation_pbx_call_financial.rb +245 -0
  35. data/lib/ultracart_api/models/conversation_pbx_call_hold.rb +215 -0
  36. data/lib/ultracart_api/models/conversation_pbx_call_queue.rb +235 -0
  37. data/lib/ultracart_api/models/conversation_pbx_call_recording.rb +244 -0
  38. data/lib/ultracart_api/models/conversation_pbx_call_response.rb +221 -0
  39. data/lib/ultracart_api/models/conversation_pbx_call_routing.rb +204 -0
  40. data/lib/ultracart_api/models/conversation_pbx_call_search_request.rb +341 -0
  41. data/lib/ultracart_api/models/conversation_pbx_call_search_response.rb +224 -0
  42. data/lib/ultracart_api/models/conversation_pbx_call_timeline.rb +235 -0
  43. data/lib/ultracart_api/models/conversation_pbx_call_transcript.rb +247 -0
  44. data/lib/ultracart_api/models/conversation_pbx_call_transcript_segment.rb +279 -0
  45. data/lib/ultracart_api/models/conversation_pbx_call_transfer.rb +225 -0
  46. data/lib/ultracart_api/models/conversation_pbx_phone_number.rb +11 -1
  47. data/lib/ultracart_api/version.rb +1 -1
  48. data/lib/ultracart_api.rb +19 -0
  49. metadata +40 -2
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class ConversationPbxCallAiWhisper
17
+ # The whisper message content
18
+ attr_accessor :message
19
+
20
+ # Priority level of the whisper
21
+ attr_accessor :priority
22
+
23
+ # Unique identifier for this whisper
24
+ attr_accessor :whisper_uuid
25
+
26
+ # Timestamp when the whisper was sent
27
+ attr_accessor :whispered_at_dts
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'message' => :'message',
33
+ :'priority' => :'priority',
34
+ :'whisper_uuid' => :'whisper_uuid',
35
+ :'whispered_at_dts' => :'whispered_at_dts'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'message' => :'String',
43
+ :'priority' => :'String',
44
+ :'whisper_uuid' => :'String',
45
+ :'whispered_at_dts' => :'String'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
56
+
57
+ if attributes.has_key?(:'message')
58
+ self.message = attributes[:'message']
59
+ end
60
+
61
+ if attributes.has_key?(:'priority')
62
+ self.priority = attributes[:'priority']
63
+ end
64
+
65
+ if attributes.has_key?(:'whisper_uuid')
66
+ self.whisper_uuid = attributes[:'whisper_uuid']
67
+ end
68
+
69
+ if attributes.has_key?(:'whispered_at_dts')
70
+ self.whispered_at_dts = attributes[:'whispered_at_dts']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ message == o.message &&
93
+ priority == o.priority &&
94
+ whisper_uuid == o.whisper_uuid &&
95
+ whispered_at_dts == o.whispered_at_dts
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Fixnum] Hash code
106
+ def hash
107
+ [message, priority, whisper_uuid, whispered_at_dts].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.swagger_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :BOOLEAN
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ temp_model = UltracartClient.const_get(type).new
168
+ temp_model.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ next if value.nil?
191
+ hash[param] = _to_hash(value)
192
+ end
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map { |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to? :to_hash
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+ end
@@ -0,0 +1,225 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class ConversationPbxCallCaller
17
+ # Caller ID name if available
18
+ attr_accessor :caller_id
19
+
20
+ # City associated with the phone number
21
+ attr_accessor :city
22
+
23
+ # Country associated with the phone number (ISO 3166-1 alpha-2)
24
+ attr_accessor :country
25
+
26
+ # Phone number in E.164 format
27
+ attr_accessor :phone_number
28
+
29
+ # State or province associated with the phone number
30
+ attr_accessor :state
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'caller_id' => :'caller_id',
36
+ :'city' => :'city',
37
+ :'country' => :'country',
38
+ :'phone_number' => :'phone_number',
39
+ :'state' => :'state'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'caller_id' => :'String',
47
+ :'city' => :'String',
48
+ :'country' => :'String',
49
+ :'phone_number' => :'String',
50
+ :'state' => :'String'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
61
+
62
+ if attributes.has_key?(:'caller_id')
63
+ self.caller_id = attributes[:'caller_id']
64
+ end
65
+
66
+ if attributes.has_key?(:'city')
67
+ self.city = attributes[:'city']
68
+ end
69
+
70
+ if attributes.has_key?(:'country')
71
+ self.country = attributes[:'country']
72
+ end
73
+
74
+ if attributes.has_key?(:'phone_number')
75
+ self.phone_number = attributes[:'phone_number']
76
+ end
77
+
78
+ if attributes.has_key?(:'state')
79
+ self.state = attributes[:'state']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ caller_id == o.caller_id &&
102
+ city == o.city &&
103
+ country == o.country &&
104
+ phone_number == o.phone_number &&
105
+ state == o.state
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
116
+ def hash
117
+ [caller_id, city, country, phone_number, state].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ self.class.swagger_types.each_pair do |key, type|
126
+ if type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :DateTime
147
+ DateTime.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :BOOLEAN
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ temp_model = UltracartClient.const_get(type).new
178
+ temp_model.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ next if value.nil?
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map { |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+
224
+ end
225
+ end
@@ -0,0 +1,245 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class ConversationPbxCallFinancial
17
+ # Total AI agent billed minutes for this call
18
+ attr_accessor :ai_agent_billed_minutes
19
+
20
+ # Total AI agent cost for this call
21
+ attr_accessor :ai_agent_cost
22
+
23
+ # Currency for AI agent cost
24
+ attr_accessor :ai_agent_cost_currency
25
+
26
+ # Currency for call price (default USD)
27
+ attr_accessor :call_currency
28
+
29
+ # Twilio call cost
30
+ attr_accessor :call_price
31
+
32
+ # True if call price is a fallback-rate estimate, false if Twilio-confirmed
33
+ attr_accessor :call_price_estimated
34
+
35
+ # AWS Transcribe transcription cost
36
+ attr_accessor :transcription_cost
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'ai_agent_billed_minutes' => :'ai_agent_billed_minutes',
42
+ :'ai_agent_cost' => :'ai_agent_cost',
43
+ :'ai_agent_cost_currency' => :'ai_agent_cost_currency',
44
+ :'call_currency' => :'call_currency',
45
+ :'call_price' => :'call_price',
46
+ :'call_price_estimated' => :'call_price_estimated',
47
+ :'transcription_cost' => :'transcription_cost'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'ai_agent_billed_minutes' => :'Float',
55
+ :'ai_agent_cost' => :'Float',
56
+ :'ai_agent_cost_currency' => :'String',
57
+ :'call_currency' => :'String',
58
+ :'call_price' => :'Float',
59
+ :'call_price_estimated' => :'BOOLEAN',
60
+ :'transcription_cost' => :'Float'
61
+ }
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ return unless attributes.is_a?(Hash)
68
+
69
+ # convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
71
+
72
+ if attributes.has_key?(:'ai_agent_billed_minutes')
73
+ self.ai_agent_billed_minutes = attributes[:'ai_agent_billed_minutes']
74
+ end
75
+
76
+ if attributes.has_key?(:'ai_agent_cost')
77
+ self.ai_agent_cost = attributes[:'ai_agent_cost']
78
+ end
79
+
80
+ if attributes.has_key?(:'ai_agent_cost_currency')
81
+ self.ai_agent_cost_currency = attributes[:'ai_agent_cost_currency']
82
+ end
83
+
84
+ if attributes.has_key?(:'call_currency')
85
+ self.call_currency = attributes[:'call_currency']
86
+ end
87
+
88
+ if attributes.has_key?(:'call_price')
89
+ self.call_price = attributes[:'call_price']
90
+ end
91
+
92
+ if attributes.has_key?(:'call_price_estimated')
93
+ self.call_price_estimated = attributes[:'call_price_estimated']
94
+ end
95
+
96
+ if attributes.has_key?(:'transcription_cost')
97
+ self.transcription_cost = attributes[:'transcription_cost']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ ai_agent_billed_minutes == o.ai_agent_billed_minutes &&
120
+ ai_agent_cost == o.ai_agent_cost &&
121
+ ai_agent_cost_currency == o.ai_agent_cost_currency &&
122
+ call_currency == o.call_currency &&
123
+ call_price == o.call_price &&
124
+ call_price_estimated == o.call_price_estimated &&
125
+ transcription_cost == o.transcription_cost
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Fixnum] Hash code
136
+ def hash
137
+ [ai_agent_billed_minutes, ai_agent_cost, ai_agent_cost_currency, call_currency, call_price, call_price_estimated, transcription_cost].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ self.class.swagger_types.each_pair do |key, type|
146
+ if type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :DateTime
167
+ DateTime.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :BOOLEAN
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ temp_model = UltracartClient.const_get(type).new
198
+ temp_model.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ next if value.nil?
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+ end