ultracart_api 4.1.121 → 4.1.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,6 +32,73 @@ module UltracartClient
32
32
  UltracartClient::AutoOrderApi.new(api_client)
33
33
  end
34
34
 
35
+ # Attempt a failed rebill on an auto order
36
+ # Attempts to rebill an auto order using the payment information already on the original order. The attempt is refused if the auto order is scheduled to charge within the next five minutes, or if it was already billed within the last 24 hours, both of which guard against double charging. Runs synchronously and may take some time while the gateway is contacted. A declined card is reported in the response body rather than as an API error.
37
+ # @param auto_order_oid [Integer] The auto order oid to rebill.
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [String] :_expand The object expansion to perform on the result. See documentation for examples
40
+ # @return [AutoOrderRebillResponse]
41
+ def attempt_auto_order_rebill(auto_order_oid, opts = {})
42
+ data, _status_code, _headers = attempt_auto_order_rebill_with_http_info(auto_order_oid, opts)
43
+ data
44
+ end
45
+
46
+ # Attempt a failed rebill on an auto order
47
+ # Attempts to rebill an auto order using the payment information already on the original order. The attempt is refused if the auto order is scheduled to charge within the next five minutes, or if it was already billed within the last 24 hours, both of which guard against double charging. Runs synchronously and may take some time while the gateway is contacted. A declined card is reported in the response body rather than as an API error.
48
+ # @param auto_order_oid [Integer] The auto order oid to rebill.
49
+ # @param [Hash] opts the optional parameters
50
+ # @option opts [String] :_expand The object expansion to perform on the result. See documentation for examples
51
+ # @return [Array<(AutoOrderRebillResponse, Integer, Hash)>] AutoOrderRebillResponse data, response status code and response headers
52
+ def attempt_auto_order_rebill_with_http_info(auto_order_oid, opts = {})
53
+ if @api_client.config.debugging
54
+ @api_client.config.logger.debug 'Calling API: AutoOrderApi.attempt_auto_order_rebill ...'
55
+ end
56
+ # verify the required parameter 'auto_order_oid' is set
57
+ if @api_client.config.client_side_validation && auto_order_oid.nil?
58
+ fail ArgumentError, "Missing the required parameter 'auto_order_oid' when calling AutoOrderApi.attempt_auto_order_rebill"
59
+ end
60
+ # resource path
61
+ local_var_path = '/auto_order/auto_orders/{auto_order_oid}/rebill'.sub('{' + 'auto_order_oid' + '}', CGI.escape(auto_order_oid.to_s))
62
+
63
+ # query parameters
64
+ query_params = opts[:query_params] || {}
65
+ query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?
66
+
67
+ # header parameters
68
+ header_params = opts[:header_params] || {}
69
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
70
+ # HTTP header 'Accept' (if needed)
71
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
72
+
73
+ # form parameters
74
+ form_params = opts[:form_params] || {}
75
+
76
+ # http body (model)
77
+ post_body = opts[:debug_body]
78
+
79
+ # return_type
80
+ return_type = opts[:debug_return_type] || 'AutoOrderRebillResponse'
81
+
82
+ # auth_names
83
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
84
+
85
+ new_options = opts.merge(
86
+ :operation => :"AutoOrderApi.attempt_auto_order_rebill",
87
+ :header_params => header_params,
88
+ :query_params => query_params,
89
+ :form_params => form_params,
90
+ :body => post_body,
91
+ :auth_names => auth_names,
92
+ :return_type => return_type
93
+ )
94
+
95
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
96
+ if @api_client.config.debugging
97
+ @api_client.config.logger.debug "API called: AutoOrderApi#attempt_auto_order_rebill\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
98
+ end
99
+ return data, status_code, headers
100
+ end
101
+
35
102
  # Cancel a single item on an auto order
36
103
  # Cancels a single item on an auto order identified by the original order id and the item's original_item_id. The request body may specify mode=_end (soft cancel by setting no_order_after_dts to the current time, preserving the row for reporting; this is the default when the body is omitted) or mode=remove (hard delete). Returns the updated auto order based upon expansion.
37
104
  # @param reference_order_id [String] The reference order id (original_order_id) of the auto order.
@@ -1187,6 +1254,84 @@ module UltracartClient
1187
1254
  return data, status_code, headers
1188
1255
  end
1189
1256
 
