ultracart_api 3.10.182 → 3.10.184

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -4
  3. data/docs/ConversationAgentAuth.md +4 -0
  4. data/docs/CouponAmountOffItems.md +1 -0
  5. data/docs/CouponBuyOneGetOneLimit.md +1 -0
  6. data/docs/CouponDiscountItemWithItemPurchase.md +2 -0
  7. data/docs/CouponFreeItemWithItemPurchase.md +2 -0
  8. data/docs/CouponPercentOffItemsWithItemsPurchase.md +2 -0
  9. data/docs/EmailSmsOrder.md +11 -0
  10. data/docs/EmailSmsOrdersResponse.md +12 -0
  11. data/docs/EmailSmsStat.md +37 -0
  12. data/docs/EmailStatSmsSummaryRequest.md +9 -0
  13. data/docs/EmailStatSmsSummaryResponse.md +12 -0
  14. data/docs/PricingTier.md +1 -0
  15. data/docs/StorefrontApi.md +114 -0
  16. data/docs/Twilio.md +9 -0
  17. data/lib/ultracart_api/api/storefront_api.rb +133 -0
  18. data/lib/ultracart_api/models/conversation_agent_auth.rb +37 -1
  19. data/lib/ultracart_api/models/coupon_amount_off_items.rb +13 -1
  20. data/lib/ultracart_api/models/coupon_buy_one_get_one_limit.rb +13 -1
  21. data/lib/ultracart_api/models/coupon_discount_item_with_item_purchase.rb +28 -4
  22. data/lib/ultracart_api/models/coupon_free_item_with_item_purchase.rb +28 -4
  23. data/lib/ultracart_api/models/coupon_percent_off_items_with_items_purchase.rb +28 -4
  24. data/lib/ultracart_api/models/email_sms_order.rb +214 -0
  25. data/lib/ultracart_api/models/email_sms_orders_response.rb +223 -0
  26. data/lib/ultracart_api/models/email_sms_stat.rb +476 -0
  27. data/lib/ultracart_api/models/email_stat_sms_summary_request.rb +195 -0
  28. data/lib/ultracart_api/models/email_stat_sms_summary_response.rb +223 -0
  29. data/lib/ultracart_api/models/pricing_tier.rb +11 -1
  30. data/lib/ultracart_api/models/twilio.rb +85 -4
  31. data/lib/ultracart_api/version.rb +1 -1
  32. data/lib/ultracart_api.rb +5 -0
  33. metadata +12 -2
