ultracart_api 3.10.19 → 3.10.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,358 @@
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 'addressable/uri'
14
+
15
+ module UltracartClient
16
+ class ConversationApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false)
24
+ api_config = Configuration.new
25
+ api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key
26
+ api_config.api_version = '2017-03-01'
27
+ api_config.verify_ssl = verify_ssl
28
+
29
+ api_client = ApiClient.new(api_config)
30
+ api_client.config.debugging = debugging
31
+
32
+ UltracartClient::ConversationApi.new(api_client)
33
+ end
34
+
35
+ # Get agent websocket authorization
36
+ # Retrieve a JWT to authorize an agent to make a websocket connection.
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [ConversationAgentAuthResponse]
39
+ def get_agent_websocket_authorization(opts = {})
40
+ data, _status_code, _headers = get_agent_websocket_authorization_with_http_info(opts)
41
+ data
42
+ end
43
+
44
+ # Get agent websocket authorization
45
+ # Retrieve a JWT to authorize an agent to make a websocket connection.
46
+ # @param [Hash] opts the optional parameters
47
+ # @return [Array<(ConversationAgentAuthResponse, Fixnum, Hash)>] ConversationAgentAuthResponse data, response status code and response headers
48
+ def get_agent_websocket_authorization_with_http_info(opts = {})
49
+ if @api_client.config.debugging
50
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_agent_websocket_authorization ...'
51
+ end
52
+ # resource path
53
+ local_var_path = '/conversation/agent/auth'
54
+
55
+ # query parameters
56
+ query_params = {}
57
+
58
+ # header parameters
59
+ header_params = {}
60
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
61
+ # HTTP header 'Accept' (if needed)
62
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
63
+ # HTTP header 'Content-Type'
64
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
65
+
66
+ # form parameters
67
+ form_params = {}
68
+
69
+ # http body (model)
70
+ post_body = nil
71
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
72
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
73
+ :header_params => header_params,
74
+ :query_params => query_params,
75
+ :form_params => form_params,
76
+ :body => post_body,
77
+ :auth_names => auth_names,
78
+ :return_type => 'ConversationAgentAuthResponse')
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: ConversationApi#get_agent_websocket_authorization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+ # Retrieve a conversation
85
+ # Retrieve a conversation including the participants and messages
86
+ # @param conversation_uuid
87
+ # @param [Hash] opts the optional parameters
88
+ # @return [Conversation]
89
+ def get_conversation(conversation_uuid, opts = {})
90
+ data, _status_code, _headers = get_conversation_with_http_info(conversation_uuid, opts)
91
+ data
92
+ end
93
+
94
+ # Retrieve a conversation
95
+ # Retrieve a conversation including the participants and messages
96
+ # @param conversation_uuid
97
+ # @param [Hash] opts the optional parameters
98
+ # @return [Array<(Conversation, Fixnum, Hash)>] Conversation data, response status code and response headers
99
+ def get_conversation_with_http_info(conversation_uuid, opts = {})
100
+ if @api_client.config.debugging
101
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_conversation ...'
102
+ end
103
+ # verify the required parameter 'conversation_uuid' is set
104
+ if @api_client.config.client_side_validation && conversation_uuid.nil?
105
+ fail ArgumentError, "Missing the required parameter 'conversation_uuid' when calling ConversationApi.get_conversation"
106
+ end
107
+ # resource path
108
+ local_var_path = '/conversation/conversations/{conversation_uuid}'.sub('{' + 'conversation_uuid' + '}', conversation_uuid.to_s)
109
+
110
+ # query parameters
111
+ query_params = {}
112
+
113
+ # header parameters
114
+ header_params = {}
115
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
116
+ # HTTP header 'Accept' (if needed)
117
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
118
+ # HTTP header 'Content-Type'
119
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
120
+
121
+ # form parameters
122
+ form_params = {}
123
+
124
+ # http body (model)
125
+ post_body = nil
126
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
127
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
128
+ :header_params => header_params,
129
+ :query_params => query_params,
130
+ :form_params => form_params,
131
+ :body => post_body,
132
+ :auth_names => auth_names,
133
+ :return_type => 'Conversation')
134
+ if @api_client.config.debugging
135
+ @api_client.config.logger.debug "API called: ConversationApi#get_conversation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
136
+ end
137
+ return data, status_code, headers
138
+ end
139
+ # Retrieve a list of conversation summaries newest to oldest
140
+ # Retrieve a list of conversation summaries that are ordered newest to oldest, include the most recent message and whether its been read.
141
+ # @param [Hash] opts the optional parameters
142
+ # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Max 200) (default to 100)
143
+ # @option opts [Integer] :_offset Pagination of the record set. Offset is a zero based index. (default to 0)
144
+ # @return [ConversationsResponse]
145
+ def get_conversations(opts = {})
146
+ data, _status_code, _headers = get_conversations_with_http_info(opts)
147
+ data
148
+ end
149
+
150
+ # Retrieve a list of conversation summaries newest to oldest
151
+ # Retrieve a list of conversation summaries that are ordered newest to oldest, include the most recent message and whether its been read.
152
+ # @param [Hash] opts the optional parameters
153
+ # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Max 200)
154
+ # @option opts [Integer] :_offset Pagination of the record set. Offset is a zero based index.
155
+ # @return [Array<(ConversationsResponse, Fixnum, Hash)>] ConversationsResponse data, response status code and response headers
156
+ def get_conversations_with_http_info(opts = {})
157
+ if @api_client.config.debugging
158
+ @api_client.config.logger.debug 'Calling API: ConversationApi.get_conversations ...'
159
+ end
160
+ # resource path
161
+ local_var_path = '/conversation/conversations'
162
+
163
+ # query parameters
164
+ query_params = {}
165
+ query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?
166
+ query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?
167
+
168
+ # header parameters
169
+ header_params = {}
170
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
171
+ # HTTP header 'Accept' (if needed)
172
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
173
+ # HTTP header 'Content-Type'
174
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
175
+
176
+ # form parameters
177
+ form_params = {}
178
+
179
+ # http body (model)
180
+ post_body = nil
181
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
182
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
183
+ :header_params => header_params,
184
+ :query_params => query_params,
185
+ :form_params => form_params,
186
+ :body => post_body,
187
+ :auth_names => auth_names,
188
+ :return_type => 'ConversationsResponse')
189
+ if @api_client.config.debugging
190
+ @api_client.config.logger.debug "API called: ConversationApi#get_conversations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
191
+ end
192
+ return data, status_code, headers
193
+ end
194
+ # Join a conversation
195
+ # Join a conversation
196
+ # @param conversation_uuid
197
+ # @param [Hash] opts the optional parameters
198
+ # @return [nil]
199
+ def join_conversation(conversation_uuid, opts = {})
200
+ join_conversation_with_http_info(conversation_uuid, opts)
201
+ nil
202
+ end
203
+
204
+ # Join a conversation
205
+ # Join a conversation
206
+ # @param conversation_uuid
207
+ # @param [Hash] opts the optional parameters
208
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
209
+ def join_conversation_with_http_info(conversation_uuid, opts = {})
210
+ if @api_client.config.debugging
211
+ @api_client.config.logger.debug 'Calling API: ConversationApi.join_conversation ...'
212
+ end
213
+ # verify the required parameter 'conversation_uuid' is set
214
+ if @api_client.config.client_side_validation && conversation_uuid.nil?
215
+ fail ArgumentError, "Missing the required parameter 'conversation_uuid' when calling ConversationApi.join_conversation"
216
+ end
217
+ # resource path
218
+ local_var_path = '/conversation/conversations/{conversation_uuid}/join'.sub('{' + 'conversation_uuid' + '}', conversation_uuid.to_s)
219
+
220
+ # query parameters
221
+ query_params = {}
222
+
223
+ # header parameters
224
+ header_params = {}
225
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
226
+ # HTTP header 'Accept' (if needed)
227
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
228
+ # HTTP header 'Content-Type'
229
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
230
+
231
+ # form parameters
232
+ form_params = {}
233
+
234
+ # http body (model)
235
+ post_body = nil
236
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
237
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
238
+ :header_params => header_params,
239
+ :query_params => query_params,
240
+ :form_params => form_params,
241
+ :body => post_body,
242
+ :auth_names => auth_names)
243
+ if @api_client.config.debugging
244
+ @api_client.config.logger.debug "API called: ConversationApi#join_conversation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
245
+ end
246
+ return data, status_code, headers
247
+ end
248
+ # Leave a conversation
249
+ # Leave a conversation
250
+ # @param conversation_uuid
251
+ # @param [Hash] opts the optional parameters
252
+ # @return [nil]
253
+ def leave_conversation(conversation_uuid, opts = {})
254
+ leave_conversation_with_http_info(conversation_uuid, opts)
255
+ nil
256
+ end
257
+
258
+ # Leave a conversation
259
+ # Leave a conversation
260
+ # @param conversation_uuid
261
+ # @param [Hash] opts the optional parameters
262
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
263
+ def leave_conversation_with_http_info(conversation_uuid, opts = {})
264
+ if @api_client.config.debugging
265
+ @api_client.config.logger.debug 'Calling API: ConversationApi.leave_conversation ...'
266
+ end
267
+ # verify the required parameter 'conversation_uuid' is set
268
+ if @api_client.config.client_side_validation && conversation_uuid.nil?
269
+ fail ArgumentError, "Missing the required parameter 'conversation_uuid' when calling ConversationApi.leave_conversation"
270
+ end
271
+ # resource path
272
+ local_var_path = '/conversation/conversations/{conversation_uuid}/leave'.sub('{' + 'conversation_uuid' + '}', conversation_uuid.to_s)
273
+
274
+ # query parameters
275
+ query_params = {}
276
+
277
+ # header parameters
278
+ header_params = {}
279
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
280
+ # HTTP header 'Accept' (if needed)
281
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
282
+ # HTTP header 'Content-Type'
283
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
284
+
285
+ # form parameters
286
+ form_params = {}
287
+
288
+ # http body (model)
289
+ post_body = nil
290
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
291
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
292
+ :header_params => header_params,
293
+ :query_params => query_params,
294
+ :form_params => form_params,
295
+ :body => post_body,
296
+ :auth_names => auth_names)
297
+ if @api_client.config.debugging
298
+ @api_client.config.logger.debug "API called: ConversationApi#leave_conversation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
299
+ end
300
+ return data, status_code, headers
301
+ end
302
+ # Start a conversation
303
+ # Start a new conversation
304
+ # @param start_request Start request
305
+ # @param [Hash] opts the optional parameters
306
+ # @return [ConversationStartResponse]
307
+ def start_conversation(start_request, opts = {})
308
+ data, _status_code, _headers = start_conversation_with_http_info(start_request, opts)
309
+ data
310
+ end
311
+
312
+ # Start a conversation
313
+ # Start a new conversation
314
+ # @param start_request Start request
315
+ # @param [Hash] opts the optional parameters
316
+ # @return [Array<(ConversationStartResponse, Fixnum, Hash)>] ConversationStartResponse data, response status code and response headers
317
+ def start_conversation_with_http_info(start_request, opts = {})
318
+ if @api_client.config.debugging
319
+ @api_client.config.logger.debug 'Calling API: ConversationApi.start_conversation ...'
320
+ end
321
+ # verify the required parameter 'start_request' is set
322
+ if @api_client.config.client_side_validation && start_request.nil?
323
+ fail ArgumentError, "Missing the required parameter 'start_request' when calling ConversationApi.start_conversation"
324
+ end
325
+ # resource path
326
+ local_var_path = '/conversation/conversations'
327
+
328
+ # query parameters
329
+ query_params = {}
330
+
331
+ # header parameters
332
+ header_params = {}
333
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
334
+ # HTTP header 'Accept' (if needed)
335
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
336
+ # HTTP header 'Content-Type'
337
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
338
+
339
+ # form parameters
340
+ form_params = {}
341
+
342
+ # http body (model)
343
+ post_body = @api_client.object_to_http_body(start_request)
344
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
345
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
346
+ :header_params => header_params,
347
+ :query_params => query_params,
348
+ :form_params => form_params,
349
+ :body => post_body,
350
+ :auth_names => auth_names,
351
+ :return_type => 'ConversationStartResponse')
352
+ if @api_client.config.debugging
353
+ @api_client.config.logger.debug "API called: ConversationApi#start_conversation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
354
+ end
355
+ return data, status_code, headers
356
+ end
357
+ end
358
+ end
@@ -16,8 +16,12 @@ module UltracartClient
16
16
  class Activity
