ultracart_api 3.10.78 → 3.10.80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -4
  3. data/docs/ConversationApi.md +308 -2
  4. data/docs/ConversationCannedMessage.md +1 -1
  5. data/docs/ConversationDepartment.md +12 -0
  6. data/docs/ConversationDepartmentResponse.md +12 -0
  7. data/docs/ConversationDepartmentSettings.md +7 -0
  8. data/docs/ConversationDepartmentsResponse.md +12 -0
  9. data/docs/ConversationEngagement.md +14 -0
  10. data/docs/ConversationEngagementEquation.md +7 -0
  11. data/docs/ConversationEngagementResponse.md +12 -0
  12. data/docs/ConversationEngagementsResponse.md +12 -0
  13. data/docs/ConversationJoinRequest.md +8 -0
  14. data/docs/ConversationMessage.md +2 -0
  15. data/docs/ConversationMessageTranslation.md +9 -0
  16. data/docs/ConversationParticipant.md +3 -0
  17. data/docs/ConversationWebchatQueueStatusQueueEntry.md +1 -0
  18. data/lib/ultracart_api/api/conversation_api.rb +333 -1
  19. data/lib/ultracart_api/models/conversation_canned_message.rb +8 -8
  20. data/lib/ultracart_api/models/conversation_department.rb +220 -0
  21. data/lib/ultracart_api/models/conversation_department_response.rb +221 -0
  22. data/lib/ultracart_api/models/conversation_department_settings.rb +175 -0
  23. data/lib/ultracart_api/models/conversation_departments_response.rb +223 -0
  24. data/lib/ultracart_api/models/conversation_engagement.rb +240 -0
  25. data/lib/ultracart_api/models/conversation_engagement_equation.rb +175 -0
  26. data/lib/ultracart_api/models/conversation_engagement_response.rb +221 -0
  27. data/lib/ultracart_api/models/conversation_engagements_response.rb +223 -0
  28. data/lib/ultracart_api/models/conversation_join_request.rb +184 -0
  29. data/lib/ultracart_api/models/conversation_message.rb +21 -1
  30. data/lib/ultracart_api/models/conversation_message_translation.rb +193 -0
  31. data/lib/ultracart_api/models/conversation_participant.rb +28 -1
  32. data/lib/ultracart_api/models/conversation_webchat_queue_status_queue_entry.rb +10 -1
  33. data/lib/ultracart_api/version.rb +1 -1
  34. data/lib/ultracart_api.rb +10 -0
  35. metadata +22 -2
