ultracart_api 3.10.168 → 3.10.169

Sign up to get free protection for your applications and to get access to all the features.
@@ -208,6 +208,67 @@ module UltracartClient
208
208
  end
209
209
  return data, status_code, headers
210
210
  end
211
+ # Delete a customer wishlist item
212
+ # Delete a customer wishlist item
213
+ # @param customer_profile_oid The customer oid for this wishlist.
214
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item to delete.
215
+ # @param [Hash] opts the optional parameters
216
+ # @return [CustomerWishListItem]
217
+ def delete_wish_list_item(customer_profile_oid, customer_wishlist_item_oid, opts = {})
218
+ data, _status_code, _headers = delete_wish_list_item_with_http_info(customer_profile_oid, customer_wishlist_item_oid, opts)
219
+ data
220
+ end
221
+
222
+ # Delete a customer wishlist item
223
+ # Delete a customer wishlist item
224
+ # @param customer_profile_oid The customer oid for this wishlist.
225
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item to delete.
226
+ # @param [Hash] opts the optional parameters
227
+ # @return [Array<(CustomerWishListItem, Fixnum, Hash)>] CustomerWishListItem data, response status code and response headers
228
+ def delete_wish_list_item_with_http_info(customer_profile_oid, customer_wishlist_item_oid, opts = {})
229
+ if @api_client.config.debugging
230
+ @api_client.config.logger.debug 'Calling API: CustomerApi.delete_wish_list_item ...'
231
+ end
232
+ # verify the required parameter 'customer_profile_oid' is set
233
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
234
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.delete_wish_list_item"
235
+ end
236
+ # verify the required parameter 'customer_wishlist_item_oid' is set
237
+ if @api_client.config.client_side_validation && customer_wishlist_item_oid.nil?
238
+ fail ArgumentError, "Missing the required parameter 'customer_wishlist_item_oid' when calling CustomerApi.delete_wish_list_item"
239
+ end
240
+ # resource path
241
+ local_var_path = '/customer/customers/{customer_profile_oid}/wishlist/{customer_wishlist_item_oid}'.sub('{' + 'customer_profile_oid' + '}', customer_profile_oid.to_s).sub('{' + 'customer_wishlist_item_oid' + '}', customer_wishlist_item_oid.to_s)
242
+
243
+ # query parameters
244
+ query_params = {}
245
+
246
+ # header parameters
247
+ header_params = {}
248
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
249
+ # HTTP header 'Accept' (if needed)
250
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
251
+ # HTTP header 'Content-Type'
252
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
253
+
254
+ # form parameters
255
+ form_params = {}
256
+
257
+ # http body (model)
258
+ post_body = nil
259
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
260
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
261
+ :header_params => header_params,
262
+ :query_params => query_params,
263
+ :form_params => form_params,
264
+ :body => post_body,
265
+ :auth_names => auth_names,
266
+ :return_type => 'CustomerWishListItem')
267
+ if @api_client.config.debugging
268
+ @api_client.config.logger.debug "API called: CustomerApi#delete_wish_list_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
269
+ end
270
+ return data, status_code, headers
271
+ end
211
272
  # Retrieve a customer
212
273
  # Retrieves a single customer using the specified customer profile oid.
213
274
  # @param customer_profile_oid The customer oid to retrieve.
@@ -477,6 +538,122 @@ module UltracartClient
477
538
  end
478
539
  return data, status_code, headers
479
540
  end