1257
+ # Update the payment information on an auto order
1258
+ # Updates the credit card on the original order behind an auto order, along with any rebills sitting in accounts receivable, and reactivates the auto order. Card data is accepted as hosted field tokens only. raw card numbers and card verification numbers are rejected. Set attempt_rebill to true to also attempt the rebill immediately, which runs synchronously and may take some time while the gateway is contacted. A declined card is reported in the response body rather than as an API error.
1259
+ # @param auto_order_oid [Integer] The auto order oid to update payment information on.
1260
+ # @param auto_order_payment_update_request [AutoOrderPaymentUpdateRequest] Payment information to place on the auto order
1261
+ # @param [Hash] opts the optional parameters
1262
+ # @option opts [String] :_expand The object expansion to perform on the result. See documentation for examples
1263
+ # @return [AutoOrderRebillResponse]
1264
+ def update_auto_order_payment(auto_order_oid, auto_order_payment_update_request, opts = {})
1265
+ data, _status_code, _headers = update_auto_order_payment_with_http_info(auto_order_oid, auto_order_payment_update_request, opts)
1266
+ data
1267
+ end
1268
+
1269
+ # Update the payment information on an auto order
1270
+ # Updates the credit card on the original order behind an auto order, along with any rebills sitting in accounts receivable, and reactivates the auto order. Card data is accepted as hosted field tokens only. raw card numbers and card verification numbers are rejected. Set attempt_rebill to true to also attempt the rebill immediately, which runs synchronously and may take some time while the gateway is contacted. A declined card is reported in the response body rather than as an API error.
1271
+ # @param auto_order_oid [Integer] The auto order oid to update payment information on.
1272
+ # @param auto_order_payment_update_request [AutoOrderPaymentUpdateRequest] Payment information to place on the auto order
1273
+ # @param [Hash] opts the optional parameters
1274
+ # @option opts [String] :_expand The object expansion to perform on the result. See documentation for examples
1275
+ # @return [Array<(AutoOrderRebillResponse, Integer, Hash)>] AutoOrderRebillResponse data, response status code and response headers
1276
+ def update_auto_order_payment_with_http_info(auto_order_oid, auto_order_payment_update_request, opts = {})
1277
+ if @api_client.config.debugging
1278
+ @api_client.config.logger.debug 'Calling API: AutoOrderApi.update_auto_order_payment ...'
1279
+ end
1280
+ # verify the required parameter 'auto_order_oid' is set
1281
+ if @api_client.config.client_side_validation && auto_order_oid.nil?
1282
+ fail ArgumentError, "Missing the required parameter 'auto_order_oid' when calling AutoOrderApi.update_auto_order_payment"
1283
+ end
1284
+ # verify the required parameter 'auto_order_payment_update_request' is set
1285
+ if @api_client.config.client_side_validation && auto_order_payment_update_request.nil?
1286
+ fail ArgumentError, "Missing the required parameter 'auto_order_payment_update_request' when calling AutoOrderApi.update_auto_order_payment"
1287
+ end
1288
+ # resource path
1289
+ local_var_path = '/auto_order/auto_orders/{auto_order_oid}/payment'.sub('{' + 'auto_order_oid' + '}', CGI.escape(auto_order_oid.to_s))
1290
+
1291
+ # query parameters
1292
+ query_params = opts[:query_params] || {}
1293
+ query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?
1294
+
1295
+ # header parameters
1296
+ header_params = opts[:header_params] || {}
1297
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1298
+ # HTTP header 'Accept' (if needed)
1299
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1300
+ # HTTP header 'Content-Type'
1301
+ content_type = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
1302
+ if !content_type.nil?
1303
+ header_params['Content-Type'] = content_type
1304
+ end
1305
+
1306
+ # form parameters
1307
+ form_params = opts[:form_params] || {}
1308
+
1309
+ # http body (model)
1310
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(auto_order_payment_update_request)
1311
+
1312
+ # return_type
1313
+ return_type = opts[:debug_return_type] || 'AutoOrderRebillResponse'
1314
+
1315
+ # auth_names
1316
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1317
+
1318
+ new_options = opts.merge(
1319
+ :operation => :"AutoOrderApi.update_auto_order_payment",
1320
+ :header_params => header_params,
1321
+ :query_params => query_params,
1322
+ :form_params => form_params,
1323
+ :body => post_body,
1324
+ :auth_names => auth_names,
1325
+ :return_type => return_type
1326
+ )
1327
+
1328
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
1329
+ if @api_client.config.debugging
1330
+ @api_client.config.logger.debug "API called: AutoOrderApi#update_auto_order_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1331
+ end
1332
+ return data, status_code, headers
1333
+ end
1334
+
1190
1335
  # Update an auto order properties
1191
1336
  # Update an auto order properties. Returns the auto order based upon expansion
1192
1337
  # @param auto_order_oid [Integer] The auto order oid to update.
@@ -1790,6 +1790,81 @@ module UltracartClient
1790
1790
  return data, status_code, headers
1791
1791
  end
1792
1792
 