@@ -0,0 +1,223 @@
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 ConversationEngagementsResponse
17
+ attr_accessor :conversation_engagements
18
+
19
+ attr_accessor :error
20
+
21
+ attr_accessor :metadata
22
+
23
+ # Indicates if API call was successful
24
+ attr_accessor :success
25
+
26
+ attr_accessor :warning
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'conversation_engagements' => :'conversation_engagements',
32
+ :'error' => :'error',
33
+ :'metadata' => :'metadata',
34
+ :'success' => :'success',
35
+ :'warning' => :'warning'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'conversation_engagements' => :'Array<ConversationEngagement>',
43
+ :'error' => :'Error',
44
+ :'metadata' => :'ResponseMetadata',
45
+ :'success' => :'BOOLEAN',
46
+ :'warning' => :'Warning'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+
58
+ if attributes.has_key?(:'conversation_engagements')
59
+ if (value = attributes[:'conversation_engagements']).is_a?(Array)
60
+ self.conversation_engagements = value
61
+ end
62
+ end
63
+
64
+ if attributes.has_key?(:'error')
65
+ self.error = attributes[:'error']
66
+ end
67
+
68
+ if attributes.has_key?(:'metadata')
69
+ self.metadata = attributes[:'metadata']
70
+ end
71
+
72
+ if attributes.has_key?(:'success')
73
+ self.success = attributes[:'success']
74
+ end
75
+
76
+ if attributes.has_key?(:'warning')
77
+ self.warning = attributes[:'warning']
78
+ end
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ conversation_engagements == o.conversation_engagements &&
100
+ error == o.error &&
101
+ metadata == o.metadata &&
102
+ success == o.success &&
103
+ warning == o.warning
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Fixnum] Hash code
114
+ def hash
115
+ [conversation_engagements, error, metadata, success, warning].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.swagger_types.each_pair do |key, type|
124
+ if type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BOOLEAN
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ temp_model = UltracartClient.const_get(type).new
176
+ temp_model.build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ next if value.nil?
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ # Outputs non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ # @param [Object] value Any valid value
207
+ # @return [Hash] Returns the value in the form of hash
208
+ def _to_hash(value)
209
+ if value.is_a?(Array)
210
+ value.compact.map { |v| _to_hash(v) }
211
+ elsif value.is_a?(Hash)
212
+ {}.tap do |hash|
213
+ value.each { |k, v| hash[k] = _to_hash(v) }
214
+ end
215
+ elsif value.respond_to? :to_hash
216
+ value.to_hash
217
+ else
218
+ value
219
+ end
220
+ end
221
+
222
+ end
223
+ end
@@ -0,0 +1,184 @@
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 ConversationJoinRequest
17
+ attr_accessor :participant_language_iso_code
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'participant_language_iso_code' => :'participant_language_iso_code'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'participant_language_iso_code' => :'String'
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ if attributes.has_key?(:'participant_language_iso_code')
42
+ self.participant_language_iso_code = attributes[:'participant_language_iso_code']
43
+ end
44
+ end
45
+
46
+ # Show invalid properties with the reasons. Usually used together with valid?
47
+ # @return Array for valid properties with the reasons
48
+ def list_invalid_properties
49
+ invalid_properties = Array.new
50
+ invalid_properties
51
+ end
52
+
53
+ # Check to see if the all the properties in the model are valid
54
+ # @return true if the model is valid
55
+ def valid?
56
+ true
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ participant_language_iso_code == o.participant_language_iso_code
65
+ end
66
+
67
+ # @see the `==` method
68
+ # @param [Object] Object to be compared
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculates hash code according to all attributes.
74
+ # @return [Fixnum] Hash code
75
+ def hash
76
+ [participant_language_iso_code].hash
77
+ end
78
+
79
+ # Builds the object from hash
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ # @return [Object] Returns the model itself
82
+ def build_from_hash(attributes)
83
+ return nil unless attributes.is_a?(Hash)
84
+ self.class.swagger_types.each_pair do |key, type|
85
+ if type =~ /\AArray<(.*)>/i
86
+ # check to ensure the input is an array given that the attribute
87
+ # is documented as an array but the input is not
88
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
89
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
90
+ end
91
+ elsif !attributes[self.class.attribute_map[key]].nil?
92
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
93
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
94
+ end
95
+
96
+ self
97
+ end
98
+
99
+ # Deserializes the data based on type
100
+ # @param string type Data type
101
+ # @param string value Value to be deserialized
102
+ # @return [Object] Deserialized data
103
+ def _deserialize(type, value)
104
+ case type.to_sym
105
+ when :DateTime
106
+ DateTime.parse(value)
107
+ when :Date
108
+ Date.parse(value)
109
+ when :String
110
+ value.to_s
111
+ when :Integer
112
+ value.to_i
113
+ when :Float
114
+ value.to_f
115
+ when :BOOLEAN
116
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
117
+ true
118
+ else
119
+ false
120
+ end
121
+ when :Object
122
+ # generic object (usually a Hash), return directly
123
+ value
124
+ when /\AArray<(?<inner_type>.+)>\z/
125
+ inner_type = Regexp.last_match[:inner_type]
126
+ value.map { |v| _deserialize(inner_type, v) }
127
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
128
+ k_type = Regexp.last_match[:k_type]
129
+ v_type = Regexp.last_match[:v_type]
130
+ {}.tap do |hash|
131
+ value.each do |k, v|
132
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
133
+ end
134
+ end
135
+ else # model
136
+ temp_model = UltracartClient.const_get(type).new
137
+ temp_model.build_from_hash(value)
138
+ end
139
+ end
140
+
141
+ # Returns the string representation of the object
142
+ # @return [String] String presentation of the object
143
+ def to_s
144
+ to_hash.to_s
145
+ end
146
+
147
+ # to_body is an alias to to_hash (backward compatibility)
148
+ # @return [Hash] Returns the object in the form of hash
149
+ def to_body
150
+ to_hash
151
+ end
152
+
153
+ # Returns the object in the form of hash
154
+ # @return [Hash] Returns the object in the form of hash
155
+ def to_hash
156
+ hash = {}
157
+ self.class.attribute_map.each_pair do |attr, param|
158
+ value = self.send(attr)
159
+ next if value.nil?
160
+ hash[param] = _to_hash(value)
161
+ end
162
+ hash
163
+ end
164
+
165
+ # Outputs non-array value in the form of hash
166
+ # For object, use to_hash. Otherwise, just return the value
167
+ # @param [Object] value Any valid value
168
+ # @return [Hash] Returns the value in the form of hash
169
+ def _to_hash(value)
170
+ if value.is_a?(Array)
171
+ value.compact.map { |v| _to_hash(v) }
172
+ elsif value.is_a?(Hash)
173
+ {}.tap do |hash|
174
+ value.each { |k, v| hash[k] = _to_hash(v) }
175
+ end
176
+ elsif value.respond_to? :to_hash
177
+ value.to_hash
178
+ else
179
+ value
180
+ end
181
+ end
182
+
183
+ end
184
+ end
@@ -27,6 +27,8 @@ module UltracartClient
27
27
  # Delay message transmission until date/time