541
+ # Retrieve wishlist items for customer
542
+ # Retrieve wishlist items for customer.
543
+ # @param customer_profile_oid The customer oid for this wishlist.
544
+ # @param [Hash] opts the optional parameters
545
+ # @return [CustomerWishListItemsResponse]
546
+ def get_customer_wish_list(customer_profile_oid, opts = {})
547
+ data, _status_code, _headers = get_customer_wish_list_with_http_info(customer_profile_oid, opts)
548
+ data
549
+ end
550
+
551
+ # Retrieve wishlist items for customer
552
+ # Retrieve wishlist items for customer.
553
+ # @param customer_profile_oid The customer oid for this wishlist.
554
+ # @param [Hash] opts the optional parameters
555
+ # @return [Array<(CustomerWishListItemsResponse, Fixnum, Hash)>] CustomerWishListItemsResponse data, response status code and response headers
556
+ def get_customer_wish_list_with_http_info(customer_profile_oid, opts = {})
557
+ if @api_client.config.debugging
558
+ @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_wish_list ...'
559
+ end
560
+ # verify the required parameter 'customer_profile_oid' is set
561
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
562
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.get_customer_wish_list"
563
+ end
564
+ # resource path
565
+ local_var_path = '/customer/customers/{customer_profile_oid}/wishlist'.sub('{' + 'customer_profile_oid' + '}', customer_profile_oid.to_s)
566
+
567
+ # query parameters
568
+ query_params = {}
569
+
570
+ # header parameters
571
+ header_params = {}
572
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
573
+ # HTTP header 'Accept' (if needed)
574
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
575
+ # HTTP header 'Content-Type'
576
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
577
+
578
+ # form parameters
579
+ form_params = {}
580
+
581
+ # http body (model)
582
+ post_body = nil
583
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
584
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
585
+ :header_params => header_params,
586
+ :query_params => query_params,
587
+ :form_params => form_params,
588
+ :body => post_body,
589
+ :auth_names => auth_names,
590
+ :return_type => 'CustomerWishListItemsResponse')
591
+ if @api_client.config.debugging
592
+ @api_client.config.logger.debug "API called: CustomerApi#get_customer_wish_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
593
+ end
594
+ return data, status_code, headers
595
+ end
596
+ # Retrieve wishlist item for customer
597
+ # Retrieve wishlist item for customer.
598
+ # @param customer_profile_oid The customer oid for this wishlist.
599
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item.
600
+ # @param [Hash] opts the optional parameters
601
+ # @return [CustomerWishListItemResponse]
602
+ def get_customer_wish_list_item(customer_profile_oid, customer_wishlist_item_oid, opts = {})
603
+ data, _status_code, _headers = get_customer_wish_list_item_with_http_info(customer_profile_oid, customer_wishlist_item_oid, opts)
604
+ data
605
+ end
606
+
607
+ # Retrieve wishlist item for customer
608
+ # Retrieve wishlist item for customer.
609
+ # @param customer_profile_oid The customer oid for this wishlist.
610
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item.
611
+ # @param [Hash] opts the optional parameters
612
+ # @return [Array<(CustomerWishListItemResponse, Fixnum, Hash)>] CustomerWishListItemResponse data, response status code and response headers
613
+ def get_customer_wish_list_item_with_http_info(customer_profile_oid, customer_wishlist_item_oid, opts = {})
614
+ if @api_client.config.debugging
615
+ @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_wish_list_item ...'
616
+ end
617
+ # verify the required parameter 'customer_profile_oid' is set
618
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
619
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.get_customer_wish_list_item"
620
+ end
621
+ # verify the required parameter 'customer_wishlist_item_oid' is set
622
+ if @api_client.config.client_side_validation && customer_wishlist_item_oid.nil?
623
+ fail ArgumentError, "Missing the required parameter 'customer_wishlist_item_oid' when calling CustomerApi.get_customer_wish_list_item"
624
+ end
625
+ # resource path
626
+ local_var_path = '/customer/customers/{customer_profile_oid}/wishlist/{customer_wishlist_item_oid}'.sub('{' + 'customer_profile_oid' + '}', customer_profile_oid.to_s).sub('{' + 'customer_wishlist_item_oid' + '}', customer_wishlist_item_oid.to_s)
627
+
628
+ # query parameters
629
+ query_params = {}
630
+
631
+ # header parameters
632
+ header_params = {}
633
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
634
+ # HTTP header 'Accept' (if needed)
635
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
636
+ # HTTP header 'Content-Type'
637
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
638
+
639
+ # form parameters
640
+ form_params = {}
641
+
642
+ # http body (model)
643
+ post_body = nil
644
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
645
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
646
+ :header_params => header_params,
647
+ :query_params => query_params,
648
+ :form_params => form_params,
649
+ :body => post_body,
650
+ :auth_names => auth_names,
651
+ :return_type => 'CustomerWishListItemResponse')
652
+ if @api_client.config.debugging
653
+ @api_client.config.logger.debug "API called: CustomerApi#get_customer_wish_list_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
654
+ end
655
+ return data, status_code, headers
656
+ end
480
657
  # Retrieve customers