17
17
  attr_accessor :action
18
18
 
19
+ attr_accessor :channel
20
+
19
21
  attr_accessor :metric
20
22
 
23
+ attr_accessor :storefront_oid
24
+
21
25
  attr_accessor :subject
22
26
 
23
27
  attr_accessor :ts
@@ -30,7 +34,9 @@ module UltracartClient
30
34
  def self.attribute_map
31
35
  {
32
36
  :'action' => :'action',
37
+ :'channel' => :'channel',
33
38
  :'metric' => :'metric',
39
+ :'storefront_oid' => :'storefront_oid',
34
40
  :'subject' => :'subject',
35
41
  :'ts' => :'ts',
36
42
  :'type' => :'type',
@@ -42,7 +48,9 @@ module UltracartClient
42
48
  def self.swagger_types
43
49
  {
44
50
  :'action' => :'String',
51
+ :'channel' => :'String',
45
52
  :'metric' => :'String',
53
+ :'storefront_oid' => :'Integer',
46
54
  :'subject' => :'String',
47
55
  :'ts' => :'Integer',
48
56
  :'type' => :'String',
@@ -62,10 +70,18 @@ module UltracartClient
62
70
  self.action = attributes[:'action']
63
71
  end
64
72
 
73
+ if attributes.has_key?(:'channel')
74
+ self.channel = attributes[:'channel']
75
+ end
76
+
65
77
  if attributes.has_key?(:'metric')
66
78
  self.metric = attributes[:'metric']
67
79
  end
68
80
 
81
+ if attributes.has_key?(:'storefront_oid')
82
+ self.storefront_oid = attributes[:'storefront_oid']
83
+ end
84
+
69
85
  if attributes.has_key?(:'subject')
70
86
  self.subject = attributes[:'subject']
71
87
  end
@@ -102,7 +118,9 @@ module UltracartClient
102
118
  return true if self.equal?(o)
103
119
  self.class == o.class &&
104
120
  action == o.action &&
121
+ channel == o.channel &&
105
122
  metric == o.metric &&
123
+ storefront_oid == o.storefront_oid &&
106
124
  subject == o.subject &&
107
125
  ts == o.ts &&
108
126
  type == o.type &&
@@ -118,7 +136,7 @@ module UltracartClient
118
136
  # Calculates hash code according to all attributes.
119
137
  # @return [Fixnum] Hash code
120
138
  def hash
121
- [action, metric, subject, ts, type, uuid].hash
139
+ [action, channel, metric, storefront_oid, subject, ts, type, uuid].hash
122
140
  end
123
141
 
124
142
  # Builds the object from hash
@@ -0,0 +1,224 @@
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 Conversation
17
+ attr_accessor :conversation_arn
18
+
19
+ attr_accessor :conversation_uuid
20
+
21
+ attr_accessor :merchant_id
22
+
23
+ attr_accessor :messages
24
+
25
+ attr_accessor :participants
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'conversation_arn' => :'conversation_arn',
31
+ :'conversation_uuid' => :'conversation_uuid',
32
+ :'merchant_id' => :'merchant_id',
33
+ :'messages' => :'messages',
34
+ :'participants' => :'participants'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.swagger_types
40
+ {
41
+ :'conversation_arn' => :'String',
42
+ :'conversation_uuid' => :'String',
43
+ :'merchant_id' => :'String',
44
+ :'messages' => :'Array<ConversationMessage>',
45
+ :'participants' => :'Array<ConversationParticipant>'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
56
+
57
+ if attributes.has_key?(:'conversation_arn')
58
+ self.conversation_arn = attributes[:'conversation_arn']
59
+ end
60
+
61
+ if attributes.has_key?(:'conversation_uuid')
62
+ self.conversation_uuid = attributes[:'conversation_uuid']
63
+ end
64
+
65
+ if attributes.has_key?(:'merchant_id')
66
+ self.merchant_id = attributes[:'merchant_id']
67
+ end
68
+
69
+ if attributes.has_key?(:'messages')
70
+ if (value = attributes[:'messages']).is_a?(Array)
71
+ self.messages = value
72
+ end
73
+ end
74
+
75
+ if attributes.has_key?(:'participants')
76
+ if (value = attributes[:'participants']).is_a?(Array)
77
+ self.participants = value
78
+ end
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ invalid_properties = Array.new
86
+ invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ true
93
+ end
94
+
95
+ # Checks equality by comparing each attribute.
96
+ # @param [Object] Object to be compared
97
+ def ==(o)
98
+ return true if self.equal?(o)
99
+ self.class == o.class &&
100
+ conversation_arn == o.conversation_arn &&
101
+ conversation_uuid == o.conversation_uuid &&
102
+ merchant_id == o.merchant_id &&
103
+ messages == o.messages &&
104
+ participants == o.participants
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Fixnum] Hash code
115
+ def hash
116
+ [conversation_arn, conversation_uuid, merchant_id, messages, participants].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ self.class.swagger_types.each_pair do |key, type|
125
+ if 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 # or else data not found in attributes(hash), not an issue as the data can be optional
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 :DateTime
146
+ DateTime.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
+ temp_model = UltracartClient.const_get(type).new
177
+ temp_model.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ next if value.nil?
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+ end