28
28
  attr_accessor :delay_until_dts
29
29
 
30
+ attr_accessor :language_iso_code
31
+
30
32
  attr_accessor :media_urls
31
33
 
32
34
  attr_accessor :merchant_id
@@ -37,6 +39,8 @@ module UltracartClient
37
39
  # Message epoch milliseconds
38
40
  attr_accessor :message_epoch
39
41
 
42
+ attr_accessor :translations
43
+
40
44
  attr_accessor :transport_statuses
41
45
 
42
46
  # Message type
@@ -75,10 +79,12 @@ module UltracartClient
75
79
  :'client_message_id' => :'client_message_id',
76
80
  :'conversation_message_uuid' => :'conversation_message_uuid',
77
81
  :'delay_until_dts' => :'delay_until_dts',
82
+ :'language_iso_code' => :'language_iso_code',
78
83
  :'media_urls' => :'media_urls',
79
84
  :'merchant_id' => :'merchant_id',
80
85
  :'message_dts' => :'message_dts',
81
86
  :'message_epoch' => :'message_epoch',
87
+ :'translations' => :'translations',
82
88
  :'transport_statuses' => :'transport_statuses',
83
89
  :'type' => :'type',
84
90
  :'upload_keys' => :'upload_keys'
@@ -94,10 +100,12 @@ module UltracartClient
94
100
  :'client_message_id' => :'String',
95
101
  :'conversation_message_uuid' => :'String',
96
102
  :'delay_until_dts' => :'String',
103
+ :'language_iso_code' => :'String',
97
104
  :'media_urls' => :'Array<String>',
98
105
  :'merchant_id' => :'String',
99
106
  :'message_dts' => :'String',
100
107
  :'message_epoch' => :'Integer',
108
+ :'translations' => :'Array<ConversationMessageTranslation>',
101
109
  :'transport_statuses' => :'Array<ConversationMessageTransportStatus>',
102
110
  :'type' => :'String',
103
111
  :'upload_keys' => :'Array<String>'
@@ -136,6 +144,10 @@ module UltracartClient
136
144
  self.delay_until_dts = attributes[:'delay_until_dts']
137
145
  end
138
146
 
147
+ if attributes.has_key?(:'language_iso_code')
148
+ self.language_iso_code = attributes[:'language_iso_code']
149
+ end
150
+
139
151
  if attributes.has_key?(:'media_urls')
140
152
  if (value = attributes[:'media_urls']).is_a?(Array)
141
153
  self.media_urls = value
@@ -154,6 +166,12 @@ module UltracartClient
154
166
  self.message_epoch = attributes[:'message_epoch']
155
167
  end
156
168
 
169
+ if attributes.has_key?(:'translations')
170
+ if (value = attributes[:'translations']).is_a?(Array)
171
+ self.translations = value
172
+ end
173
+ end
174
+
157
175
  if attributes.has_key?(:'transport_statuses')
158
176
  if (value = attributes[:'transport_statuses']).is_a?(Array)
159
177
  self.transport_statuses = value
@@ -207,10 +225,12 @@ module UltracartClient
207
225
  client_message_id == o.client_message_id &&
208
226
  conversation_message_uuid == o.conversation_message_uuid &&
