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