Class: AlogramPayRisk::Purchase

Inherits:
ApiModelBase show all
Defined in:
lib/alogram_payrisk/models/purchase.rb

Overview

Purchase details for fraud checks; core fields are common, instrument specifics live in ‘paymentMethod`.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Purchase

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/alogram_payrisk/models/purchase.rb', line 138

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `AlogramPayRisk::Purchase` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `AlogramPayRisk::Purchase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'location_id')
    self.location_id = attributes[:'location_id']
  end

  if attributes.key?(:'device_info')
    self.device_info = attributes[:'device_info']
  end

  if attributes.key?(:'timestamp')
    self.timestamp = attributes[:'timestamp']
  end

  if attributes.key?(:'transaction_id')
    self.transaction_id = attributes[:'transaction_id']
  end

  if attributes.key?(:'amount')
    self.amount = attributes[:'amount']
  else
    self.amount = nil
  end

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  else
    self.currency = nil
  end

  if attributes.key?(:'channel')
    self.channel = attributes[:'channel']
  end

  if attributes.key?(:'entry_method')
    self.entry_method = attributes[:'entry_method']
  end

  if attributes.key?(:'payment_method')
    self.payment_method = attributes[:'payment_method']
  else
    self.payment_method = nil
  end

  if attributes.key?(:'order')
    self.order = attributes[:'order']
  end

  if attributes.key?(:'discounts')
    if (value = attributes[:'discounts']).is_a?(Array)
      self.discounts = value
    end
  end

  if attributes.key?(:'payer_type')
    self.payer_type = attributes[:'payer_type']
  else
    self.payer_type = 'consumer'
  end

  if attributes.key?(:'stored_credential')
    self.stored_credential = attributes[:'stored_credential']
  end

  if attributes.key?(:'merchant')
    self.merchant = attributes[:'merchant']
  end

  if attributes.key?(:'metadata')
    self. = attributes[:'metadata']
  end
end

Instance Attribute Details

#amountObject

Value of the purchase in the specified currency. Must be a positive number with up to two decimal places.



31
32
33
# File 'lib/alogram_payrisk/models/purchase.rb', line 31

def amount
  @amount
end

#channelObject

Returns the value of attribute channel.



36
37
38
# File 'lib/alogram_payrisk/models/purchase.rb', line 36

def channel
  @channel
end

#currencyObject

ISO 4217 currency code (e.g., ‘USD’).



34
35
36
# File 'lib/alogram_payrisk/models/purchase.rb', line 34

def currency
  @currency
end

#device_infoObject

Returns the value of attribute device_info.



22
23
24
# File 'lib/alogram_payrisk/models/purchase.rb', line 22

def device_info
  @device_info
end

#discountsObject

List of discount codes applied to the purchase.



45
46
47
# File 'lib/alogram_payrisk/models/purchase.rb', line 45

def discounts
  @discounts
end

#entry_methodObject

Returns the value of attribute entry_method.



38
39
40
# File 'lib/alogram_payrisk/models/purchase.rb', line 38

def entry_method
  @entry_method
end

#location_idObject

Unique identifier for the location where the transaction occurred.



20
21
22
# File 'lib/alogram_payrisk/models/purchase.rb', line 20

def location_id
  @location_id
end

#merchantObject

Returns the value of attribute merchant.



51
52
53
# File 'lib/alogram_payrisk/models/purchase.rb', line 51

def merchant
  @merchant
end

#metadataObject

Optional key-value pairs providing additional context for the request. Each key should be descriptive, and values should not exceed 2048 characters. Each key should be descriptive.



54
55
56
# File 'lib/alogram_payrisk/models/purchase.rb', line 54

def 
  @metadata
end

#orderObject

Returns the value of attribute order.



42
43
44
# File 'lib/alogram_payrisk/models/purchase.rb', line 42

def order
  @order
end

#payer_typeObject

Returns the value of attribute payer_type.



47
48
49
# File 'lib/alogram_payrisk/models/purchase.rb', line 47

def payer_type
  @payer_type
end

#payment_methodObject

Returns the value of attribute payment_method.



40
41
42
# File 'lib/alogram_payrisk/models/purchase.rb', line 40

def payment_method
  @payment_method
end

#stored_credentialObject

Returns the value of attribute stored_credential.



49
50
51
# File 'lib/alogram_payrisk/models/purchase.rb', line 49

def stored_credential
  @stored_credential
end

#timestampObject

RFC 3339 timestamp with timezone.



25
26
27
# File 'lib/alogram_payrisk/models/purchase.rb', line 25

def timestamp
  @timestamp
end

#transaction_idObject

A unique identifier for the transaction. Must be between 3 and 50 characters and only contain alphanumeric characters, underscores, or hyphens.



28
29
30
# File 'lib/alogram_payrisk/models/purchase.rb', line 28

def transaction_id
  @transaction_id
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



100
101
102
# File 'lib/alogram_payrisk/models/purchase.rb', line 100

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



105
106
107
# File 'lib/alogram_payrisk/models/purchase.rb', line 105

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/alogram_payrisk/models/purchase.rb', line 79

