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