481
658
  # Retrieves customers from the account. If no parameters are specified, all customers will be returned. You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination.
482
659
  # @param [Hash] opts the optional parameters
@@ -918,6 +1095,67 @@ module UltracartClient
918
1095
  end
919
1096
  return data, status_code, headers
920
1097
  end
1098
+ # Insert a customer wishlist item
1099
+ # Insert a customer wishlist item
1100
+ # @param wishlist_item Wishlist item to insert
1101
+ # @param customer_profile_oid The customer oid for this wishlist.
1102
+ # @param [Hash] opts the optional parameters
1103
+ # @return [CustomerWishListItem]
1104
+ def insert_wish_list_item(wishlist_item, customer_profile_oid, opts = {})
1105
+ data, _status_code, _headers = insert_wish_list_item_with_http_info(wishlist_item, customer_profile_oid, opts)
1106
+ data
1107
+ end
1108
+
1109
+ # Insert a customer wishlist item
1110
+ # Insert a customer wishlist item
1111
+ # @param wishlist_item Wishlist item to insert
1112
+ # @param customer_profile_oid The customer oid for this wishlist.
1113
+ # @param [Hash] opts the optional parameters
1114
+ # @return [Array<(CustomerWishListItem, Fixnum, Hash)>] CustomerWishListItem data, response status code and response headers
1115
+ def insert_wish_list_item_with_http_info(wishlist_item, customer_profile_oid, opts = {})
1116
+ if @api_client.config.debugging
1117
+ @api_client.config.logger.debug 'Calling API: CustomerApi.insert_wish_list_item ...'
1118
+ end
1119
+ # verify the required parameter 'wishlist_item' is set
1120
+ if @api_client.config.client_side_validation && wishlist_item.nil?
1121
+ fail ArgumentError, "Missing the required parameter 'wishlist_item' when calling CustomerApi.insert_wish_list_item"
1122
+ end
1123
+ # verify the required parameter 'customer_profile_oid' is set
1124
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
1125
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.insert_wish_list_item"
1126
+ end
1127
+ # resource path
1128
+ local_var_path = '/customer/customers/{customer_profile_oid}/wishlist'.sub('{' + 'customer_profile_oid' + '}', customer_profile_oid.to_s)
1129
+
1130
+ # query parameters
1131
+ query_params = {}
1132
+
1133
+ # header parameters
1134
+ header_params = {}
1135
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1136
+ # HTTP header 'Accept' (if needed)
1137
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1138
+ # HTTP header 'Content-Type'
1139
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
1140
+
1141
+ # form parameters
1142
+ form_params = {}
1143
+
1144
+ # http body (model)
1145
+ post_body = @api_client.object_to_http_body(wishlist_item)
1146
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1147
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
1148
+ :header_params => header_params,
1149
+ :query_params => query_params,
1150
+ :form_params => form_params,
1151
+ :body => post_body,
1152
+ :auth_names => auth_names,
1153
+ :return_type => 'CustomerWishListItem')
1154
+ if @api_client.config.debugging
1155
+ @api_client.config.logger.debug "API called: CustomerApi#insert_wish_list_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1156
+ end
1157
+ return data, status_code, headers
1158
+ end
921
1159
  # Merge customer into this customer
922
1160
  # Merge customer into this customer.
923
1161
  # @param customer Customer to merge into this profile.
