ultracart_api 4.1.92 → 4.1.94

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -2
  3. data/docs/FraudApi.md +278 -0
  4. data/docs/FraudDeclineEmailRequest.md +18 -0
  5. data/docs/FraudLookupValues.md +28 -0
  6. data/docs/FraudLookupValuesResponse.md +26 -0
  7. data/docs/FraudRuleInsertRequest.md +76 -0
  8. data/docs/FraudRuleItemFilter.md +20 -0
  9. data/docs/FraudRulePublic.md +90 -0
  10. data/docs/FraudRuleResponse.md +26 -0
  11. data/docs/FraudRuleRotatingTransactionGatewayFilter.md +20 -0
  12. data/docs/FraudRuleSearchRequest.md +78 -0
  13. data/docs/FraudRuleStorefrontFilter.md +20 -0
  14. data/docs/FraudRulesResponse.md +26 -0
  15. data/docs/ItemVariantItem.md +2 -0
  16. data/lib/ultracart_api/api/fraud_api.rb +373 -0
  17. data/lib/ultracart_api/models/fraud_decline_email_request.rb +220 -0
  18. data/lib/ultracart_api/models/fraud_lookup_values.rb +270 -0
  19. data/lib/ultracart_api/models/fraud_lookup_values_response.rb +256 -0
  20. data/lib/ultracart_api/models/fraud_rule_insert_request.rb +583 -0
  21. data/lib/ultracart_api/models/fraud_rule_item_filter.rb +245 -0
  22. data/lib/ultracart_api/models/fraud_rule_public.rb +652 -0
  23. data/lib/ultracart_api/models/fraud_rule_response.rb +256 -0
  24. data/lib/ultracart_api/models/fraud_rule_rotating_transaction_gateway_filter.rb +230 -0
  25. data/lib/ultracart_api/models/fraud_rule_search_request.rb +572 -0
  26. data/lib/ultracart_api/models/fraud_rule_storefront_filter.rb +245 -0
  27. data/lib/ultracart_api/models/fraud_rules_response.rb +259 -0
  28. data/lib/ultracart_api/models/item_variant_item.rb +11 -1
  29. data/lib/ultracart_api/version.rb +1 -1
  30. data/lib/ultracart_api.rb +12 -0
  31. metadata +26 -2
