ultracart_api 4.0.40.rc → 4.0.43.rc
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/Conversation.md +2 -0
- data/docs/ConversationApi.md +142 -0
- data/docs/ConversationEventQueuePosition.md +20 -0
- data/docs/ConversationSummary.md +2 -0
- data/docs/ConversationWebchatQueueStatus.md +38 -0
- data/docs/ConversationWebchatQueueStatusAgent.md +26 -0
- data/docs/ConversationWebchatQueueStatusQueueEntry.md +24 -0
- data/docs/ConversationWebchatQueueStatusUpdateRequest.md +18 -0
- data/docs/ConversationWebchatQueueStatusesResponse.md +26 -0
- data/docs/ConversationWebsocketMessage.md +6 -4
- data/lib/ultracart_api/api/conversation_api.rb +133 -0
- data/lib/ultracart_api/models/conversation.rb +10 -1
- data/lib/ultracart_api/models/conversation_event_queue_position.rb +230 -0
- data/lib/ultracart_api/models/conversation_summary.rb +10 -1
- data/lib/ultracart_api/models/conversation_webchat_queue_status.rb +314 -0
- data/lib/ultracart_api/models/conversation_webchat_queue_status_agent.rb +256 -0
- data/lib/ultracart_api/models/conversation_webchat_queue_status_queue_entry.rb +247 -0
- data/lib/ultracart_api/models/conversation_webchat_queue_status_update_request.rb +219 -0
- data/lib/ultracart_api/models/conversation_webchat_queue_statuses_response.rb +258 -0
- data/lib/ultracart_api/models/conversation_websocket_message.rb +16 -7
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +6 -0
- metadata +14 -2
@@ -0,0 +1,230 @@
|
|
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 ConversationEventQueuePosition
|
18
|
+
# True if agents are logged into the queue
|
19
|
+
attr_accessor :available
|
20
|
+
|
21
|
+
# Position in the queue. Value will be -1 if they cant be found in the queue.
|
22
|
+
attr_accessor :position
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'available' => :'available',
|
28
|
+
:'position' => :'position'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns all the JSON keys this model knows about
|
33
|
+
def self.acceptable_attributes
|
34
|
+
attribute_map.values
|
35
|
+
end
|
36
|
+
|
37
|
+
# Attribute type mapping.
|
38
|
+
def self.openapi_types
|
39
|
+
{
|
40
|
+
:'available' => :'Boolean',
|
41
|
+
:'position' => :'Integer'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# List of attributes with nullable: true
|
46
|
+
def self.openapi_nullable
|
47
|
+
Set.new([
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
if (!attributes.is_a?(Hash))
|
55
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationEventQueuePosition` initialize method"
|
56
|
+
end
|
57
|
+
|
58
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
59
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
60
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
61
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationEventQueuePosition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
62
|
+
end
|
63
|
+
h[k.to_sym] = v
|
64
|
+
}
|
65
|
+
|
66
|
+
if attributes.key?(:'available')
|
67
|
+
self.available = attributes[:'available']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.key?(:'position')
|
71
|
+
self.position = attributes[:'position']
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
76
|
+
# @return Array for valid properties with the reasons
|
77
|
+
def list_invalid_properties
|
78
|
+
invalid_properties = Array.new
|
79
|
+
invalid_properties
|
80
|
+
end
|
81
|
+
|
82
|
+
# Check to see if the all the properties in the model are valid
|
83
|
+
# @return true if the model is valid
|
84
|
+
def valid?
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
# Checks equality by comparing each attribute.
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def ==(o)
|
91
|
+
return true if self.equal?(o)
|
92
|
+
self.class == o.class &&
|
93
|
+
available == o.available &&
|
94
|
+
position == o.position
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Integer] Hash code
|
105
|
+
def hash
|
106
|
+
[available, position].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def self.build_from_hash(attributes)
|
113
|
+
new.build_from_hash(attributes)
|
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
|
+
attributes = attributes.transform_keys(&:to_sym)
|
122
|
+
self.class.openapi_types.each_pair do |key, type|
|
123
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
124
|
+
self.send("#{key}=", nil)
|
125
|
+
elsif type =~ /\AArray<(.*)>/i
|
126
|
+
# check to ensure the input is an array given that the attribute
|
127
|
+
# is documented as an array but the input is not
|
128
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
129
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
130
|
+
end
|
131
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
132
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
self
|
137
|
+
end
|
138
|
+
|
139
|
+
# Deserializes the data based on type
|
140
|
+
# @param string type Data type
|
141
|
+
# @param string value Value to be deserialized
|
142
|
+
# @return [Object] Deserialized data
|
143
|
+
def _deserialize(type, value)
|
144
|
+
case type.to_sym
|
145
|
+
when :Time
|
146
|
+
Time.parse(value)
|
147
|
+
when :Date
|
148
|
+
Date.parse(value)
|
149
|
+
when :String
|
150
|
+
value.to_s
|
151
|
+
when :Integer
|
152
|
+
value.to_i
|
153
|
+
when :Float
|
154
|
+
value.to_f
|
155
|
+
when :Boolean
|
156
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
157
|
+
true
|
158
|
+
else
|
159
|
+
false
|
160
|
+
end
|
161
|
+
when :Object
|
162
|
+
# generic object (usually a Hash), return directly
|
163
|
+
value
|
164
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
165
|
+
inner_type = Regexp.last_match[:inner_type]
|
166
|
+
value.map { |v| _deserialize(inner_type, v) }
|
167
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
168
|
+
k_type = Regexp.last_match[:k_type]
|
169
|
+
v_type = Regexp.last_match[:v_type]
|
170
|
+
{}.tap do |hash|
|
171
|
+
value.each do |k, v|
|
172
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
else # model
|
176
|
+
# models (e.g. Pet) or oneOf
|
177
|
+
klass = UltracartClient.const_get(type)
|
178
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
|
+
if value.nil?
|
201
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
202
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
203
|
+
end
|
204
|
+
|
205
|
+
hash[param] = _to_hash(value)
|
206
|
+
end
|
207
|
+
hash
|
208
|
+
end
|
209
|
+
|
210
|
+
# Outputs non-array value in the form of hash
|
211
|
+
# For object, use to_hash. Otherwise, just return the value
|
212
|
+
# @param [Object] value Any valid value
|
213
|
+
# @return [Hash] Returns the value in the form of hash
|
214
|
+
def _to_hash(value)
|
215
|
+
if value.is_a?(Array)
|
216
|
+
value.compact.map { |v| _to_hash(v) }
|
217
|
+
elsif value.is_a?(Hash)
|
218
|
+
{}.tap do |hash|
|
219
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
220
|
+
end
|
221
|
+
elsif value.respond_to? :to_hash
|
222
|
+
value.to_hash
|
223
|
+
else
|
224
|
+
value
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
@@ -15,6 +15,8 @@ require 'time'
|
|
15
15
|
|
16
16
|
module UltracartClient
|
17
17
|
class ConversationSummary
|
18
|
+
attr_accessor :closed
|
19
|
+
|
18
20
|
attr_accessor :conversation_arn
|
19
21
|
|
20
22
|
attr_accessor :conversation_uuid
|
@@ -37,6 +39,7 @@ module UltracartClient
|
|
37
39
|
# Attribute mapping from ruby-style variable name to JSON key.
|
38
40
|
def self.attribute_map
|
39
41
|
{
|
42
|
+
:'closed' => :'closed',
|
40
43
|
:'conversation_arn' => :'conversation_arn',
|
41
44
|
:'conversation_uuid' => :'conversation_uuid',
|
42
45
|
:'last_conversation_message_body' => :'last_conversation_message_body',
|
@@ -57,6 +60,7 @@ module UltracartClient
|
|
57
60
|
# Attribute type mapping.
|
58
61
|
def self.openapi_types
|
59
62
|
{
|
63
|
+
:'closed' => :'Boolean',
|
60
64
|
:'conversation_arn' => :'String',
|
61
65
|
:'conversation_uuid' => :'String',
|
62
66
|
:'last_conversation_message_body' => :'String',
|
@@ -90,6 +94,10 @@ module UltracartClient
|
|
90
94
|
h[k.to_sym] = v
|
91
95
|
}
|
92
96
|
|
97
|
+
if attributes.key?(:'closed')
|
98
|
+
self.closed = attributes[:'closed']
|
99
|
+
end
|
100
|
+
|
93
101
|
if attributes.key?(:'conversation_arn')
|
94
102
|
self.conversation_arn = attributes[:'conversation_arn']
|
95
103
|
end
|
@@ -145,6 +153,7 @@ module UltracartClient
|
|
145
153
|
def ==(o)
|
146
154
|
return true if self.equal?(o)
|
147
155
|
self.class == o.class &&
|
156
|
+
closed == o.closed &&
|
148
157
|
conversation_arn == o.conversation_arn &&
|
149
158
|
conversation_uuid == o.conversation_uuid &&
|
150
159
|
last_conversation_message_body == o.last_conversation_message_body &&
|
@@ -165,7 +174,7 @@ module UltracartClient
|
|
165
174
|
# Calculates hash code according to all attributes.
|
166
175
|
# @return [Integer] Hash code
|
167
176
|
def hash
|
168
|
-
[conversation_arn, conversation_uuid, last_conversation_message_body, last_conversation_participant_arn, last_conversation_participant_name, last_message_dts, merchant_id, message_count, unread_messages].hash
|
177
|
+
[closed, conversation_arn, conversation_uuid, last_conversation_message_body, last_conversation_participant_arn, last_conversation_participant_name, last_message_dts, merchant_id, message_count, unread_messages].hash
|
169
178
|
end
|
170
179
|
|
171
180
|
# Builds the object from hash
|
@@ -0,0 +1,314 @@
|
|
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 ConversationWebchatQueueStatus
|
18
|
+
attr_accessor :agent_available_count
|
19
|
+
|
20
|
+
attr_accessor :agent_busy_count
|
21
|
+
|
22
|
+
attr_accessor :agent_count
|
23
|
+
|
24
|
+
attr_accessor :agent_unavailable_count
|
25
|
+
|
26
|
+
attr_accessor :agents
|
27
|
+
|
28
|
+
attr_accessor :customer_abandon_count
|
29
|
+
|
30
|
+
attr_accessor :customer_active_count
|
31
|
+
|
32
|
+
attr_accessor :customer_waiting_count
|
33
|
+
|
34
|
+
# Date/time that the oldest person joined the queue
|
35
|
+
attr_accessor :customer_waiting_join_dts
|
36
|
+
|
37
|
+
attr_accessor :queue_entries
|
38
|
+
|
39
|
+
attr_accessor :queue_name
|
40
|
+
|
41
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
42
|
+
def self.attribute_map
|
43
|
+
{
|
44
|
+
:'agent_available_count' => :'agent_available_count',
|
45
|
+
:'agent_busy_count' => :'agent_busy_count',
|
46
|
+
:'agent_count' => :'agent_count',
|
47
|
+
:'agent_unavailable_count' => :'agent_unavailable_count',
|
48
|
+
:'agents' => :'agents',
|
49
|
+
:'customer_abandon_count' => :'customer_abandon_count',
|
50
|
+
:'customer_active_count' => :'customer_active_count',
|
51
|
+
:'customer_waiting_count' => :'customer_waiting_count',
|
52
|
+
:'customer_waiting_join_dts' => :'customer_waiting_join_dts',
|
53
|
+
:'queue_entries' => :'queue_entries',
|
54
|
+
:'queue_name' => :'queue_name'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns all the JSON keys this model knows about
|
59
|
+
def self.acceptable_attributes
|
60
|
+
attribute_map.values
|
61
|
+
end
|
62
|
+
|
63
|
+
# Attribute type mapping.
|
64
|
+
def self.openapi_types
|
65
|
+
{
|
66
|
+
:'agent_available_count' => :'Integer',
|
67
|
+
:'agent_busy_count' => :'Integer',
|
68
|
+
:'agent_count' => :'Integer',
|
69
|
+
:'agent_unavailable_count' => :'Integer',
|
70
|
+
:'agents' => :'Array<ConversationWebchatQueueStatusAgent>',
|
71
|
+
:'customer_abandon_count' => :'Integer',
|
72
|
+
:'customer_active_count' => :'Integer',
|
73
|
+
:'customer_waiting_count' => :'Integer',
|
74
|
+
:'customer_waiting_join_dts' => :'String',
|
75
|
+
:'queue_entries' => :'Array<ConversationWebchatQueueStatusQueueEntry>',
|
76
|
+
:'queue_name' => :'String'
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
# List of attributes with nullable: true
|
81
|
+
def self.openapi_nullable
|
82
|
+
Set.new([
|
83
|
+
])
|
84
|
+
end
|
85
|
+
|
86
|
+
# Initializes the object
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
def initialize(attributes = {})
|
89
|
+
if (!attributes.is_a?(Hash))
|
90
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationWebchatQueueStatus` initialize method"
|
91
|
+
end
|
92
|
+
|
93
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
94
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
95
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
96
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationWebchatQueueStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
97
|
+
end
|
98
|
+
h[k.to_sym] = v
|
99
|
+
}
|
100
|
+
|
101
|
+
if attributes.key?(:'agent_available_count')
|
102
|
+
self.agent_available_count = attributes[:'agent_available_count']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'agent_busy_count')
|
106
|
+
self.agent_busy_count = attributes[:'agent_busy_count']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'agent_count')
|
110
|
+
self.agent_count = attributes[:'agent_count']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'agent_unavailable_count')
|
114
|
+
self.agent_unavailable_count = attributes[:'agent_unavailable_count']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'agents')
|
118
|
+
if (value = attributes[:'agents']).is_a?(Array)
|
119
|
+
self.agents = value
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'customer_abandon_count')
|
124
|
+
self.customer_abandon_count = attributes[:'customer_abandon_count']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'customer_active_count')
|
128
|
+
self.customer_active_count = attributes[:'customer_active_count']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'customer_waiting_count')
|
132
|
+
self.customer_waiting_count = attributes[:'customer_waiting_count']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'customer_waiting_join_dts')
|
136
|
+
self.customer_waiting_join_dts = attributes[:'customer_waiting_join_dts']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'queue_entries')
|
140
|
+
if (value = attributes[:'queue_entries']).is_a?(Array)
|
141
|
+
self.queue_entries = value
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'queue_name')
|
146
|
+
self.queue_name = attributes[:'queue_name']
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
151
|
+
# @return Array for valid properties with the reasons
|
152
|
+
def list_invalid_properties
|
153
|
+
invalid_properties = Array.new
|
154
|
+
invalid_properties
|
155
|
+
end
|
156
|
+
|
157
|
+
# Check to see if the all the properties in the model are valid
|
158
|
+
# @return true if the model is valid
|
159
|
+
def valid?
|
160
|
+
true
|
161
|
+
end
|
162
|
+
|
163
|
+
# Checks equality by comparing each attribute.
|
164
|
+
# @param [Object] Object to be compared
|
165
|
+
def ==(o)
|
166
|
+
return true if self.equal?(o)
|
167
|
+
self.class == o.class &&
|
168
|
+
agent_available_count == o.agent_available_count &&
|
169
|
+
agent_busy_count == o.agent_busy_count &&
|
170
|
+
agent_count == o.agent_count &&
|
171
|
+
agent_unavailable_count == o.agent_unavailable_count &&
|
172
|
+
agents == o.agents &&
|
173
|
+
customer_abandon_count == o.customer_abandon_count &&
|
174
|
+
customer_active_count == o.customer_active_count &&
|
175
|
+
customer_waiting_count == o.customer_waiting_count &&
|
176
|
+
customer_waiting_join_dts == o.customer_waiting_join_dts &&
|
177
|
+
queue_entries == o.queue_entries &&
|
178
|
+
queue_name == o.queue_name
|
179
|
+
end
|
180
|
+
|
181
|
+
# @see the `==` method
|
182
|
+
# @param [Object] Object to be compared
|
183
|
+
def eql?(o)
|
184
|
+
self == o
|
185
|
+
end
|
186
|
+
|
187
|
+
# Calculates hash code according to all attributes.
|
188
|
+
# @return [Integer] Hash code
|
189
|
+
def hash
|
190
|
+
[agent_available_count, agent_busy_count, agent_count, agent_unavailable_count, agents, customer_abandon_count, customer_active_count, customer_waiting_count, customer_waiting_join_dts, queue_entries, queue_name].hash
|
191
|
+
end
|
192
|
+
|
193
|
+
# Builds the object from hash
|
194
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
195
|
+
# @return [Object] Returns the model itself
|
196
|
+
def self.build_from_hash(attributes)
|
197
|
+
new.build_from_hash(attributes)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Builds the object from hash
|
201
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
202
|
+
# @return [Object] Returns the model itself
|
203
|
+
def build_from_hash(attributes)
|
204
|
+
return nil unless attributes.is_a?(Hash)
|
205
|
+
attributes = attributes.transform_keys(&:to_sym)
|
206
|
+
self.class.openapi_types.each_pair do |key, type|
|
207
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
208
|
+
self.send("#{key}=", nil)
|
209
|
+
elsif type =~ /\AArray<(.*)>/i
|
210
|
+
# check to ensure the input is an array given that the attribute
|
211
|
+
# is documented as an array but the input is not
|
212
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
213
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
214
|
+
end
|
215
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
216
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
self
|
221
|
+
end
|
222
|
+
|
223
|
+
# Deserializes the data based on type
|
224
|
+
# @param string type Data type
|
225
|
+
# @param string value Value to be deserialized
|
226
|
+
# @return [Object] Deserialized data
|
227
|
+
def _deserialize(type, value)
|
228
|
+
case type.to_sym
|
229
|
+
when :Time
|
230
|
+
Time.parse(value)
|
231
|
+
when :Date
|
232
|
+
Date.parse(value)
|
233
|
+
when :String
|
234
|
+
value.to_s
|
235
|
+
when :Integer
|
236
|
+
value.to_i
|
237
|
+
when :Float
|
238
|
+
value.to_f
|
239
|
+
when :Boolean
|
240
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
241
|
+
true
|
242
|
+
else
|
243
|
+
false
|
244
|
+
end
|
245
|
+
when :Object
|
246
|
+
# generic object (usually a Hash), return directly
|
247
|
+
value
|
248
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
249
|
+
inner_type = Regexp.last_match[:inner_type]
|
250
|
+
value.map { |v| _deserialize(inner_type, v) }
|
251
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
252
|
+
k_type = Regexp.last_match[:k_type]
|
253
|
+
v_type = Regexp.last_match[:v_type]
|
254
|
+
{}.tap do |hash|
|
255
|
+
value.each do |k, v|
|
256
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
else # model
|
260
|
+
# models (e.g. Pet) or oneOf
|
261
|
+
klass = UltracartClient.const_get(type)
|
262
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the string representation of the object
|
267
|
+
# @return [String] String presentation of the object
|
268
|
+
def to_s
|
269
|
+
to_hash.to_s
|
270
|
+
end
|
271
|
+
|
272
|
+
# to_body is an alias to to_hash (backward compatibility)
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
274
|
+
def to_body
|
275
|
+
to_hash
|
276
|
+
end
|
277
|
+
|
278
|
+
# Returns the object in the form of hash
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
280
|
+
def to_hash
|
281
|
+
hash = {}
|
282
|
+
self.class.attribute_map.each_pair do |attr, param|
|
283
|
+
value = self.send(attr)
|
284
|
+
if value.nil?
|
285
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
286
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
287
|
+
end
|
288
|
+
|
289
|
+
hash[param] = _to_hash(value)
|
290
|
+
end
|
291
|
+
hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Outputs non-array value in the form of hash
|
295
|
+
# For object, use to_hash. Otherwise, just return the value
|
296
|
+
# @param [Object] value Any valid value
|
297
|
+
# @return [Hash] Returns the value in the form of hash
|
298
|
+
def _to_hash(value)
|
299
|
+
if value.is_a?(Array)
|
300
|
+
value.compact.map { |v| _to_hash(v) }
|
301
|
+
elsif value.is_a?(Hash)
|
302
|
+
{}.tap do |hash|
|
303
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
304
|
+
end
|
305
|
+
elsif value.respond_to? :to_hash
|
306
|
+
value.to_hash
|
307
|
+
else
|
308
|
+
value
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|