@@ -1159,6 +1397,73 @@ module UltracartClient
1159
1397
  end
1160
1398
  return data, status_code, headers
1161
1399
  end
1400
+ # Update a customer wishlist item
1401
+ # Update a customer wishlist item
1402
+ # @param wishlist_item Wishlist item to update
1403
+ # @param customer_profile_oid The customer oid for this wishlist.
1404
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item.
1405
+ # @param [Hash] opts the optional parameters
1406
+ # @return [CustomerWishListItem]
1407
+ def update_wish_list_item(wishlist_item, customer_profile_oid, customer_wishlist_item_oid, opts = {})
1408
+ data, _status_code, _headers = update_wish_list_item_with_http_info(wishlist_item, customer_profile_oid, customer_wishlist_item_oid, opts)
1409
+ data
1410
+ end
1411
+
1412
+ # Update a customer wishlist item
1413
+ # Update a customer wishlist item
1414
+ # @param wishlist_item Wishlist item to update
1415
+ # @param customer_profile_oid The customer oid for this wishlist.
1416
+ # @param customer_wishlist_item_oid The wishlist oid for this wishlist item.
1417
+ # @param [Hash] opts the optional parameters
1418
+ # @return [Array<(CustomerWishListItem, Fixnum, Hash)>] CustomerWishListItem data, response status code and response headers
1419
+ def update_wish_list_item_with_http_info(wishlist_item, customer_profile_oid, customer_wishlist_item_oid, opts = {})
1420
+ if @api_client.config.debugging
1421
+ @api_client.config.logger.debug 'Calling API: CustomerApi.update_wish_list_item ...'
1422
+ end
1423
+ # verify the required parameter 'wishlist_item' is set
1424
+ if @api_client.config.client_side_validation && wishlist_item.nil?
1425
+ fail ArgumentError, "Missing the required parameter 'wishlist_item' when calling CustomerApi.update_wish_list_item"
1426
+ end
1427
+ # verify the required parameter 'customer_profile_oid' is set
1428
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
1429
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.update_wish_list_item"
1430
+ end
1431
+ # verify the required parameter 'customer_wishlist_item_oid' is set
1432
+ if @api_client.config.client_side_validation && customer_wishlist_item_oid.nil?
1433
+ fail ArgumentError, "Missing the required parameter 'customer_wishlist_item_oid' when calling CustomerApi.update_wish_list_item"
1434
+ end
1435
+ # resource path
1436
+ local_var_path = '/customer/customers/{customer_profile_oid}/wishlist/{customer_wishlist_item_oid}'.sub('{' + 'customer_profile_oid' + '}', customer_profile_oid.to_s).sub('{' + 'customer_wishlist_item_oid' + '}', customer_wishlist_item_oid.to_s)
1437
+
1438
+ # query parameters
1439
+ query_params = {}
1440
+
1441
+ # header parameters
1442
+ header_params = {}
1443
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1444
+ # HTTP header 'Accept' (if needed)
1445
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1446
+ # HTTP header 'Content-Type'
1447
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
1448
+
1449
+ # form parameters
1450
+ form_params = {}
1451
+
1452
+ # http body (model)
1453
+ post_body = @api_client.object_to_http_body(wishlist_item)
1454
+ auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
1455
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1456
+ :header_params => header_params,
1457
+ :query_params => query_params,
1458
+ :form_params => form_params,
1459
+ :body => post_body,
1460
+ :auth_names => auth_names,
1461
+ :return_type => 'CustomerWishListItem')
1462
+ if @api_client.config.debugging
1463
+ @api_client.config.logger.debug "API called: CustomerApi#update_wish_list_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1464
+ end
1465
+ return data, status_code, headers
1466
+ end
1162
1467
  # Validate a token that can be used to verify a customer email address
1163
1468
  # Validate a token that can be used to verify a customer email address. The implementation of how a customer interacts with this token is left to the merchant.
1164
1469
  # @param validation_request Token validation request