@@ -0,0 +1,572 @@
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 FraudRuleSearchRequest
18
+ # Affiliate oid (integer) or affiliate email. Email is resolved to oid before searching.
19
+ attr_accessor :affiliate_oid_or_email
20
+
21
+ # Lower bound on amount/score/percentage thresholds (rules backed by the same numeric column).
22
+ attr_accessor :amount_threshold_begin
23
+
24
+ attr_accessor :amount_threshold_end
25
+
26
+ # Wildcard search on the rule's auto_note. Use '*' for wildcards.
27
+ attr_accessor :auto_note
28
+
29
+ # Lower bound on count thresholds (rules backed by the same integer count column).
30
+ attr_accessor :count_threshold_begin
31
+
32
+ attr_accessor :count_threshold_end
33
+
34
+ attr_accessor :created_by
35
+
36
+ # Rule creation date begin (MM/dd/yyyy)
37
+ attr_accessor :created_date_begin
38
+
39
+ # Rule creation date end (MM/dd/yyyy)
40
+ attr_accessor :created_date_end
41
+
42
+ # Partial credit card number for matching 'credit card matches' rules. Use '*' wildcards.
43
+ attr_accessor :credit_card_partial
44
+
45
+ # Wildcard search on the rule's decline_message. Use '*' for wildcards.
46
+ attr_accessor :decline_message
47
+
48
+ attr_accessor :failure_action
49
+
50
+ attr_accessor :gateway_code
51
+
52
+ attr_accessor :merchant_item_id
53
+
54
+ # Wildcard search on the rule's secondary modifier (eg 'address'/'subnet', gateway codes, avs match types).
55
+ attr_accessor :modifier_value
56
+
57
+ attr_accessor :modify_custom_field1
58
+
59
+ attr_accessor :modify_custom_field2
60
+
61
+ attr_accessor :modify_custom_field3
62
+
63
+ attr_accessor :modify_custom_field4
64
+
65
+ attr_accessor :modify_custom_field5
66
+
67
+ attr_accessor :modify_custom_field6
68
+
69
+ attr_accessor :modify_custom_field7
70
+
71
+ attr_accessor :modify_skip_affiliate
72
+
73
+ attr_accessor :modify_skip_affiliate_network_pixel
74
+
75
+ # Rule group to filter by.
76
+ attr_accessor :rule_group
77
+
78
+ # Rule type to filter by.
79
+ attr_accessor :rule_type
80
+
81
+ # Include rules from accounts linked to this merchant. Defaults to false.
82
+ attr_accessor :search_linked_accounts
83
+
84
+ attr_accessor :storefront_hostname
85
+
86
+ # Wildcard search on the rule's text parameter (email / ip / bin / country / item id / avs codes - the backend disambiguates by rule_type).
87
+ attr_accessor :text_value
88
+
89
+ attr_accessor :theme_code
90
+
91
+ attr_accessor :user_action
92
+
93
+ class EnumAttributeValidator
94
+ attr_reader :datatype
95
+ attr_reader :allowable_values
96
+
97
+ def initialize(datatype, allowable_values)
98
+ @allowable_values = allowable_values.map do |value|
99
+ case datatype.to_s
100
+ when /Integer/i
101
+ value.to_i
102
+ when /Float/i
103
+ value.to_f
104
+ else
105
+ value
106
+ end
107
+ end
108
+ end
109
+
110
+ def valid?(value)
111
+ !value || allowable_values.include?(value)
112
+ end
113
+ end
114
+
115
+ # Attribute mapping from ruby-style variable name to JSON key.
116
+ def self.attribute_map
117
+ {
118
+ :'affiliate_oid_or_email' => :'affiliate_oid_or_email',
119
+ :'amount_threshold_begin' => :'amount_threshold_begin',
120
+ :'amount_threshold_end' => :'amount_threshold_end',
121
+ :'auto_note' => :'auto_note',
122
+ :'count_threshold_begin' => :'count_threshold_begin',
123
+ :'count_threshold_end' => :'count_threshold_end',
124
+ :'created_by' => :'created_by',
125
+ :'created_date_begin' => :'created_date_begin',
126
+ :'created_date_end' => :'created_date_end',
127
+ :'credit_card_partial' => :'credit_card_partial',
128
+ :'decline_message' => :'decline_message',
129
+ :'failure_action' => :'failure_action',
130
+ :'gateway_code' => :'gateway_code',
131
+ :'merchant_item_id' => :'merchant_item_id',
132
+ :'modifier_value' => :'modifier_value',
133
+ :'modify_custom_field1' => :'modify_custom_field1',
134
+ :'modify_custom_field2' => :'modify_custom_field2',
135
+ :'modify_custom_field3' => :'modify_custom_field3',
136
+ :'modify_custom_field4' => :'modify_custom_field4',
137
+ :'modify_custom_field5' => :'modify_custom_field5',
138
+ :'modify_custom_field6' => :'modify_custom_field6',
139
+ :'modify_custom_field7' => :'modify_custom_field7',
140
+ :'modify_skip_affiliate' => :'modify_skip_affiliate',
141
+ :'modify_skip_affiliate_network_pixel' => :'modify_skip_affiliate_network_pixel',
142
+ :'rule_group' => :'rule_group',
143
+ :'rule_type' => :'rule_type',
144
+ :'search_linked_accounts' => :'search_linked_accounts',
145
+ :'storefront_hostname' => :'storefront_hostname',
146
+ :'text_value' => :'text_value',
147
+ :'theme_code' => :'theme_code',
148
+ :'user_action' => :'user_action'
149
+ }
150
+ end
151
+
152
+ # Returns all the JSON keys this model knows about
153
+ def self.acceptable_attributes
154
+ attribute_map.values
155
+ end
156
+
157
+ # Attribute type mapping.
158
+ def self.openapi_types
159
+ {
160
+ :'affiliate_oid_or_email' => :'String',
161
+ :'amount_threshold_begin' => :'Float',
162
+ :'amount_threshold_end' => :'Float',
163
+ :'auto_note' => :'String',
164
+ :'count_threshold_begin' => :'Integer',
165
+ :'count_threshold_end' => :'Integer',
166
+ :'created_by' => :'String',
167
+ :'created_date_begin' => :'String',
168
+ :'created_date_end' => :'String',
169
+ :'credit_card_partial' => :'String',
170
+ :'decline_message' => :'String',
171
+ :'failure_action' => :'String',
172
+ :'gateway_code' => :'String',
173
+ :'merchant_item_id' => :'String',
174
+ :'modifier_value' => :'String',
175
+ :'modify_custom_field1' => :'String',
176
+ :'modify_custom_field2' => :'String',
177
+ :'modify_custom_field3' => :'String',
178
+ :'modify_custom_field4' => :'String',
179
+ :'modify_custom_field5' => :'String',
180
+ :'modify_custom_field6' => :'String',
181
+ :'modify_custom_field7' => :'String',
182
+ :'modify_skip_affiliate' => :'Boolean',
183
+ :'modify_skip_affiliate_network_pixel' => :'Boolean',
184
+ :'rule_group' => :'String',
185
+ :'rule_type' => :'String',
186
+ :'search_linked_accounts' => :'Boolean',
187
+ :'storefront_hostname' => :'String',
188
+ :'text_value' => :'String',
189
+ :'theme_code' => :'String',
190
+ :'user_action' => :'String'
191
+ }
192
+ end
193
+
194
+ # List of attributes with nullable: true
195
+ def self.openapi_nullable
196
+ Set.new([
197
+ ])
198
+ end
199
+
200
+ # Initializes the object
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ def initialize(attributes = {})
203
+ if (!attributes.is_a?(Hash))
204
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::FraudRuleSearchRequest` initialize method"
205
+ end
206
+
207
+ # check to see if the attribute exists and convert string to symbol for hash key
208
+ attributes = attributes.each_with_object({}) { |(k, v), h|
209
+ if (!self.class.attribute_map.key?(k.to_sym))
210
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::FraudRuleSearchRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
211
+ end
212
+ h[k.to_sym] = v
213
+ }
214
+
215
+ if attributes.key?(:'affiliate_oid_or_email')
216
+ self.affiliate_oid_or_email = attributes[:'affiliate_oid_or_email']
217
+ end
218
+
219
+ if attributes.key?(:'amount_threshold_begin')
220
+ self.amount_threshold_begin = attributes[:'amount_threshold_begin']
221
+ end
222
+
223
+ if attributes.key?(:'amount_threshold_end')
224
+ self.amount_threshold_end = attributes[:'amount_threshold_end']
225
+ end
226
+
227
+ if attributes.key?(:'auto_note')
228
+ self.auto_note = attributes[:'auto_note']
229
+ end
230
+
231
+ if attributes.key?(:'count_threshold_begin')
232
+ self.count_threshold_begin = attributes[:'count_threshold_begin']
233
+ end
234
+
235
+ if attributes.key?(:'count_threshold_end')
236
+ self.count_threshold_end = attributes[:'count_threshold_end']
237
+ end
238
+
239
+ if attributes.key?(:'created_by')
240
+ self.created_by = attributes[:'created_by']
241
+ end
242
+
243
+ if attributes.key?(:'created_date_begin')
244
+ self.created_date_begin = attributes[:'created_date_begin']
245
+ end
246
+
247
+ if attributes.key?(:'created_date_end')
248
+ self.created_date_end = attributes[:'created_date_end']
249
+ end
250
+
251
+ if attributes.key?(:'credit_card_partial')
252
+ self.credit_card_partial = attributes[:'credit_card_partial']
253
+ end
254
+
255
+ if attributes.key?(:'decline_message')
256
+ self.decline_message = attributes[:'decline_message']
257
+ end
258
+
259
+ if attributes.key?(:'failure_action')
260
+ self.failure_action = attributes[:'failure_action']
261
+ end
262
+
263
+ if attributes.key?(:'gateway_code')
264
+ self.gateway_code = attributes[:'gateway_code']
265
+ end
266
+
267
+ if attributes.key?(:'merchant_item_id')
268
+ self.merchant_item_id = attributes[:'merchant_item_id']
269
+ end
270
+
271
+ if attributes.key?(:'modifier_value')
272
+ self.modifier_value = attributes[:'modifier_value']
273
+ end
274
+
275
+ if attributes.key?(:'modify_custom_field1')
276
+ self.modify_custom_field1 = attributes[:'modify_custom_field1']
277
+ end
278
+
279
+ if attributes.key?(:'modify_custom_field2')
280
+ self.modify_custom_field2 = attributes[:'modify_custom_field2']
281
+ end
282
+
283
+ if attributes.key?(:'modify_custom_field3')
284
+ self.modify_custom_field3 = attributes[:'modify_custom_field3']
285
+ end
286
+
287
+ if attributes.key?(:'modify_custom_field4')
288
+ self.modify_custom_field4 = attributes[:'modify_custom_field4']
289
+ end
290
+
291
+ if attributes.key?(:'modify_custom_field5')
292
+ self.modify_custom_field5 = attributes[:'modify_custom_field5']
293
+ end
294
+
295
+ if attributes.key?(:'modify_custom_field6')
296
+ self.modify_custom_field6 = attributes[:'modify_custom_field6']
297
+ end
298
+
299
+ if attributes.key?(:'modify_custom_field7')
300
+ self.modify_custom_field7 = attributes[:'modify_custom_field7']
301
+ end
302
+
303
+ if attributes.key?(:'modify_skip_affiliate')
304
+ self.modify_skip_affiliate = attributes[:'modify_skip_affiliate']
305
+ end
306
+
307
+ if attributes.key?(:'modify_skip_affiliate_network_pixel')
308
+ self.modify_skip_affiliate_network_pixel = attributes[:'modify_skip_affiliate_network_pixel']
309
+ end
310
+
311
+ if attributes.key?(:'rule_group')
312
+ self.rule_group = attributes[:'rule_group']
313
+ end
314
+
315
+ if attributes.key?(:'rule_type')
316
+ self.rule_type = attributes[:'rule_type']
317
+ end
318
+
319
+ if attributes.key?(:'search_linked_accounts')
320
+ self.search_linked_accounts = attributes[:'search_linked_accounts']
321
+ end
322
+
323
+ if attributes.key?(:'storefront_hostname')
324
+ self.storefront_hostname = attributes[:'storefront_hostname']
325
+ end
326
+
327
+ if attributes.key?(:'text_value')
328
+ self.text_value = attributes[:'text_value']
329
+ end
330
+
331
+ if attributes.key?(:'theme_code')
332
+ self.theme_code = attributes[:'theme_code']
333
+ end
334
+
335
+ if attributes.key?(:'user_action')
336
+ self.user_action = attributes[:'user_action']
337
+ end
338
+ end
339
+
340
+ # Show invalid properties with the reasons. Usually used together with valid?
341
+ # @return Array for valid properties with the reasons
342
+ def list_invalid_properties
343
+ invalid_properties = Array.new
344
+ invalid_properties
345
+ end
346
+
347
+ # Check to see if the all the properties in the model are valid
348
+ # @return true if the model is valid
349
+ def valid?
350
+ failure_action_validator = EnumAttributeValidator.new('String', ["Flag For Review", "Process Payment and Modify", "Process Payment and Review", "Decline Transaction", "Exempt"])
351
+ return false unless failure_action_validator.valid?(@failure_action)
352
+ rule_group_validator = EnumAttributeValidator.new('String', ["exemptRules", "creditCardRules", "ipRules", "addressRules", "affiliateRules", "itemRules", "orderRules", "browserRules"])
353
+ return false unless rule_group_validator.valid?(@rule_group)
354
+ rule_type_validator = EnumAttributeValidator.new('String', ["exempt apo fpo", "exempt ip", "exempt logged in customer with pricing tier", "credit card single transaction exceeds", "credit card daily transaction amount exceeds", "credit card daily transaction count exceeds", "credit card weekly transaction amount exceeds", "credit card weekly transaction count exceeds", "credit card change number", "credit card block bin", "credit card block prepaid", "amazon special instructions", "paypal special instructions", "reward coupon email mismatch", "gateway response", "ip daily transaction amount exceeds", "ip daily transaction count exceeds", "ip weekly transaction amount exceeds", "ip weekly transaction count exceeds", "ip matches", "ip country mismatch", "address fraud score exceeds", "address fraud score exceeds exempt apo fpo", "address street and zip avs", "address billing doesnt match shipping", "billing country doesnt match shipping", "address international", "address match except zip", "address email", "address not in country", "wholesale customer not logged in", "affiliate matches", "affiliate daily count exceeds", "affiliate weekly count exceeds", "affiliate daily decline percentage exceeds", "affiliate weekly decline percentage exceeds", "affiliate daily with same ip", "affiliate weekly with same ip", "item matches", "item quantity exceeds", "order previous return", "order purchased within last hours", "order used coupon meant for sharing", "browser os linux"])
355
+ return false unless rule_type_validator.valid?(@rule_type)
356
+ user_action_validator = EnumAttributeValidator.new('String', ["Attempted", "Approved"])
357
+ return false unless user_action_validator.valid?(@user_action)
358
+ true
359
+ end
360
+
361
+ # Custom attribute writer method checking allowed values (enum).
362
+ # @param [Object] failure_action Object to be assigned
363
+ def failure_action=(failure_action)
364
+ validator = EnumAttributeValidator.new('String', ["Flag For Review", "Process Payment and Modify", "Process Payment and Review", "Decline Transaction", "Exempt"])
365
+ unless validator.valid?(failure_action)
366
+ fail ArgumentError, "invalid value for \"failure_action\", must be one of #{validator.allowable_values}."
367
+ end
368
+ @failure_action = failure_action
369
+ end
370
+
371
+ # Custom attribute writer method checking allowed values (enum).
372
+ # @param [Object] rule_group Object to be assigned
373
+ def rule_group=(rule_group)
374
+ validator = EnumAttributeValidator.new('String', ["exemptRules", "creditCardRules", "ipRules", "addressRules", "affiliateRules", "itemRules", "orderRules", "browserRules"])
375
+ unless validator.valid?(rule_group)
376
+ fail ArgumentError, "invalid value for \"rule_group\", must be one of #{validator.allowable_values}."
377
+ end
378
+ @rule_group = rule_group
379
+ end
380
+
381
+ # Custom attribute writer method checking allowed values (enum).
382
+ # @param [Object] rule_type Object to be assigned
383
+ def rule_type=(rule_type)
384
+ validator = EnumAttributeValidator.new('String', ["exempt apo fpo", "exempt ip", "exempt logged in customer with pricing tier", "credit card single transaction exceeds", "credit card daily transaction amount exceeds", "credit card daily transaction count exceeds", "credit card weekly transaction amount exceeds", "credit card weekly transaction count exceeds", "credit card change number", "credit card block bin", "credit card block prepaid", "amazon special instructions", "paypal special instructions", "reward coupon email mismatch", "gateway response", "ip daily transaction amount exceeds", "ip daily transaction count exceeds", "ip weekly transaction amount exceeds", "ip weekly transaction count exceeds", "ip matches", "ip country mismatch", "address fraud score exceeds", "address fraud score exceeds exempt apo fpo", "address street and zip avs", "address billing doesnt match shipping", "billing country doesnt match shipping", "address international", "address match except zip", "address email", "address not in country", "wholesale customer not logged in", "affiliate matches", "affiliate daily count exceeds", "affiliate weekly count exceeds", "affiliate daily decline percentage exceeds", "affiliate weekly decline percentage exceeds", "affiliate daily with same ip", "affiliate weekly with same ip", "item matches", "item quantity exceeds", "order previous return", "order purchased within last hours", "order used coupon meant for sharing", "browser os linux"])
385
+ unless validator.valid?(rule_type)
386
+ fail ArgumentError, "invalid value for \"rule_type\", must be one of #{validator.allowable_values}."
387
+ end
388
+ @rule_type = rule_type
389
+ end
390
+
391
+ # Custom attribute writer method checking allowed values (enum).
392
+ # @param [Object] user_action Object to be assigned
393
+ def user_action=(user_action)
394
+ validator = EnumAttributeValidator.new('String', ["Attempted", "Approved"])
395
+ unless validator.valid?(user_action)
396
+ fail ArgumentError, "invalid value for \"user_action\", must be one of #{validator.allowable_values}."
397
+ end
398
+ @user_action = user_action
399
+ end
400
+
401
+ # Checks equality by comparing each attribute.
402
+ # @param [Object] Object to be compared
403
+ def ==(o)
404
+ return true if self.equal?(o)
405
+ self.class == o.class &&
406
+ affiliate_oid_or_email == o.affiliate_oid_or_email &&
407
+ amount_threshold_begin == o.amount_threshold_begin &&
408
+ amount_threshold_end == o.amount_threshold_end &&
409
+ auto_note == o.auto_note &&
410
+ count_threshold_begin == o.count_threshold_begin &&
411
+ count_threshold_end == o.count_threshold_end &&
412
+ created_by == o.created_by &&
413
+ created_date_begin == o.created_date_begin &&
414
+ created_date_end == o.created_date_end &&
415
+ credit_card_partial == o.credit_card_partial &&
416
+ decline_message == o.decline_message &&
417
+ failure_action == o.failure_action &&
418
+ gateway_code == o.gateway_code &&
419
+ merchant_item_id == o.merchant_item_id &&
420
+ modifier_value == o.modifier_value &&
421
+ modify_custom_field1 == o.modify_custom_field1 &&
422
+ modify_custom_field2 == o.modify_custom_field2 &&
423
+ modify_custom_field3 == o.modify_custom_field3 &&
424
+ modify_custom_field4 == o.modify_custom_field4 &&
425
+ modify_custom_field5 == o.modify_custom_field5 &&
426
+ modify_custom_field6 == o.modify_custom_field6 &&
427
+ modify_custom_field7 == o.modify_custom_field7 &&
428
+ modify_skip_affiliate == o.modify_skip_affiliate &&
429
+ modify_skip_affiliate_network_pixel == o.modify_skip_affiliate_network_pixel &&
430
+ rule_group == o.rule_group &&
431
+ rule_type == o.rule_type &&
432
+ search_linked_accounts == o.search_linked_accounts &&
433
+ storefront_hostname == o.storefront_hostname &&
434
+ text_value == o.text_value &&
435
+ theme_code == o.theme_code &&
436
+ user_action == o.user_action
437
+ end
438
+
439
+ # @see the `==` method
440
+ # @param [Object] Object to be compared
441
+ def eql?(o)
442
+ self == o
443
+ end
444
+
445
+ # Calculates hash code according to all attributes.
446
+ # @return [Integer] Hash code
447
+ def hash
448
+ [affiliate_oid_or_email, amount_threshold_begin, amount_threshold_end, auto_note, count_threshold_begin, count_threshold_end, created_by, created_date_begin, created_date_end, credit_card_partial, decline_message, failure_action, gateway_code, merchant_item_id, modifier_value, modify_custom_field1, modify_custom_field2, modify_custom_field3, modify_custom_field4, modify_custom_field5, modify_custom_field6, modify_custom_field7, modify_skip_affiliate, modify_skip_affiliate_network_pixel, rule_group, rule_type, search_linked_accounts, storefront_hostname, text_value, theme_code, user_action].hash
449
+ end
450
+
451
+ # Builds the object from hash
452
+ # @param [Hash] attributes Model attributes in the form of hash
453
+ # @return [Object] Returns the model itself
454
+ def self.build_from_hash(attributes)
455
+ new.build_from_hash(attributes)
456
+ end
457
+
458
+ # Builds the object from hash
459
+ # @param [Hash] attributes Model attributes in the form of hash
460
+ # @return [Object] Returns the model itself
461
+ def build_from_hash(attributes)
462
+ return nil unless attributes.is_a?(Hash)
463
+ attributes = attributes.transform_keys(&:to_sym)
464
+ self.class.openapi_types.each_pair do |key, type|
465
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
466
+ self.send("#{key}=", nil)
467
+ elsif type =~ /\AArray<(.*)>/i
468
+ # check to ensure the input is an array given that the attribute
469
+ # is documented as an array but the input is not
470
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
471
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
472
+ end
473
+ elsif !attributes[self.class.attribute_map[key]].nil?
474
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
475
+ end
476
+ end
477
+
478
+ self
479
+ end
480
+
481
+ # Deserializes the data based on type
482
+ # @param string type Data type
483
+ # @param string value Value to be deserialized
484
+ # @return [Object] Deserialized data
485
+ def _deserialize(type, value)
486
+ case type.to_sym
487
+ when :Time
488
+ Time.parse(value)
489
+ when :Date
490
+ Date.parse(value)
491
+ when :String
492
+ value.to_s
493
+ when :Integer
494
+ value.to_i
495
+ when :Float
496
+ value.to_f
497
+ when :Boolean
498
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
499
+ true
500
+ else
501
+ false
502
+ end
503
+ when :Object
504
+ # generic object (usually a Hash), return directly
505
+ value
506
+ when /\AArray<(?<inner_type>.+)>\z/
507
+ inner_type = Regexp.last_match[:inner_type]
508
+ value.map { |v| _deserialize(inner_type, v) }
509
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
510
+ k_type = Regexp.last_match[:k_type]
511
+ v_type = Regexp.last_match[:v_type]
512
+ {}.tap do |hash|
513
+ value.each do |k, v|
514
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
515
+ end
516
+ end
517
+ else # model
518
+ # models (e.g. Pet) or oneOf
519
+ klass = UltracartClient.const_get(type)
520
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
521
+ end
522
+ end
523
+
524
+ # Returns the string representation of the object
525
+ # @return [String] String presentation of the object
526
+ def to_s
527
+ to_hash.to_s
528
+ end
529
+
530
+ # to_body is an alias to to_hash (backward compatibility)
531
+ # @return [Hash] Returns the object in the form of hash
532
+ def to_body
533
+ to_hash
534
+ end
535
+
536
+ # Returns the object in the form of hash
537
+ # @return [Hash] Returns the object in the form of hash
538
+ def to_hash
539
+ hash = {}
540
+ self.class.attribute_map.each_pair do |attr, param|
541
+ value = self.send(attr)
542
+ if value.nil?
543
+ is_nullable = self.class.openapi_nullable.include?(attr)
544
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
545
+ end
546
+
547
+ hash[param] = _to_hash(value)
548
+ end
549
+ hash
550
+ end
551
+
552
+ # Outputs non-array value in the form of hash
553
+ # For object, use to_hash. Otherwise, just return the value
554
+ # @param [Object] value Any valid value
555
+ # @return [Hash] Returns the value in the form of hash
556
+ def _to_hash(value)
557
+ if value.is_a?(Array)
558
+ value.compact.map { |v| _to_hash(v) }
559
+ elsif value.is_a?(Hash)
560
+ {}.tap do |hash|
561
+ value.each { |k, v| hash[k] = _to_hash(v) }
562
+ end
563
+ elsif value.respond_to? :to_hash
564
+ value.to_hash
565
+ else
566
+ value
567
+ end
568
+ end
569
+
570
+ end
571
+
572
+ end