@@ -0,0 +1,223 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class EmailSmsOrdersResponse
17
+ attr_accessor :error
18
+
19
+ attr_accessor :metadata
20
+
21
+ attr_accessor :orders
22
+
23
+ # Indicates if API call was successful
24
+ attr_accessor :success
25
+
26
+ attr_accessor :warning
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'error' => :'error',
32
+ :'metadata' => :'metadata',
33
+ :'orders' => :'orders',
34
+ :'success' => :'success',
35
+ :'warning' => :'warning'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'error' => :'Error',
43
+ :'metadata' => :'ResponseMetadata',
44
+ :'orders' => :'Array<EmailSmsOrder>',
45
+ :'success' => :'BOOLEAN',
46
+ :'warning' => :'Warning'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+
58
+ if attributes.has_key?(:'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?(:'orders')
67
+ if (value = attributes[:'orders']).is_a?(Array)
68
+ self.orders = value
69
+ end
70
+ end
71
+
72
+ if attributes.has_key?(:'success')
73
+ self.success = attributes[:'success']
74
+ end
75
+
76
+ if attributes.has_key?(:'warning')
77
+ self.warning = attributes[:'warning']
78
+ end
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ error == o.error &&
100
+ metadata == o.metadata &&
101
+ orders == o.orders &&
102
+ success == o.success &&
103
+ warning == o.warning
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Fixnum] Hash code
114
+ def hash
115
+ [error, metadata, orders, success, warning].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.swagger_types.each_pair do |key, type|
124
+ if type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BOOLEAN
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ temp_model = UltracartClient.const_get(type).new
176
+ temp_model.build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ next if value.nil?
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ # Outputs non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ # @param [Object] value Any valid value
207
+ # @return [Hash] Returns the value in the form of hash
208
+ def _to_hash(value)
209
+ if value.is_a?(Array)
210
+ value.compact.map { |v| _to_hash(v) }
211
+ elsif value.is_a?(Hash)
212
+ {}.tap do |hash|
213
+ value.each { |k, v| hash[k] = _to_hash(v) }
214
+ end
215
+ elsif value.respond_to? :to_hash
216
+ value.to_hash
217
+ else
218
+ value
219
+ end
220
+ end
221
+
222
+ end
223
+ end
@@ -0,0 +1,476 @@
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 EmailSmsStat
17
+ # Count of clicked emails
18
+ attr_accessor :click_count
19
+
20
+ # Count of clicked emails, formatted
21
+ attr_accessor :click_count_formatted
22
+
23
+ # Count of conversions
24
+ attr_accessor :conversion_count
25
+
26
+ # Count of conversions, formatted
27
+ attr_accessor :conversion_count_formatted
28
+
29
+ # True if campaign/flow has been archived
30
+ attr_accessor :deleted
31
+
32
+ # Count of delivered emails
33
+ attr_accessor :delivered_count
34
+
35
+ # Count of delivered emails, formatted
36
+ attr_accessor :delivered_count_formatted
37
+
38
+ # Merchant ID
39
+ attr_accessor :merchant_id
40
+
41
+ # List or segment name
42
+ attr_accessor :name
43
+
44
+ # Count of orders
45
+ attr_accessor :order_count
46
+
47
+ # Count of orders, formatted
48
+ attr_accessor :order_count_formatted
49
+
50
+ # Profit
51
+ attr_accessor :profit
52
+
53
+ # Profit, formatted
54
+ attr_accessor :profit_formatted
55
+
56
+ # Revenue
57
+ attr_accessor :revenue
58
+
59
+ # Revenue, formatted
60
+ attr_accessor :revenue_formatted
61
+
62
+ # Count of emails sent
63
+ attr_accessor :send_count
64
+
65
+ # Count of emails sent, formatted
66
+ attr_accessor :send_count_formatted
67
+
68
+ # Count of skipped emails
69
+ attr_accessor :skipped_count
70
+
71
+ # Count of skipped emails, formatted
72
+ attr_accessor :skipped_count_formatted
73
+
74
+ # Campaign, Flow or None (for anything else)
75
+ attr_accessor :stat_type
76
+
77
+ # Status of campaign or flow
78
+ attr_accessor :status
79
+
80
+ # Status dts of campaign or flow
81
+ attr_accessor :status_dts
82
+
83
+ # Step UUID if the statistics are at the step/email level
84
+ attr_accessor :step_uuid
85
+
86
+ attr_accessor :steps
87
+
88
+ # Storefront oid
89
+ attr_accessor :storefront_oid
90
+
91
+ # Count of emails classified as unsubscribe
92
+ attr_accessor :unsubscribe_count
93
+
94
+ # Count of emails classified as unsubscribe, formatted
95
+ attr_accessor :unsubscribe_count_formatted
96
+
97
+ # List/Segment uuid, or Flow/Campaign uuid depending on level of stat aggregation.
98
+ attr_accessor :uuid
99
+
100
+ # Count of views
101
+ attr_accessor :view_count
102
+
103
+ # Count of views, formatted
104
+ attr_accessor :view_count_formatted
105
+
106
+ # Attribute mapping from ruby-style variable name to JSON key.
107
+ def self.attribute_map
108
+ {
109
+ :'click_count' => :'click_count',
110
+ :'click_count_formatted' => :'click_count_formatted',
111
+ :'conversion_count' => :'conversion_count',
112
+ :'conversion_count_formatted' => :'conversion_count_formatted',
113
+ :'deleted' => :'deleted',
114
+ :'delivered_count' => :'delivered_count',
115
+ :'delivered_count_formatted' => :'delivered_count_formatted',
116
+ :'merchant_id' => :'merchant_id',
117
+ :'name' => :'name',
118
+ :'order_count' => :'order_count',
119
+ :'order_count_formatted' => :'order_count_formatted',
120
+ :'profit' => :'profit',
121
+ :'profit_formatted' => :'profit_formatted',
122
+ :'revenue' => :'revenue',
123
+ :'revenue_formatted' => :'revenue_formatted',
124
+ :'send_count' => :'send_count',
125
+ :'send_count_formatted' => :'send_count_formatted',
126
+ :'skipped_count' => :'skipped_count',
127
+ :'skipped_count_formatted' => :'skipped_count_formatted',
128
+ :'stat_type' => :'stat_type',
129
+ :'status' => :'status',
130
+ :'status_dts' => :'status_dts',
131
+ :'step_uuid' => :'step_uuid',
132
+ :'steps' => :'steps',
133
+ :'storefront_oid' => :'storefront_oid',
134
+ :'unsubscribe_count' => :'unsubscribe_count',
135
+ :'unsubscribe_count_formatted' => :'unsubscribe_count_formatted',
136
+ :'uuid' => :'uuid',
137
+ :'view_count' => :'view_count',
138
+ :'view_count_formatted' => :'view_count_formatted'
139
+ }
140
+ end
141
+
142
+ # Attribute type mapping.
143
+ def self.swagger_types
144
+ {
145
+ :'click_count' => :'Integer',
146
+ :'click_count_formatted' => :'String',
147
+ :'conversion_count' => :'Integer',
148
+ :'conversion_count_formatted' => :'String',
149
+ :'deleted' => :'BOOLEAN',
150
+ :'delivered_count' => :'Integer',
151
+ :'delivered_count_formatted' => :'String',
152
+ :'merchant_id' => :'String',
153
+ :'name' => :'String',
154
+ :'order_count' => :'Integer',
155
+ :'order_count_formatted' => :'String',
156
+ :'profit' => :'Float',
157
+ :'profit_formatted' => :'String',
158
+ :'revenue' => :'Float',
159
+ :'revenue_formatted' => :'String',
160
+ :'send_count' => :'Integer',
161
+ :'send_count_formatted' => :'String',
162
+ :'skipped_count' => :'Integer',
163
+ :'skipped_count_formatted' => :'String',
164
+ :'stat_type' => :'String',
165
+ :'status' => :'String',
166
+ :'status_dts' => :'String',
167
+ :'step_uuid' => :'String',
168
+ :'steps' => :'Array<EmailSmsStat>',
169
+ :'storefront_oid' => :'Integer',
170
+ :'unsubscribe_count' => :'Integer',
171
+ :'unsubscribe_count_formatted' => :'String',
172
+ :'uuid' => :'String',
173
+ :'view_count' => :'Integer',
174
+ :'view_count_formatted' => :'String'
175
+ }
176
+ end
177
+
178
+ # Initializes the object
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ def initialize(attributes = {})
181
+ return unless attributes.is_a?(Hash)
182
+
183
+ # convert string to symbol for hash key
184
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
185
+
186
+ if attributes.has_key?(:'click_count')
187
+ self.click_count = attributes[:'click_count']
188
+ end
189
+
190
+ if attributes.has_key?(:'click_count_formatted')
191
+ self.click_count_formatted = attributes[:'click_count_formatted']
192
+ end
193
+
194
+ if attributes.has_key?(:'conversion_count')
195
+ self.conversion_count = attributes[:'conversion_count']
196
+ end
197
+
198
+ if attributes.has_key?(:'conversion_count_formatted')
199
+ self.conversion_count_formatted = attributes[:'conversion_count_formatted']
200
+ end
201
+
202
+ if attributes.has_key?(:'deleted')
203
+ self.deleted = attributes[:'deleted']
204
+ end
205
+
206
+ if attributes.has_key?(:'delivered_count')
207
+ self.delivered_count = attributes[:'delivered_count']
208
+ end
209
+
210
+ if attributes.has_key?(:'delivered_count_formatted')
211
+ self.delivered_count_formatted = attributes[:'delivered_count_formatted']
212
+ end
213
+
214
+ if attributes.has_key?(:'merchant_id')
215
+ self.merchant_id = attributes[:'merchant_id']
216
+ end
217
+
218
+ if attributes.has_key?(:'name')
219
+ self.name = attributes[:'name']
220
+ end
221
+
222
+ if attributes.has_key?(:'order_count')
223
+ self.order_count = attributes[:'order_count']
224
+ end
225
+
226
+ if attributes.has_key?(:'order_count_formatted')
227
+ self.order_count_formatted = attributes[:'order_count_formatted']
228
+ end
229
+
230
+ if attributes.has_key?(:'profit')
231
+ self.profit = attributes[:'profit']
232
+ end
233
+
234
+ if attributes.has_key?(:'profit_formatted')
235
+ self.profit_formatted = attributes[:'profit_formatted']
236
+ end
237
+
238
+ if attributes.has_key?(:'revenue')
239
+ self.revenue = attributes[:'revenue']
240
+ end
241
+
242
+ if attributes.has_key?(:'revenue_formatted')
243
+ self.revenue_formatted = attributes[:'revenue_formatted']
244
+ end
245
+
246
+ if attributes.has_key?(:'send_count')
247
+ self.send_count = attributes[:'send_count']
248
+ end
249
+
250
+ if attributes.has_key?(:'send_count_formatted')
251
+ self.send_count_formatted = attributes[:'send_count_formatted']
252
+ end
253
+
254
+ if attributes.has_key?(:'skipped_count')
255
+ self.skipped_count = attributes[:'skipped_count']
256
+ end
257
+
258
+ if attributes.has_key?(:'skipped_count_formatted')
259
+ self.skipped_count_formatted = attributes[:'skipped_count_formatted']
260
+ end
261
+
262
+ if attributes.has_key?(:'stat_type')
263
+ self.stat_type = attributes[:'stat_type']
264
+ end
265
+
266
+ if attributes.has_key?(:'status')
267
+ self.status = attributes[:'status']
268
+ end
269
+
270
+ if attributes.has_key?(:'status_dts')
271
+ self.status_dts = attributes[:'status_dts']
272
+ end
273
+
274
+ if attributes.has_key?(:'step_uuid')
275
+ self.step_uuid = attributes[:'step_uuid']
276
+ end
277
+
278
+ if attributes.has_key?(:'steps')
279
+ if (value = attributes[:'steps']).is_a?(Array)
280
+ self.steps = value
281
+ end
282
+ end
283
+
284
+ if attributes.has_key?(:'storefront_oid')
285
+ self.storefront_oid = attributes[:'storefront_oid']
286
+ end
287
+
288
+ if attributes.has_key?(:'unsubscribe_count')
289
+ self.unsubscribe_count = attributes[:'unsubscribe_count']
290
+ end
291
+
292
+ if attributes.has_key?(:'unsubscribe_count_formatted')
293
+ self.unsubscribe_count_formatted = attributes[:'unsubscribe_count_formatted']
294
+ end
295
+
296
+ if attributes.has_key?(:'uuid')
297
+ self.uuid = attributes[:'uuid']
298
+ end
299
+
300
+ if attributes.has_key?(:'view_count')
301
+ self.view_count = attributes[:'view_count']
302
+ end
303
+
304
+ if attributes.has_key?(:'view_count_formatted')
305
+ self.view_count_formatted = attributes[:'view_count_formatted']
306
+ end
307
+ end
308
+
309
+ # Show invalid properties with the reasons. Usually used together with valid?
310
+ # @return Array for valid properties with the reasons
311
+ def list_invalid_properties
312
+ invalid_properties = Array.new
313
+ invalid_properties
314
+ end
315
+
316
+ # Check to see if the all the properties in the model are valid
317
+ # @return true if the model is valid
318
+ def valid?
319
+ true
320
+ end
321
+
322
+ # Checks equality by comparing each attribute.
323
+ # @param [Object] Object to be compared
324
+ def ==(o)
325
+ return true if self.equal?(o)
326
+ self.class == o.class &&
327
+ click_count == o.click_count &&
328
+ click_count_formatted == o.click_count_formatted &&
329
+ conversion_count == o.conversion_count &&
330
+ conversion_count_formatted == o.conversion_count_formatted &&
331
+ deleted == o.deleted &&
332
+ delivered_count == o.delivered_count &&
333
+ delivered_count_formatted == o.delivered_count_formatted &&
334
+ merchant_id == o.merchant_id &&
335
+ name == o.name &&
336
+ order_count == o.order_count &&
337
+ order_count_formatted == o.order_count_formatted &&
338
+ profit == o.profit &&
339
+ profit_formatted == o.profit_formatted &&
340
+ revenue == o.revenue &&
341
+ revenue_formatted == o.revenue_formatted &&
342
+ send_count == o.send_count &&
343
+ send_count_formatted == o.send_count_formatted &&
344
+ skipped_count == o.skipped_count &&
345
+ skipped_count_formatted == o.skipped_count_formatted &&
346
+ stat_type == o.stat_type &&
347
+ status == o.status &&
348
+ status_dts == o.status_dts &&
349
+ step_uuid == o.step_uuid &&
350
+ steps == o.steps &&
351
+ storefront_oid == o.storefront_oid &&
352
+ unsubscribe_count == o.unsubscribe_count &&
353
+ unsubscribe_count_formatted == o.unsubscribe_count_formatted &&
354
+ uuid == o.uuid &&
355
+ view_count == o.view_count &&
356
+ view_count_formatted == o.view_count_formatted
357
+ end
358
+
359
+ # @see the `==` method
360
+ # @param [Object] Object to be compared
361
+ def eql?(o)
362
+ self == o
363
+ end
364
+
365
+ # Calculates hash code according to all attributes.
366
+ # @return [Fixnum] Hash code
367
+ def hash
368
+ [click_count, click_count_formatted, conversion_count, conversion_count_formatted, deleted, delivered_count, delivered_count_formatted, merchant_id, name, order_count, order_count_formatted, profit, profit_formatted, revenue, revenue_formatted, send_count, send_count_formatted, skipped_count, skipped_count_formatted, stat_type, status, status_dts, step_uuid, steps, storefront_oid, unsubscribe_count, unsubscribe_count_formatted, uuid, view_count, view_count_formatted].hash
369
+ end
370
+
371
+ # Builds the object from hash
372
+ # @param [Hash] attributes Model attributes in the form of hash
373
+ # @return [Object] Returns the model itself
374
+ def build_from_hash(attributes)
375
+ return nil unless attributes.is_a?(Hash)
376
+ self.class.swagger_types.each_pair do |key, type|
377
+ if type =~ /\AArray<(.*)>/i
378
+ # check to ensure the input is an array given that the attribute
379
+ # is documented as an array but the input is not
380
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
381
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
382
+ end
383
+ elsif !attributes[self.class.attribute_map[key]].nil?
384
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
385
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
386
+ end
387
+
388
+ self
389
+ end
390
+
391
+ # Deserializes the data based on type
392
+ # @param string type Data type
393
+ # @param string value Value to be deserialized
394
+ # @return [Object] Deserialized data
395
+ def _deserialize(type, value)
396
+ case type.to_sym
397
+ when :DateTime
398
+ DateTime.parse(value)
399
+ when :Date
400
+ Date.parse(value)
401
+ when :String
402
+ value.to_s
403
+ when :Integer
404
+ value.to_i
405
+ when :Float
406
+ value.to_f
407
+ when :BOOLEAN
408
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
409
+ true
410
+ else
411
+ false
412
+ end
413
+ when :Object
414
+ # generic object (usually a Hash), return directly
415
+ value
416
+ when /\AArray<(?<inner_type>.+)>\z/
417
+ inner_type = Regexp.last_match[:inner_type]
418
+ value.map { |v| _deserialize(inner_type, v) }
419
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
420
+ k_type = Regexp.last_match[:k_type]
421
+ v_type = Regexp.last_match[:v_type]
422
+ {}.tap do |hash|
423
+ value.each do |k, v|
424
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
425
+ end
426
+ end
427
+ else # model
428
+ temp_model = UltracartClient.const_get(type).new
429
+ temp_model.build_from_hash(value)
430
+ end
431
+ end
432
+
433
+ # Returns the string representation of the object
434
+ # @return [String] String presentation of the object
435
+ def to_s
436
+ to_hash.to_s
437
+ end
438
+
439
+ # to_body is an alias to to_hash (backward compatibility)
440
+ # @return [Hash] Returns the object in the form of hash
441
+ def to_body
442
+ to_hash
443
+ end
444
+
445
+ # Returns the object in the form of hash
446
+ # @return [Hash] Returns the object in the form of hash
447
+ def to_hash
448
+ hash = {}
449
+ self.class.attribute_map.each_pair do |attr, param|
450
+ value = self.send(attr)
451
+ next if value.nil?
452
+ hash[param] = _to_hash(value)
453
+ end
454
+ hash
455
+ end
456
+
457
+ # Outputs non-array value in the form of hash
458
+ # For object, use to_hash. Otherwise, just return the value
459
+ # @param [Object] value Any valid value
460
+ # @return [Hash] Returns the value in the form of hash
461
+ def _to_hash(value)
462
+ if value.is_a?(Array)
463
+ value.compact.map { |v| _to_hash(v) }
464
+ elsif value.is_a?(Hash)
465
+ {}.tap do |hash|
466
+ value.each { |k, v| hash[k] = _to_hash(v) }
467
+ end
468
+ elsif value.respond_to? :to_hash
469
+ value.to_hash
470
+ else
471
+ value
472
+ end
473
+ end
474
+
475
+ end
476
+ end