@@ -0,0 +1,260 @@
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 CustomerWishListItem
17
+ # Add date
18
+ attr_accessor :add_dts
19
+
20
+ # Comments
21
+ attr_accessor :comments
22
+
23
+ # Customer profile object identifier
24
+ attr_accessor :customer_profile_oid
25
+
26
+ # Customer wishlist item object identifier
27
+ attr_accessor :customer_wishlist_item_oid
28
+
29
+ # Merchant item object identifier
30
+ attr_accessor :merchant_item_oid
31
+
32
+ # Position in wishlist
33
+ attr_accessor :position
34
+
35
+ # Priority of wishlist item, 3 being low priority and 5 is high priority.
36
+ attr_accessor :priority
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'add_dts' => :'add_dts',
42
+ :'comments' => :'comments',
43
+ :'customer_profile_oid' => :'customer_profile_oid',
44
+ :'customer_wishlist_item_oid' => :'customer_wishlist_item_oid',
45
+ :'merchant_item_oid' => :'merchant_item_oid',
46
+ :'position' => :'position',
47
+ :'priority' => :'priority'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'add_dts' => :'String',
55
+ :'comments' => :'String',
56
+ :'customer_profile_oid' => :'Integer',
57
+ :'customer_wishlist_item_oid' => :'Integer',
58
+ :'merchant_item_oid' => :'Integer',
59
+ :'position' => :'Integer',
60
+ :'priority' => :'Integer'
61
+ }
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ return unless attributes.is_a?(Hash)
68
+
69
+ # convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
71
+
72
+ if attributes.has_key?(:'add_dts')
73
+ self.add_dts = attributes[:'add_dts']
74
+ end
75
+
76
+ if attributes.has_key?(:'comments')
77
+ self.comments = attributes[:'comments']
78
+ end
79
+
80
+ if attributes.has_key?(:'customer_profile_oid')
81
+ self.customer_profile_oid = attributes[:'customer_profile_oid']
82
+ end
83
+
84
+ if attributes.has_key?(:'customer_wishlist_item_oid')
85
+ self.customer_wishlist_item_oid = attributes[:'customer_wishlist_item_oid']
86
+ end
87
+
88
+ if attributes.has_key?(:'merchant_item_oid')
89
+ self.merchant_item_oid = attributes[:'merchant_item_oid']
90
+ end
91
+
92
+ if attributes.has_key?(:'position')
93
+ self.position = attributes[:'position']
94
+ end
95
+
96
+ if attributes.has_key?(:'priority')
97
+ self.priority = attributes[:'priority']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ if !@comments.nil? && @comments.to_s.length > 1024
106
+ invalid_properties.push('invalid value for "comments", the character length must be smaller than or equal to 1024.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ return false if !@comments.nil? && @comments.to_s.length > 1024
116
+ true
117
+ end
118
+
119
+ # Custom attribute writer method with validation
120
+ # @param [Object] comments Value to be assigned
121
+ def comments=(comments)
122
+ if !comments.nil? && comments.to_s.length > 1024
123
+ fail ArgumentError, 'invalid value for "comments", the character length must be smaller than or equal to 1024.'
124
+ end
125
+
126
+ @comments = comments
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ add_dts == o.add_dts &&
135
+ comments == o.comments &&
136
+ customer_profile_oid == o.customer_profile_oid &&
137
+ customer_wishlist_item_oid == o.customer_wishlist_item_oid &&
138
+ merchant_item_oid == o.merchant_item_oid &&
139
+ position == o.position &&
140
+ priority == o.priority
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Fixnum] Hash code
151
+ def hash
152
+ [add_dts, comments, customer_profile_oid, customer_wishlist_item_oid, merchant_item_oid, position, priority].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ self.class.swagger_types.each_pair do |key, type|
161
+ if type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :DateTime
182
+ DateTime.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :BOOLEAN
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ temp_model = UltracartClient.const_get(type).new
213
+ temp_model.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ next if value.nil?
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+ end