ultracart_api 4.1.222 → 4.1.224

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -2
  3. data/docs/OauthTokenResponse.md +2 -0
  4. data/docs/SfvbAffiliateNetwork.md +60 -0
  5. data/docs/SfvbAffiliateNetworkRequest.md +50 -0
  6. data/docs/SfvbAffiliateNetworksResponse.md +20 -0
  7. data/docs/SfvbApi.md +1456 -120
  8. data/docs/SfvbApprovalCreateRequest.md +8 -2
  9. data/docs/SfvbApprovalParams.md +7 -3
  10. data/docs/SfvbContainerResponse.md +3 -1
  11. data/docs/SfvbSmartAttribution.md +38 -0
  12. data/docs/SfvbSmartAttributionPlatform.md +34 -0
  13. data/docs/SfvbSmartAttributionRequest.md +30 -0
  14. data/docs/SfvbTrackingAdvanced.md +34 -0
  15. data/docs/SfvbTrackingAdvancedRequest.md +34 -0
  16. data/docs/SfvbTrackingChange.md +24 -0
  17. data/docs/SfvbTrackingHtml.md +36 -0
  18. data/docs/SfvbTrackingHtmlRequest.md +20 -0
  19. data/docs/SfvbTrackingHtmlResponse.md +22 -0
  20. data/docs/SfvbTrackingPrivacy.md +28 -0
  21. data/docs/SfvbTrackingPrivacyRequest.md +28 -0
  22. data/docs/SfvbTrackingProvider.md +48 -0
  23. data/docs/SfvbTrackingProviderConsent.md +22 -0
  24. data/docs/SfvbTrackingProviderEvent.md +20 -0
  25. data/docs/SfvbTrackingProviderField.md +42 -0
  26. data/docs/SfvbTrackingProviderOauth.md +28 -0
  27. data/docs/SfvbTrackingProviderRequest.md +32 -0
  28. data/docs/SfvbTrackingProviderSecrets.md +46 -0
  29. data/docs/SfvbTrackingProvidersResponse.md +22 -0
  30. data/docs/SfvbTrackingSettingsResponse.md +28 -0
  31. data/docs/SfvbTrackingWholesaleTier.md +22 -0
  32. data/docs/SfvbUtmShortcode.md +56 -0
  33. data/docs/SfvbUtmShortcodeRequest.md +44 -0
  34. data/docs/SfvbUtmShortcodesResponse.md +24 -0
  35. data/lib/ultracart_api/api/sfvb_api.rb +4602 -2793
  36. data/lib/ultracart_api/models/oauth_token_response.rb +11 -1
  37. data/lib/ultracart_api/models/sfvb_affiliate_network.rb +478 -0
  38. data/lib/ultracart_api/models/sfvb_affiliate_network_request.rb +428 -0
  39. data/lib/ultracart_api/models/sfvb_affiliate_networks_response.rb +232 -0
  40. data/lib/ultracart_api/models/sfvb_approval_create_request.rb +34 -7
  41. data/lib/ultracart_api/models/sfvb_approval_params.rb +24 -4
  42. data/lib/ultracart_api/models/sfvb_container_response.rb +16 -4
  43. data/lib/ultracart_api/models/sfvb_smart_attribution.rb +324 -0
  44. data/lib/ultracart_api/models/sfvb_smart_attribution_platform.rb +300 -0
  45. data/lib/ultracart_api/models/sfvb_smart_attribution_request.rb +282 -0
  46. data/lib/ultracart_api/models/sfvb_tracking_advanced.rb +300 -0
  47. data/lib/ultracart_api/models/sfvb_tracking_advanced_request.rb +302 -0
  48. data/lib/ultracart_api/models/sfvb_tracking_change.rb +250 -0
  49. data/lib/ultracart_api/models/sfvb_tracking_html.rb +344 -0
  50. data/lib/ultracart_api/models/sfvb_tracking_html_request.rb +230 -0
  51. data/lib/ultracart_api/models/sfvb_tracking_html_response.rb +242 -0
  52. data/lib/ultracart_api/models/sfvb_tracking_privacy.rb +352 -0
  53. data/lib/ultracart_api/models/sfvb_tracking_privacy_request.rb +352 -0
  54. data/lib/ultracart_api/models/sfvb_tracking_provider.rb +378 -0
  55. data/lib/ultracart_api/models/sfvb_tracking_provider_consent.rb +240 -0
  56. data/lib/ultracart_api/models/sfvb_tracking_provider_event.rb +230 -0
  57. data/lib/ultracart_api/models/sfvb_tracking_provider_field.rb +342 -0
  58. data/lib/ultracart_api/models/sfvb_tracking_provider_oauth.rb +270 -0
  59. data/lib/ultracart_api/models/sfvb_tracking_provider_request.rb +292 -0
  60. data/lib/ultracart_api/models/sfvb_tracking_provider_secrets.rb +360 -0
  61. data/lib/ultracart_api/models/sfvb_tracking_providers_response.rb +242 -0
  62. data/lib/ultracart_api/models/sfvb_tracking_settings_response.rb +272 -0
  63. data/lib/ultracart_api/models/sfvb_tracking_wholesale_tier.rb +240 -0
  64. data/lib/ultracart_api/models/sfvb_utm_shortcode.rb +410 -0
  65. data/lib/ultracart_api/models/sfvb_utm_shortcode_request.rb +350 -0
  66. data/lib/ultracart_api/models/sfvb_utm_shortcodes_response.rb +252 -0
  67. data/lib/ultracart_api/version.rb +1 -1
  68. data/lib/ultracart_api.rb +27 -0
  69. metadata +55 -1