209
227
  delay_until_dts == o.delay_until_dts &&
228
+ language_iso_code == o.language_iso_code &&
210
229
  media_urls == o.media_urls &&
211
230
  merchant_id == o.merchant_id &&
212
231
  message_dts == o.message_dts &&
213
232
  message_epoch == o.message_epoch &&
233
+ translations == o.translations &&
214
234
  transport_statuses == o.transport_statuses &&
215
235
  type == o.type &&
216
236
  upload_keys == o.upload_keys
@@ -225,7 +245,7 @@ module UltracartClient
225
245
  # Calculates hash code according to all attributes.
226
246
  # @return [Fixnum] Hash code
227
247
  def hash
228
- [author_conversation_participant_arn, author_conversation_participant_name, body, client_message_id, conversation_message_uuid, delay_until_dts, media_urls, merchant_id, message_dts, message_epoch, transport_statuses, type, upload_keys].hash
248
+ [author_conversation_participant_arn, author_conversation_participant_name, body, client_message_id, conversation_message_uuid, delay_until_dts, language_iso_code, media_urls, merchant_id, message_dts, message_epoch, translations, transport_statuses, type, upload_keys].hash
229
249
  end
230
250
 
231
251
  # Builds the object from hash
@@ -0,0 +1,193 @@
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 ConversationMessageTranslation
17
+ attr_accessor :body
18
+
19
+ attr_accessor :language_iso_code
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'body' => :'body',
25
+ :'language_iso_code' => :'language_iso_code'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.swagger_types
31
+ {
32
+ :'body' => :'String',
33
+ :'language_iso_code' => :'String'
34
+ }
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ return unless attributes.is_a?(Hash)
41
+
42
+ # convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
44
+
45
+ if attributes.has_key?(:'body')
46
+ self.body = attributes[:'body']
47
+ end
48
+
49
+ if attributes.has_key?(:'language_iso_code')
50
+ self.language_iso_code = attributes[:'language_iso_code']
51
+ end
52
+ end
53
+
54
+ # Show invalid properties with the reasons. Usually used together with valid?
55
+ # @return Array for valid properties with the reasons
56
+ def list_invalid_properties
57
+ invalid_properties = Array.new
58
+ invalid_properties
59
+ end
60
+
61
+ # Check to see if the all the properties in the model are valid
62
+ # @return true if the model is valid
63
+ def valid?
64
+ true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ body == o.body &&
73
+ language_iso_code == o.language_iso_code
74
+ end
75
+
76
+ # @see the `==` method
77
+ # @param [Object] Object to be compared
78
+ def eql?(o)
79
+ self == o
80
+ end
81
+
82
+ # Calculates hash code according to all attributes.
83
+ # @return [Fixnum] Hash code
84
+ def hash
85
+ [body, language_iso_code].hash
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.swagger_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :BOOLEAN
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ temp_model = UltracartClient.const_get(type).new
146
+ temp_model.build_from_hash(value)
147
+ end
148
+ end
149
+
150
+ # Returns the string representation of the object
151
+ # @return [String] String presentation of the object
152
+ def to_s
153
+ to_hash.to_s
154
+ end
155
+
156
+ # to_body is an alias to to_hash (backward compatibility)
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_body
159
+ to_hash
160
+ end
161
+
162
+ # Returns the object in the form of hash
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_hash
165
+ hash = {}
166
+ self.class.attribute_map.each_pair do |attr, param|
167
+ value = self.send(attr)
168
+ next if value.nil?
169
+ hash[param] = _to_hash(value)
170
+ end
171
+ hash
172
+ end
173
+
174
+ # Outputs non-array value in the form of hash
175
+ # For object, use to_hash. Otherwise, just return the value
176
+ # @param [Object] value Any valid value
177
+ # @return [Hash] Returns the value in the form of hash
178
+ def _to_hash(value)
179
+ if value.is_a?(Array)
180
+ value.compact.map { |v| _to_hash(v) }
181
+ elsif value.is_a?(Hash)
182
+ {}.tap do |hash|
183
+ value.each { |k, v| hash[k] = _to_hash(v) }
184
+ end
185
+ elsif value.respond_to? :to_hash
186
+ value.to_hash
187
+ else
188
+ value
189
+ end
190
+ end
191
+
192
+ end
193
+ end