1793
+ # Clear email suppression for a customer
1794
+ # Clears global unsubscribe, spam complaint and/or bounce suppression for a customer. This method is clear-only and cannot set a suppression flag. Clearing a suppression removes the send gate but does not subscribe the customer to any email list -- list membership survives a global unsubscribe untouched, so the customer's original lists become deliverable again with no further action. Returns 200 with a warning if the flags were cleared but an upstream ESP suppression removal failed; the profile was still modified in that case.
1795
+ # @param customer_profile_oid [Integer] The customer profile oid
1796
+ # @param suppression_changes [CustomerEmailSuppressionRequest] Suppression changes
1797
+ # @param [Hash] opts the optional parameters
1798
+ # @return [CustomerEmailSuppressionResponse]
1799
+ def update_customer_email_suppression(customer_profile_oid, suppression_changes, opts = {})
1800
+ data, _status_code, _headers = update_customer_email_suppression_with_http_info(customer_profile_oid, suppression_changes, opts)
1801
+ data
1802
+ end
1803
+
1804
+ # Clear email suppression for a customer
1805
+ # Clears global unsubscribe, spam complaint and/or bounce suppression for a customer. This method is clear-only and cannot set a suppression flag. Clearing a suppression removes the send gate but does not subscribe the customer to any email list -- list membership survives a global unsubscribe untouched, so the customer&#39;s original lists become deliverable again with no further action. Returns 200 with a warning if the flags were cleared but an upstream ESP suppression removal failed; the profile was still modified in that case.
1806
+ # @param customer_profile_oid [Integer] The customer profile oid
1807
+ # @param suppression_changes [CustomerEmailSuppressionRequest] Suppression changes
1808
+ # @param [Hash] opts the optional parameters
1809
+ # @return [Array<(CustomerEmailSuppressionResponse, Integer, Hash)>] CustomerEmailSuppressionResponse data, response status code and response headers
1810
+ def update_customer_email_suppression_with_http_info(customer_profile_oid, suppression_changes, opts = {})
1811
+ if @api_client.config.debugging
1812
+ @api_client.config.logger.debug 'Calling API: CustomerApi.update_customer_email_suppression ...'
1813
+ end
1814
+ # verify the required parameter 'customer_profile_oid' is set
1815
+ if @api_client.config.client_side_validation && customer_profile_oid.nil?
1816
+ fail ArgumentError, "Missing the required parameter 'customer_profile_oid' when calling CustomerApi.update_customer_email_suppression"
1817
+ end
1818
+ # verify the required parameter 'suppression_changes' is set
1819
+ if @api_client.config.client_side_validation && suppression_changes.nil?
1820
+ fail ArgumentError, "Missing the required parameter 'suppression_changes' when calling CustomerApi.update_customer_email_suppression"
1821
+ end
1822
+ # resource path
1823
+ local_var_path = '/customer/customers/{customer_profile_oid}/email_suppression'.sub('{' + 'customer_profile_oid' + '}', CGI.escape(customer_profile_oid.to_s))
1824
+
1825
+ # query parameters
1826
+ query_params = opts[:query_params] || {}
1827
+
1828
+ # header parameters
1829
+ header_params = opts[:header_params] || {}
1830
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1831
+ # HTTP header 'Accept' (if needed)
1832
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1833
+ # HTTP header 'Content-Type'
1834
+ content_type = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
1835
+ if !content_type.nil?
1836
+ header_params['Content-Type'] = content_type
1837
+ end
1838
+
1839
+ # form parameters
1840
+ form_params = opts[:form_params] || {}
1841
+
1842
+ # http body (model)
1843
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(suppression_changes)
1844
+
1845
+ # return_type
1846
+ return_type = opts[:debug_return_type] || 'CustomerEmailSuppressionResponse'
1847
+
1848
+ # auth_names
1849
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1850
+
1851
+ new_options = opts.merge(
1852
+ :operation => :"CustomerApi.update_customer_email_suppression",
1853
+ :header_params => header_params,
1854
+ :query_params => query_params,
1855
+ :form_params => form_params,
1856
+ :body => post_body,
1857
+ :auth_names => auth_names,
1858
+ :return_type => return_type
1859
+ )
1860
+
1861
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
1862
+ if @api_client.config.debugging
1863
+ @api_client.config.logger.debug "API called: CustomerApi#update_customer_email_suppression\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1864
+ end
1865
+ return data, status_code, headers
1866
+ end
1867
+
1793
1868
  # Update a customer wishlist item
1794
1869
  # Update a customer wishlist item
1795
1870
  # @param customer_profile_oid [Integer] The customer oid for this wishlist.
