ultracart_api 4.1.195 → 4.1.197

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.
@@ -0,0 +1,445 @@
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 SfvbApproval
18
+ # The gated action.
19
+ attr_accessor :action
20
+
21
+ # Send this as the Approval-Id header on the gated call once status is approved.
22
+ attr_accessor :approval_id
23
+
24
+ # The page where the person approves or denies. Show it to them. Never open or fill it in yourself.
25
+ attr_accessor :approval_url
26
+
27
+ # When the request was made, ISO 8601 UTC.
28
+ attr_accessor :created_at
29
+
30
+ # The sentence the person reads before approving. Written by the server, not the agent.
31
+ attr_accessor :description
32
+
33
+ # When this approval stops being usable, ISO 8601 UTC. For a pending request, when it lapses undecided. For an approved one, when it must have been used by.
34
+ attr_accessor :expires_at
35
+
36
+ # Seconds until expires_at. Zero once passed.
37
+ attr_accessor :expires_in_seconds
38
+
39
+ # True when the person must enter a new 2FA code for this request even inside an approval session.
40
+ attr_accessor :fresh_code_required
41
+
42
+ # Poll no more often than this.
43
+ attr_accessor :interval_seconds
44
+
45
+ # Once used, succeeded or failed. Used with no outcome means the result is unknown. Check the target and never send the call again with this approval.
46
+ attr_accessor :outcome
47
+
48
+ # The error code the gated call failed with.
49
+ attr_accessor :outcome_code
50
+
51
+ # The HTTP status the gated call answered with.
52
+ attr_accessor :outcome_http_status
53
+
54
+ attr_accessor :params
55
+
56
+ # The reason the agent sent, as stored and shown (cleaned and capped).
57
+ attr_accessor :reason
58
+
59
+ # Where the action applies. The storefront host name, or account for account-wide actions.
60
+ attr_accessor :scope
61
+
62
+ # pending, approved, denied, cancelled, expired or used. Only approved may be sent with the gated call.
63
+ attr_accessor :status
64
+
65
+ # The storefront the action runs on. Absent for account-wide actions.
66
+ attr_accessor :storefront_oid
67
+
68
+ # When the gated call used this approval, ISO 8601 UTC.
69
+ attr_accessor :used_at
70
+
71
+ # Short matching code. Print it next to approval_url so the person can check the page shows the same code.
72
+ attr_accessor :user_code
73
+
74
+ class EnumAttributeValidator
75
+ attr_reader :datatype
76
+ attr_reader :allowable_values
77
+
78
+ def initialize(datatype, allowable_values)
79
+ @allowable_values = allowable_values.map do |value|
80
+ case datatype.to_s
81
+ when /Integer/i
82
+ value.to_i
83
+ when /Float/i
84
+ value.to_f
85
+ else
86
+ value
87
+ end
88
+ end
89
+ end
90
+
91
+ def valid?(value)
92
+ !value || allowable_values.include?(value)
93
+ end
94
+ end
95
+
96
+ # Attribute mapping from ruby-style variable name to JSON key.
97
+ def self.attribute_map
98
+ {
99
+ :'action' => :'action',
100
+ :'approval_id' => :'approval_id',
101
+ :'approval_url' => :'approval_url',
102
+ :'created_at' => :'created_at',
103
+ :'description' => :'description',
104
+ :'expires_at' => :'expires_at',
105
+ :'expires_in_seconds' => :'expires_in_seconds',
106
+ :'fresh_code_required' => :'fresh_code_required',
107
+ :'interval_seconds' => :'interval_seconds',
108
+ :'outcome' => :'outcome',
109
+ :'outcome_code' => :'outcome_code',
110
+ :'outcome_http_status' => :'outcome_http_status',
111
+ :'params' => :'params',
112
+ :'reason' => :'reason',
113
+ :'scope' => :'scope',
114
+ :'status' => :'status',
115
+ :'storefront_oid' => :'storefront_oid',
116
+ :'used_at' => :'used_at',
117
+ :'user_code' => :'user_code'
118
+ }
119
+ end
120
+
121
+ # Returns all the JSON keys this model knows about
122
+ def self.acceptable_attributes
123
+ attribute_map.values
124
+ end
125
+
126
+ # Attribute type mapping.
127
+ def self.openapi_types
128
+ {
129
+ :'action' => :'String',
130
+ :'approval_id' => :'String',
131
+ :'approval_url' => :'String',
132
+ :'created_at' => :'String',
133
+ :'description' => :'String',
134
+ :'expires_at' => :'String',
135
+ :'expires_in_seconds' => :'Integer',
136
+ :'fresh_code_required' => :'Boolean',
137
+ :'interval_seconds' => :'Integer',
138
+ :'outcome' => :'String',
139
+ :'outcome_code' => :'String',
140
+ :'outcome_http_status' => :'Integer',
141
+ :'params' => :'SfvbApprovalParams',
142
+ :'reason' => :'String',
143
+ :'scope' => :'String',
144
+ :'status' => :'String',
145
+ :'storefront_oid' => :'Integer',
146
+ :'used_at' => :'String',
147
+ :'user_code' => :'String'
148
+ }
149
+ end
150
+
151
+ # List of attributes with nullable: true
152
+ def self.openapi_nullable
153
+ Set.new([
154
+ ])
155
+ end
156
+
157
+ # Initializes the object
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ def initialize(attributes = {})
160
+ if (!attributes.is_a?(Hash))
161
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbApproval` initialize method"
162
+ end
163
+
164
+ # check to see if the attribute exists and convert string to symbol for hash key
165
+ attributes = attributes.each_with_object({}) { |(k, v), h|
166
+ if (!self.class.attribute_map.key?(k.to_sym))
167
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbApproval`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
168
+ end
169
+ h[k.to_sym] = v
170
+ }
171
+
172
+ if attributes.key?(:'action')
173
+ self.action = attributes[:'action']
174
+ end
175
+
176
+ if attributes.key?(:'approval_id')
177
+ self.approval_id = attributes[:'approval_id']
178
+ end
179
+
180
+ if attributes.key?(:'approval_url')
181
+ self.approval_url = attributes[:'approval_url']
182
+ end
183
+
184
+ if attributes.key?(:'created_at')
185
+ self.created_at = attributes[:'created_at']
186
+ end
187
+
188
+ if attributes.key?(:'description')
189
+ self.description = attributes[:'description']
190
+ end
191
+
192
+ if attributes.key?(:'expires_at')
193
+ self.expires_at = attributes[:'expires_at']
194
+ end
195
+
196
+ if attributes.key?(:'expires_in_seconds')
197
+ self.expires_in_seconds = attributes[:'expires_in_seconds']
198
+ end
199
+
200
+ if attributes.key?(:'fresh_code_required')
201
+ self.fresh_code_required = attributes[:'fresh_code_required']
202
+ end
203
+
204
+ if attributes.key?(:'interval_seconds')
205
+ self.interval_seconds = attributes[:'interval_seconds']
206
+ end
207
+
208
+ if attributes.key?(:'outcome')
209
+ self.outcome = attributes[:'outcome']
210
+ end
211
+
212
+ if attributes.key?(:'outcome_code')
213
+ self.outcome_code = attributes[:'outcome_code']
214
+ end
215
+
216
+ if attributes.key?(:'outcome_http_status')
217
+ self.outcome_http_status = attributes[:'outcome_http_status']
218
+ end
219
+
220
+ if attributes.key?(:'params')
221
+ self.params = attributes[:'params']
222
+ end
223
+
224
+ if attributes.key?(:'reason')
225
+ self.reason = attributes[:'reason']
226
+ end
227
+
228
+ if attributes.key?(:'scope')
229
+ self.scope = attributes[:'scope']
230
+ end
231
+
232
+ if attributes.key?(:'status')
233
+ self.status = attributes[:'status']
234
+ end
235
+
236
+ if attributes.key?(:'storefront_oid')
237
+ self.storefront_oid = attributes[:'storefront_oid']
238
+ end
239
+
240
+ if attributes.key?(:'used_at')
241
+ self.used_at = attributes[:'used_at']
242
+ end
243
+
244
+ if attributes.key?(:'user_code')
245
+ self.user_code = attributes[:'user_code']
246
+ end
247
+ end
248
+
249
+ # Show invalid properties with the reasons. Usually used together with valid?
250
+ # @return Array for valid properties with the reasons
251
+ def list_invalid_properties
252
+ invalid_properties = Array.new
253
+ invalid_properties
254
+ end
255
+
256
+ # Check to see if the all the properties in the model are valid
257
+ # @return true if the model is valid
258
+ def valid?
259
+ outcome_validator = EnumAttributeValidator.new('String', ["succeeded", "failed"])
260
+ return false unless outcome_validator.valid?(@outcome)
261
+ status_validator = EnumAttributeValidator.new('String', ["pending", "approved", "denied", "cancelled", "expired", "used"])
262
+ return false unless status_validator.valid?(@status)
263
+ true
264
+ end
265
+
266
+ # Custom attribute writer method checking allowed values (enum).
267
+ # @param [Object] outcome Object to be assigned
268
+ def outcome=(outcome)
269
+ validator = EnumAttributeValidator.new('String', ["succeeded", "failed"])
270
+ unless validator.valid?(outcome)
271
+ fail ArgumentError, "invalid value for \"outcome\", must be one of #{validator.allowable_values}."
272
+ end
273
+ @outcome = outcome
274
+ end
275
+
276
+ # Custom attribute writer method checking allowed values (enum).
277
+ # @param [Object] status Object to be assigned
278
+ def status=(status)
279
+ validator = EnumAttributeValidator.new('String', ["pending", "approved", "denied", "cancelled", "expired", "used"])
280
+ unless validator.valid?(status)
281
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
282
+ end
283
+ @status = status
284
+ end
285
+
286
+ # Checks equality by comparing each attribute.
287
+ # @param [Object] Object to be compared
288
+ def ==(o)
289
+ return true if self.equal?(o)
290
+ self.class == o.class &&
291
+ action == o.action &&
292
+ approval_id == o.approval_id &&
293
+ approval_url == o.approval_url &&
294
+ created_at == o.created_at &&
295
+ description == o.description &&
296
+ expires_at == o.expires_at &&
297
+ expires_in_seconds == o.expires_in_seconds &&
298
+ fresh_code_required == o.fresh_code_required &&
299
+ interval_seconds == o.interval_seconds &&
300
+ outcome == o.outcome &&
301
+ outcome_code == o.outcome_code &&
302
+ outcome_http_status == o.outcome_http_status &&
303
+ params == o.params &&
304
+ reason == o.reason &&
305
+ scope == o.scope &&
306
+ status == o.status &&
307
+ storefront_oid == o.storefront_oid &&
308
+ used_at == o.used_at &&
309
+ user_code == o.user_code
310
+ end
311
+
312
+ # @see the `==` method
313
+ # @param [Object] Object to be compared
314
+ def eql?(o)
315
+ self == o
316
+ end
317
+
318
+ # Calculates hash code according to all attributes.
319
+ # @return [Integer] Hash code
320
+ def hash
321
+ [action, approval_id, approval_url, created_at, description, expires_at, expires_in_seconds, fresh_code_required, interval_seconds, outcome, outcome_code, outcome_http_status, params, reason, scope, status, storefront_oid, used_at, user_code].hash
322
+ end
323
+
324
+ # Builds the object from hash
325
+ # @param [Hash] attributes Model attributes in the form of hash
326
+ # @return [Object] Returns the model itself
327
+ def self.build_from_hash(attributes)
328
+ new.build_from_hash(attributes)
329
+ end
330
+
331
+ # Builds the object from hash
332
+ # @param [Hash] attributes Model attributes in the form of hash
333
+ # @return [Object] Returns the model itself
334
+ def build_from_hash(attributes)
335
+ return nil unless attributes.is_a?(Hash)
336
+ attributes = attributes.transform_keys(&:to_sym)
337
+ self.class.openapi_types.each_pair do |key, type|
338
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
339
+ self.send("#{key}=", nil)
340
+ elsif type =~ /\AArray<(.*)>/i
341
+ # check to ensure the input is an array given that the attribute
342
+ # is documented as an array but the input is not
343
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
344
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
345
+ end
346
+ elsif !attributes[self.class.attribute_map[key]].nil?
347
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
348
+ end
349
+ end
350
+
351
+ self
352
+ end
353
+
354
+ # Deserializes the data based on type
355
+ # @param string type Data type
356
+ # @param string value Value to be deserialized
357
+ # @return [Object] Deserialized data
358
+ def _deserialize(type, value)
359
+ case type.to_sym
360
+ when :Time
361
+ Time.parse(value)
362
+ when :Date
363
+ Date.parse(value)
364
+ when :String
365
+ value.to_s
366
+ when :Integer
367
+ value.to_i
368
+ when :Float
369
+ value.to_f
370
+ when :Boolean
371
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
372
+ true
373
+ else
374
+ false
375
+ end
376
+ when :Object
377
+ # generic object (usually a Hash), return directly
378
+ value
379
+ when /\AArray<(?<inner_type>.+)>\z/
380
+ inner_type = Regexp.last_match[:inner_type]
381
+ value.map { |v| _deserialize(inner_type, v) }
382
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
383
+ k_type = Regexp.last_match[:k_type]
384
+ v_type = Regexp.last_match[:v_type]
385
+ {}.tap do |hash|
386
+ value.each do |k, v|
387
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
388
+ end
389
+ end
390
+ else # model
391
+ # models (e.g. Pet) or oneOf
392
+ klass = UltracartClient.const_get(type)
393
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
394
+ end
395
+ end
396
+
397
+ # Returns the string representation of the object
398
+ # @return [String] String presentation of the object
399
+ def to_s
400
+ to_hash.to_s
401
+ end
402
+
403
+ # to_body is an alias to to_hash (backward compatibility)
404
+ # @return [Hash] Returns the object in the form of hash
405
+ def to_body
406
+ to_hash
407
+ end
408
+
409
+ # Returns the object in the form of hash
410
+ # @return [Hash] Returns the object in the form of hash
411
+ def to_hash
412
+ hash = {}
413
+ self.class.attribute_map.each_pair do |attr, param|
414
+ value = self.send(attr)
415
+ if value.nil?
416
+ is_nullable = self.class.openapi_nullable.include?(attr)
417
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
418
+ end
419
+
420
+ hash[param] = _to_hash(value)
421
+ end
422
+ hash
423
+ end
424
+
425
+ # Outputs non-array value in the form of hash
426
+ # For object, use to_hash. Otherwise, just return the value
427
+ # @param [Object] value Any valid value
428
+ # @return [Hash] Returns the value in the form of hash
429
+ def _to_hash(value)
430
+ if value.is_a?(Array)
431
+ value.compact.map { |v| _to_hash(v) }
432
+ elsif value.is_a?(Hash)
433
+ {}.tap do |hash|
434
+ value.each { |k, v| hash[k] = _to_hash(v) }
435
+ end
436
+ elsif value.respond_to? :to_hash
437
+ value.to_hash
438
+ else
439
+ value
440
+ end
441
+ end
442
+
443
+ end
444
+
445
+ end