@@ -33,6 +33,9 @@ module UltracartClient
33
33
  # The refresh token that should be used to fetch a new access token when the expiration occurs
34
34
  attr_accessor :refresh_token
35
35
 
36
+ # Seconds until the refresh token expires. Returned only by applications that rotate refresh tokens, which return a new refresh token on every refresh.
37
+ attr_accessor :refresh_token_expires_in
38
+
36
39
  # The scope of permissions associated with teh access token
37
40
  attr_accessor :scope
38
41
 
@@ -71,6 +74,7 @@ module UltracartClient
71
74
  :'expires_in' => :'expires_in',
72
75
  :'merchant_id' => :'merchant_id',
73
76
  :'refresh_token' => :'refresh_token',
77
+ :'refresh_token_expires_in' => :'refresh_token_expires_in',
74
78
  :'scope' => :'scope',
75
79
  :'token_type' => :'token_type'
76
80
  }
@@ -91,6 +95,7 @@ module UltracartClient
91
95
  :'expires_in' => :'String',
92
96
  :'merchant_id' => :'String',
93
97
  :'refresh_token' => :'String',
98
+ :'refresh_token_expires_in' => :'String',
94
99
  :'scope' => :'String',
95
100
  :'token_type' => :'String'
96
101
  }
@@ -145,6 +150,10 @@ module UltracartClient
145
150
  self.refresh_token = attributes[:'refresh_token']
146
151
  end
147
152
 
153
+ if attributes.key?(:'refresh_token_expires_in')
154
+ self.refresh_token_expires_in = attributes[:'refresh_token_expires_in']
155
+ end
156
+
148
157
  if attributes.key?(:'scope')
149
158
  self.scope = attributes[:'scope']
150
159
  end
@@ -191,6 +200,7 @@ module UltracartClient
191
200
  expires_in == o.expires_in &&
192
201
  merchant_id == o.merchant_id &&
193
202
  refresh_token == o.refresh_token &&
203
+ refresh_token_expires_in == o.refresh_token_expires_in &&
194
204
  scope == o.scope &&
195
205
  token_type == o.token_type
196
206
  end
@@ -204,7 +214,7 @@ module UltracartClient
204
214
  # Calculates hash code according to all attributes.
205
215
  # @return [Integer] Hash code
206
216
  def hash