@@ -0,0 +1,304 @@
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 AutoOrderPaymentUpdateRequest
18
+ # Attempt to rebill the auto order immediately after the payment information is updated. Defaults to false.
19
+ attr_accessor :attempt_rebill
20
+
21
+ # Card expiration month (1-12)
22
+ attr_accessor :card_expiration_month
23
+
24
+ # Card expiration year (four digit)
25
+ attr_accessor :card_expiration_year
26
+
27
+ # Hosted field token for the credit card number. Tokens are valid for two hours.
28
+ attr_accessor :card_number_token
29
+
30
+ # Credit card type. Optional. When the hosted field token carries the card type, the token wins.
31
+ attr_accessor :card_type
32
+
33
+ # Hosted field token for the card verification number (CVV). Required when the order has a vaulted card that must be re-vaulted.
34
+ attr_accessor :card_verification_number_token
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'attempt_rebill' => :'attempt_rebill',
62
+ :'card_expiration_month' => :'card_expiration_month',
63
+ :'card_expiration_year' => :'card_expiration_year',
64
+ :'card_number_token' => :'card_number_token',
65
+ :'card_type' => :'card_type',
66
+ :'card_verification_number_token' => :'card_verification_number_token'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'attempt_rebill' => :'Boolean',
79
+ :'card_expiration_month' => :'Integer',
80
+ :'card_expiration_year' => :'Integer',
81
+ :'card_number_token' => :'String',
82
+ :'card_type' => :'String',
83
+ :'card_verification_number_token' => :'String'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::AutoOrderPaymentUpdateRequest` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::AutoOrderPaymentUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'attempt_rebill')
109
+ self.attempt_rebill = attributes[:'attempt_rebill']
110
+ end
111
+
112
+ if attributes.key?(:'card_expiration_month')
113
+ self.card_expiration_month = attributes[:'card_expiration_month']
114
+ end
115
+
116
+ if attributes.key?(:'card_expiration_year')
117
+ self.card_expiration_year = attributes[:'card_expiration_year']
118
+ end
119
+
120
+ if attributes.key?(:'card_number_token')
121
+ self.card_number_token = attributes[:'card_number_token']
122
+ end
123
+
124
+ if attributes.key?(:'card_type')
125
+ self.card_type = attributes[:'card_type']
126
+ end
127
+
128
+ if attributes.key?(:'card_verification_number_token')
129
+ self.card_verification_number_token = attributes[:'card_verification_number_token']
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ invalid_properties = Array.new
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ card_type_validator = EnumAttributeValidator.new('String', ["AMEX", "Diners Club", "Discover", "JCB", "MasterCard", "VISA"])
144
+ return false unless card_type_validator.valid?(@card_type)
145
+ true
146
+ end
147
+
148
+ # Custom attribute writer method checking allowed values (enum).
149
+ # @param [Object] card_type Object to be assigned
150
+ def card_type=(card_type)
151
+ validator = EnumAttributeValidator.new('String', ["AMEX", "Diners Club", "Discover", "JCB", "MasterCard", "VISA"])
152
+ unless validator.valid?(card_type)
153
+ fail ArgumentError, "invalid value for \"card_type\", must be one of #{validator.allowable_values}."
154
+ end
155
+ @card_type = card_type
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ attempt_rebill == o.attempt_rebill &&
164
+ card_expiration_month == o.card_expiration_month &&
165
+ card_expiration_year == o.card_expiration_year &&
166
+ card_number_token == o.card_number_token &&
167
+ card_type == o.card_type &&
168
+ card_verification_number_token == o.card_verification_number_token
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [attempt_rebill, card_expiration_month, card_expiration_year, card_number_token, card_type, card_verification_number_token].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ attributes = attributes.transform_keys(&:to_sym)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
203
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
204
+ end
205
+ elsif !attributes[self.class.attribute_map[key]].nil?
206
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
207
+ end
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ # Deserializes the data based on type
214
+ # @param string type Data type
215
+ # @param string value Value to be deserialized
216
+ # @return [Object] Deserialized data
217
+ def _deserialize(type, value)
218
+ case type.to_sym
219
+ when :Time
220
+ Time.parse(value)
221
+ when :Date
222
+ Date.parse(value)
223
+ when :String
224
+ value.to_s
225
+ when :Integer
226
+ value.to_i
227
+ when :Float
228
+ value.to_f
229
+ when :Boolean
230
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
231
+ true
232
+ else
233
+ false
234
+ end
235
+ when :Object
236
+ # generic object (usually a Hash), return directly
237
+ value
238
+ when /\AArray<(?<inner_type>.+)>\z/
239
+ inner_type = Regexp.last_match[:inner_type]
240
+ value.map { |v| _deserialize(inner_type, v) }
241
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
242
+ k_type = Regexp.last_match[:k_type]
243
+ v_type = Regexp.last_match[:v_type]
244
+ {}.tap do |hash|
245
+ value.each do |k, v|
246
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
247
+ end
248
+ end
249
+ else # model
250
+ # models (e.g. Pet) or oneOf
251
+ klass = UltracartClient.const_get(type)
252
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+
302
+ end
303
+
304
+ end