def self.attribute_map
  {
    :'location_id' => :'locationId',
    :'device_info' => :'deviceInfo',
    :'timestamp' => :'timestamp',
    :'transaction_id' => :'transactionId',
    :'amount' => :'amount',
    :'currency' => :'currency',
    :'channel' => :'channel',
    :'entry_method' => :'entryMethod',
    :'payment_method' => :'paymentMethod',
    :'order' => :'order',
    :'discounts' => :'discounts',
    :'payer_type' => :'payerType',
    :'stored_credential' => :'storedCredential',
    :'merchant' => :'merchant',
    :'metadata' => :'metadata'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/alogram_payrisk/models/purchase.rb', line 476

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



131
132
133
134
# File 'lib/alogram_payrisk/models/purchase.rb', line 131

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/alogram_payrisk/models/purchase.rb', line 110

def self.openapi_types
  {
    :'location_id' => :'String',
    :'device_info' => :'DeviceInfo',
    :'timestamp' => :'String',
    :'transaction_id' => :'String',
    :'amount' => :'Float',
    :'currency' => :'String',
    :'channel' => :'ChannelEnum',
    :'entry_method' => :'EntryMethodEnum',
    :'payment_method' => :'PaymentMethod',
    :'order' => :'OrderContext',
    :'discounts' => :'Array<DiscountCode>',
    :'payer_type' => :'PayerTypeEnum',
    :'stored_credential' => :'StoredCredentialContext',
    :'merchant' => :'MerchantContext',
    :'metadata' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/alogram_payrisk/models/purchase.rb', line 441

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      location_id == o.location_id &&
      device_info == o.device_info &&
      timestamp == o.timestamp &&
      transaction_id == o.transaction_id &&
      amount == o.amount &&
      currency == o.currency &&
      channel == o.channel &&
      entry_method == o.entry_method &&
      payment_method == o.payment_method &&
      order == o.order &&
      discounts == o.discounts &&
      payer_type == o.payer_type &&
      stored_credential == o.stored_credential &&
      merchant == o.merchant &&
       == o.
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


463
464
465
# File 'lib/alogram_payrisk/models/purchase.rb', line 463

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



469
470
471
# File 'lib/alogram_payrisk/models/purchase.rb', line 469

def hash
  [location_id, device_info, timestamp, transaction_id, amount, currency, channel, entry_method, payment_method, order, discounts, payer_type, stored_credential, merchant, ].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/alogram_payrisk/models/purchase.rb', line 225

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@location_id.nil? && @location_id.to_s.length > 50
    invalid_properties.push('invalid value for "location_id", the character length must be smaller than or equal to 50.')
  end

  if !@location_id.nil? && @location_id.to_s.length < 3
    invalid_properties.push('invalid value for "location_id", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9\-_]{3,50}$/)
  if !@location_id.nil? && @location_id !~ pattern
    invalid_properties.push("invalid value for \"location_id\", must conform to the pattern #{pattern}.")
  end

  pattern = Regexp.new(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/)
  if !@timestamp.nil? && @timestamp !~ pattern
    invalid_properties.push("invalid value for \"timestamp\", must conform to the pattern #{pattern}.")
  end

  if !@transaction_id.nil? && @transaction_id.to_s.length > 50
    invalid_properties.push('invalid value for "transaction_id", the character length must be smaller than or equal to 50.')
  end

  if !@transaction_id.nil? && @transaction_id.to_s.length < 3
    invalid_properties.push('invalid value for "transaction_id", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9\-_]+$/)
  if !@transaction_id.nil? && @transaction_id !~ pattern
    invalid_properties.push("invalid value for \"transaction_id\", must conform to the pattern #{pattern}.")
  end

  if @amount.nil?
    invalid_properties.push('invalid value for "amount", amount cannot be nil.')
  end

  if @amount > 1.0E+7
    invalid_properties.push('invalid value for "amount", must be smaller than or equal to 1.0E+7.')
  end

  if @amount < 0.01
    invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.01.')
  end

  if @currency.nil?
    invalid_properties.push('invalid value for "currency", currency cannot be nil.')
  end

  if @currency.to_s.length > 3
    invalid_properties.push('invalid value for "currency", the character length must be smaller than or equal to 3.')
  end

  if @currency.to_s.length < 3
    invalid_properties.push('invalid value for "currency", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[A-Z]{3}$/)
  if @currency !~ pattern
    invalid_properties.push("invalid value for \"currency\", must conform to the pattern #{pattern}.")
  end

  if @payment_method.nil?
    invalid_properties.push('invalid value for "payment_method", payment_method cannot be nil.')
  end

  if !@metadata.nil? && @metadata.to_s.length > 2048
    invalid_properties.push('invalid value for "metadata", the character length must be smaller than or equal to 2048.')
  end

  if !@metadata.nil? && @metadata.to_s.length < 1
    invalid_properties.push('invalid value for "metadata", the character length must be greater than or equal to 1.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/alogram_payrisk/models/purchase.rb', line 498

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/alogram_payrisk/models/purchase.rb', line 305

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@location_id.nil? && @location_id.to_s.length > 50
  return false if !@location_id.nil? && @location_id.to_s.length < 3
  return false if !@location_id.nil? && @location_id !~ Regexp.new(/^[a-zA-Z0-9\-_]{3,50}$/)
  return false if !@timestamp.nil? && @timestamp !~ Regexp.new(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/)
  return false if !@transaction_id.nil? && @transaction_id.to_s.length > 50
  return false if !@transaction_id.nil? && @transaction_id.to_s.length < 3
  return false if !@transaction_id.nil? && @transaction_id !~ Regexp.new(/^[a-zA-Z0-9\-_]+$/)
  return false if @amount.nil?
  return false if @amount > 1.0E+7
  return false if @amount < 0.01
  return false if @currency.nil?
  return false if @currency.to_s.length > 3
  return false if @currency.to_s.length < 3
  return false if @currency !~ Regexp.new(/^[A-Z]{3}$/)
  return false if @payment_method.nil?
  return false if !@metadata.nil? && @metadata.to_s.length > 2048
  return false if !@metadata.nil? && @metadata.to_s.length < 1
  true
end