207
- [access_token, error, error_description, error_uri, expires_in, merchant_id, refresh_token, scope, token_type].hash
217
+ [access_token, error, error_description, error_uri, expires_in, merchant_id, refresh_token, refresh_token_expires_in, scope, token_type].hash
208
218
  end
209
219
 
210
220
  # Builds the object from hash
@@ -0,0 +1,478 @@
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 SfvbAffiliateNetwork
18
+ # The network's oid. Smart Attribution names it as a platform's integration_id.
19
+ attr_accessor :affiliate_network_oid
20
+
21
+ # On a dry run, whether the real write needs an approved affiliate_network.change request.
22
+ attr_accessor :approval_needed
23
+
24
+ # The account's own affiliate that orders from this network are assigned to. Null when none.
25
+ attr_accessor :assign_to_affiliate_oid
26
+
27
+ # On a write, what changed, or what would change on a dry run. conversion_pixel shows its size and hash, not its content.
28
+ attr_accessor :changes
29
+
30
+ # A fixed commission amount, in the account's currency. Null when not set.
31
+ attr_accessor :commission
32
+
33
+ # HTML for custom, or the postback URL for server_to_server, with the admin's order tokens. Only on a read of one network and on a write. Empty when not set.
34
+ attr_accessor :conversion_pixel
35
+
36
+ # The SHA-256 of conversion_pixel as UTF-8.
37
+ attr_accessor :conversion_pixel_sha256
38
+
39
+ # The size of conversion_pixel in UTF-8 bytes.
40
+ attr_accessor :conversion_pixel_size_bytes
41
+
42
+ # custom prints conversion_pixel into the receipt page. commission_junction fires the account's Commission Junction setup instead and does not use conversion_pixel. server_to_server has UltraCart's server request conversion_pixel as an https URL after the order. A value stored by the admin that is none of these is shown as stored.
43
+ attr_accessor :conversion_type
44
+
45
+ # How long the visit is remembered, in days, 1 to 3650.
46
+ attr_accessor :cookie_lifetime_days
47
+
48
+ # On a write, true when nothing was saved.
49
+ attr_accessor :dry_run
50
+
51
+ # The share of this network's orders whose pixel fires, from 0 to 100.
52
+ attr_accessor :fire_percentage
53
+
54
+ # The hash of the network as stored. Send it as If-Match on an update or delete.
55
+ attr_accessor :hash_sha256
56
+
57
+ # What UltraCart's own affiliate system does with an order whose pixel did not fire. process handles it as usual, skip leaves it out, assign credits if_not_fired_affiliate_oid.
58
+ attr_accessor :if_not_fired
59
+
60
+ # For if_not_fired assign, the account's own affiliate to credit.
61
+ attr_accessor :if_not_fired_affiliate_oid
62
+
63
+ # The network's name, up to 50 characters.
64
+ attr_accessor :network_name
65
+
66
+ # The URL parameter that marks a visit from this network, up to 50 characters. Compared without case.
67
+ attr_accessor :parameter_name
68
+
69
+ # The parameter's value for this network, up to 100 characters. Compared without case.
70
+ attr_accessor :parameter_value
71
+
72
+ # The order custom field, 1 to 10, that records whether the pixel fired.
73
+ attr_accessor :record_fire_in_custom_field
74
+
75
+ # The order custom field, 1 to 10, that records the network's name.
76
+ attr_accessor :record_name_in_custom_field
77
+
78
+ # For server_to_server only, true to drop query parameters that are empty after the tokens are filled in.
79
+ attr_accessor :remove_empty_pixel_parameters
80
+
81
+ # True to replace another network's cookie. False keeps the first network's.
82
+ attr_accessor :stomp_previous_cookie
83
+
84
+ class EnumAttributeValidator
85
+ attr_reader :datatype
86
+ attr_reader :allowable_values
87
+
88
+ def initialize(datatype, allowable_values)
89
+ @allowable_values = allowable_values.map do |value|
90
+ case datatype.to_s
91
+ when /Integer/i
92
+ value.to_i
93
+ when /Float/i
94
+ value.to_f
95
+ else
96
+ value
97
+ end
98
+ end
99
+ end
100
+
101
+ def valid?(value)
102
+ !value || allowable_values.include?(value)
103
+ end
104
+ end
105
+
106
+ # Attribute mapping from ruby-style variable name to JSON key.
107
+ def self.attribute_map
108
+ {
109
+ :'affiliate_network_oid' => :'affiliate_network_oid',
110
+ :'approval_needed' => :'approval_needed',
111
+ :'assign_to_affiliate_oid' => :'assign_to_affiliate_oid',
112
+ :'changes' => :'changes',
113
+ :'commission' => :'commission',
114
+ :'conversion_pixel' => :'conversion_pixel',
115
+ :'conversion_pixel_sha256' => :'conversion_pixel_sha256',
116
+ :'conversion_pixel_size_bytes' => :'conversion_pixel_size_bytes',
117
+ :'conversion_type' => :'conversion_type',
118
+ :'cookie_lifetime_days' => :'cookie_lifetime_days',
119
+ :'dry_run' => :'dry_run',
120
+ :'fire_percentage' => :'fire_percentage',
121
+ :'hash_sha256' => :'hash_sha256',
122
+ :'if_not_fired' => :'if_not_fired',
123
+ :'if_not_fired_affiliate_oid' => :'if_not_fired_affiliate_oid',
124
+ :'network_name' => :'network_name',
125
+ :'parameter_name' => :'parameter_name',
126
+ :'parameter_value' => :'parameter_value',
127
+ :'record_fire_in_custom_field' => :'record_fire_in_custom_field',
128
+ :'record_name_in_custom_field' => :'record_name_in_custom_field',
129
+ :'remove_empty_pixel_parameters' => :'remove_empty_pixel_parameters',
130
+ :'stomp_previous_cookie' => :'stomp_previous_cookie'
131
+ }
132
+ end
133
+
134
+ # Returns all the JSON keys this model knows about
135
+ def self.acceptable_attributes
136
+ attribute_map.values
137
+ end
138
+
139
+ # Attribute type mapping.
140
+ def self.openapi_types
141
+ {
142
+ :'affiliate_network_oid' => :'Integer',
143
+ :'approval_needed' => :'Boolean',
144
+ :'assign_to_affiliate_oid' => :'Integer',
145
+ :'changes' => :'Array<SfvbTrackingChange>',
146
+ :'commission' => :'Float',
147
+ :'conversion_pixel' => :'String',
148
+ :'conversion_pixel_sha256' => :'String',
149
+ :'conversion_pixel_size_bytes' => :'Integer',
150
+ :'conversion_type' => :'String',
151
+ :'cookie_lifetime_days' => :'Integer',
152
+ :'dry_run' => :'Boolean',
153
+ :'fire_percentage' => :'Float',
154
+ :'hash_sha256' => :'String',
155
+ :'if_not_fired' => :'String',
156
+ :'if_not_fired_affiliate_oid' => :'Integer',
157
+ :'network_name' => :'String',
158
+ :'parameter_name' => :'String',
159
+ :'parameter_value' => :'String',
160
+ :'record_fire_in_custom_field' => :'Integer',
161
+ :'record_name_in_custom_field' => :'Integer',
162
+ :'remove_empty_pixel_parameters' => :'Boolean',
163
+ :'stomp_previous_cookie' => :'Boolean'
164
+ }
165
+ end
166
+
167
+ # List of attributes with nullable: true
168
+ def self.openapi_nullable
169
+ Set.new([
170
+ ])
171
+ end
172
+
173
+ # Initializes the object
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ def initialize(attributes = {})
176
+ if (!attributes.is_a?(Hash))
177
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbAffiliateNetwork` initialize method"
178
+ end
179
+
180
+ # check to see if the attribute exists and convert string to symbol for hash key
181
+ attributes = attributes.each_with_object({}) { |(k, v), h|
182
+ if (!self.class.attribute_map.key?(k.to_sym))
183
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbAffiliateNetwork`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
184
+ end
185
+ h[k.to_sym] = v
186
+ }
187
+
188
+ if attributes.key?(:'affiliate_network_oid')
189
+ self.affiliate_network_oid = attributes[:'affiliate_network_oid']
190
+ end
191
+
192
+ if attributes.key?(:'approval_needed')
193
+ self.approval_needed = attributes[:'approval_needed']
194
+ end
195
+
196
+ if attributes.key?(:'assign_to_affiliate_oid')
197
+ self.assign_to_affiliate_oid = attributes[:'assign_to_affiliate_oid']
198
+ end
199
+
200
+ if attributes.key?(:'changes')
201
+ if (value = attributes[:'changes']).is_a?(Array)
202
+ self.changes = value
203
+ end
204
+ end
205
+
206
+ if attributes.key?(:'commission')
207
+ self.commission = attributes[:'commission']
208
+ end
209
+
210
+ if attributes.key?(:'conversion_pixel')
211
+ self.conversion_pixel = attributes[:'conversion_pixel']
212
+ end
213
+
214
+ if attributes.key?(:'conversion_pixel_sha256')
215
+ self.conversion_pixel_sha256 = attributes[:'conversion_pixel_sha256']
216
+ end
217
+
218
+ if attributes.key?(:'conversion_pixel_size_bytes')
219
+ self.conversion_pixel_size_bytes = attributes[:'conversion_pixel_size_bytes']
220
+ end
221
+
222
+ if attributes.key?(:'conversion_type')
223
+ self.conversion_type = attributes[:'conversion_type']
224
+ end
225
+
226
+ if attributes.key?(:'cookie_lifetime_days')
227
+ self.cookie_lifetime_days = attributes[:'cookie_lifetime_days']
228
+ end
229
+
230
+ if attributes.key?(:'dry_run')
231
+ self.dry_run = attributes[:'dry_run']
232
+ end
233
+
234
+ if attributes.key?(:'fire_percentage')
235
+ self.fire_percentage = attributes[:'fire_percentage']
236
+ end
237
+
238
+ if attributes.key?(:'hash_sha256')
239
+ self.hash_sha256 = attributes[:'hash_sha256']
240
+ end
241
+
242
+ if attributes.key?(:'if_not_fired')
243
+ self.if_not_fired = attributes[:'if_not_fired']
244
+ end
245
+
246
+ if attributes.key?(:'if_not_fired_affiliate_oid')
247
+ self.if_not_fired_affiliate_oid = attributes[:'if_not_fired_affiliate_oid']
248
+ end
249
+
250
+ if attributes.key?(:'network_name')
251
+ self.network_name = attributes[:'network_name']
252
+ end
253
+
254
+ if attributes.key?(:'parameter_name')
255
+ self.parameter_name = attributes[:'parameter_name']
256
+ end
257
+
258
+ if attributes.key?(:'parameter_value')
259
+ self.parameter_value = attributes[:'parameter_value']
260
+ end
261
+
262
+ if attributes.key?(:'record_fire_in_custom_field')
263
+ self.record_fire_in_custom_field = attributes[:'record_fire_in_custom_field']
264
+ end
265
+
266
+ if attributes.key?(:'record_name_in_custom_field')
267
+ self.record_name_in_custom_field = attributes[:'record_name_in_custom_field']
268
+ end
269
+
270
+ if attributes.key?(:'remove_empty_pixel_parameters')
271
+ self.remove_empty_pixel_parameters = attributes[:'remove_empty_pixel_parameters']
272
+ end
273
+
274
+ if attributes.key?(:'stomp_previous_cookie')
275
+ self.stomp_previous_cookie = attributes[:'stomp_previous_cookie']
276
+ end
277
+ end
278
+
279
+ # Show invalid properties with the reasons. Usually used together with valid?
280
+ # @return Array for valid properties with the reasons
281
+ def list_invalid_properties
282
+ invalid_properties = Array.new
283
+ invalid_properties
284
+ end
285
+
286
+ # Check to see if the all the properties in the model are valid
287
+ # @return true if the model is valid
288
+ def valid?
289
+ conversion_type_validator = EnumAttributeValidator.new('String', ["custom", "commission_junction", "server_to_server"])
290
+ return false unless conversion_type_validator.valid?(@conversion_type)
291
+ if_not_fired_validator = EnumAttributeValidator.new('String', ["process", "skip", "assign"])
292
+ return false unless if_not_fired_validator.valid?(@if_not_fired)
293
+ true
294
+ end
295
+
296
+ # Custom attribute writer method checking allowed values (enum).
297
+ # @param [Object] conversion_type Object to be assigned
298
+ def conversion_type=(conversion_type)
299
+ validator = EnumAttributeValidator.new('String', ["custom", "commission_junction", "server_to_server"])
300
+ unless validator.valid?(conversion_type)
301
+ fail ArgumentError, "invalid value for \"conversion_type\", must be one of #{validator.allowable_values}."
302
+ end
303
+ @conversion_type = conversion_type
304
+ end
305
+
306
+ # Custom attribute writer method checking allowed values (enum).
307
+ # @param [Object] if_not_fired Object to be assigned
308
+ def if_not_fired=(if_not_fired)
309
+ validator = EnumAttributeValidator.new('String', ["process", "skip", "assign"])
310
+ unless validator.valid?(if_not_fired)
311
+ fail ArgumentError, "invalid value for \"if_not_fired\", must be one of #{validator.allowable_values}."
312
+ end
313
+ @if_not_fired = if_not_fired
314
+ end
315
+
316
+ # Checks equality by comparing each attribute.
317
+ # @param [Object] Object to be compared
318
+ def ==(o)
319
+ return true if self.equal?(o)
320
+ self.class == o.class &&
321
+ affiliate_network_oid == o.affiliate_network_oid &&
322
+ approval_needed == o.approval_needed &&
323
+ assign_to_affiliate_oid == o.assign_to_affiliate_oid &&
324
+ changes == o.changes &&
325
+ commission == o.commission &&
326
+ conversion_pixel == o.conversion_pixel &&
327
+ conversion_pixel_sha256 == o.conversion_pixel_sha256 &&
328
+ conversion_pixel_size_bytes == o.conversion_pixel_size_bytes &&
329
+ conversion_type == o.conversion_type &&
330
+ cookie_lifetime_days == o.cookie_lifetime_days &&
331
+ dry_run == o.dry_run &&
332
+ fire_percentage == o.fire_percentage &&
333
+ hash_sha256 == o.hash_sha256 &&
334
+ if_not_fired == o.if_not_fired &&
335
+ if_not_fired_affiliate_oid == o.if_not_fired_affiliate_oid &&
336
+ network_name == o.network_name &&
337
+ parameter_name == o.parameter_name &&
338
+ parameter_value == o.parameter_value &&
339
+ record_fire_in_custom_field == o.record_fire_in_custom_field &&
340
+ record_name_in_custom_field == o.record_name_in_custom_field &&
341
+ remove_empty_pixel_parameters == o.remove_empty_pixel_parameters &&
342
+ stomp_previous_cookie == o.stomp_previous_cookie
343
+ end
344
+
345
+ # @see the `==` method
346
+ # @param [Object] Object to be compared
347
+ def eql?(o)
348
+ self == o
349
+ end
350
+
351
+ # Calculates hash code according to all attributes.
352
+ # @return [Integer] Hash code
353
+ def hash
354
+ [affiliate_network_oid, approval_needed, assign_to_affiliate_oid, changes, commission, conversion_pixel, conversion_pixel_sha256, conversion_pixel_size_bytes, conversion_type, cookie_lifetime_days, dry_run, fire_percentage, hash_sha256, if_not_fired, if_not_fired_affiliate_oid, network_name, parameter_name, parameter_value, record_fire_in_custom_field, record_name_in_custom_field, remove_empty_pixel_parameters, stomp_previous_cookie].hash
355
+ end
356
+
357
+ # Builds the object from hash
358
+ # @param [Hash] attributes Model attributes in the form of hash
359
+ # @return [Object] Returns the model itself
360
+ def self.build_from_hash(attributes)
361
+ new.build_from_hash(attributes)
362
+ end
363
+
364
+ # Builds the object from hash
365
+ # @param [Hash] attributes Model attributes in the form of hash
366
+ # @return [Object] Returns the model itself
367
+ def build_from_hash(attributes)
368
+ return nil unless attributes.is_a?(Hash)
369
+ attributes = attributes.transform_keys(&:to_sym)
370
+ self.class.openapi_types.each_pair do |key, type|
371
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
372
+ self.send("#{key}=", nil)
373
+ elsif type =~ /\AArray<(.*)>/i
374
+ # check to ensure the input is an array given that the attribute
375
+ # is documented as an array but the input is not
376
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
377
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
378
+ end
379
+ elsif !attributes[self.class.attribute_map[key]].nil?
380
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
381
+ end
382
+ end
383
+
384
+ self
385
+ end
386
+
387
+ # Deserializes the data based on type
388
+ # @param string type Data type
389
+ # @param string value Value to be deserialized
390
+ # @return [Object] Deserialized data
391
+ def _deserialize(type, value)
392
+ case type.to_sym
393
+ when :Time
394
+ Time.parse(value)
395
+ when :Date
396
+ Date.parse(value)
397
+ when :String
398
+ value.to_s
399
+ when :Integer
400
+ value.to_i
401
+ when :Float
402
+ value.to_f
403
+ when :Boolean
404
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
405
+ true
406
+ else
407
+ false
408
+ end
409
+ when :Object
410
+ # generic object (usually a Hash), return directly
411
+ value
412
+ when /\AArray<(?<inner_type>.+)>\z/
413
+ inner_type = Regexp.last_match[:inner_type]
414
+ value.map { |v| _deserialize(inner_type, v) }
415
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
416
+ k_type = Regexp.last_match[:k_type]
417
+ v_type = Regexp.last_match[:v_type]
418
+ {}.tap do |hash|
419
+ value.each do |k, v|
420
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
421
+ end
422
+ end
423
+ else # model
424
+ # models (e.g. Pet) or oneOf
425
+ klass = UltracartClient.const_get(type)
426
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
427
+ end
428
+ end
429
+
430
+ # Returns the string representation of the object
431
+ # @return [String] String presentation of the object
432
+ def to_s
433
+ to_hash.to_s
434
+ end
435
+
436
+ # to_body is an alias to to_hash (backward compatibility)
437
+ # @return [Hash] Returns the object in the form of hash
438
+ def to_body
439
+ to_hash
440
+ end
441
+
442
+ # Returns the object in the form of hash
443
+ # @return [Hash] Returns the object in the form of hash
444
+ def to_hash
445
+ hash = {}
446
+ self.class.attribute_map.each_pair do |attr, param|
447
+ value = self.send(attr)
448
+ if value.nil?
449
+ is_nullable = self.class.openapi_nullable.include?(attr)
450
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
451
+ end
452
+
453
+ hash[param] = _to_hash(value)
454
+ end
455
+ hash
456
+ end
457
+
458
+ # Outputs non-array value in the form of hash
459
+ # For object, use to_hash. Otherwise, just return the value
460
+ # @param [Object] value Any valid value
461
+ # @return [Hash] Returns the value in the form of hash
462
+ def _to_hash(value)
463
+ if value.is_a?(Array)
464
+ value.compact.map { |v| _to_hash(v) }
465
+ elsif value.is_a?(Hash)
466
+ {}.tap do |hash|
467
+ value.each { |k, v| hash[k] = _to_hash(v) }
468
+ end
469
+ elsif value.respond_to? :to_hash
470
+ value.to_hash
471
+ else
472
+ value
473
+ end
474
+ end
475
+
476
+ end
477
+
478
+ end