Class: AlogramPayRisk::PaymentEvent

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

Overview

Payment lifecycle event.

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 = {}) ⇒ PaymentEvent

Initializes the object

Parameters:

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

    Model attributes in the form of hash



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/alogram_payrisk/models/payment_event.rb', line 104

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `AlogramPayRisk::PaymentEvent` 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::PaymentEvent`. 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?(:'payment_intent_id')
    self.payment_intent_id = attributes[:'payment_intent_id']
  else
    self.payment_intent_id = nil
  end

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

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

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

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

  if attributes.key?(:'outcome')
    self.outcome = attributes[:'outcome']
  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.



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

def amount
  @amount
end

#currencyObject

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



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

def currency
  @currency
end

#event_typeObject

Returns the value of attribute event_type.



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

def event_type
  @event_type
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.



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

def 
  @metadata
end

#outcomeObject

Returns the value of attribute outcome.



33
34
35
# File 'lib/alogram_payrisk/models/payment_event.rb', line 33

def outcome
  @outcome
end

#payment_intent_idObject

Server-minted unique payment identifier.



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

def payment_intent_id
  @payment_intent_id
end

#timestampObject

RFC 3339 timestamp with timezone.



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

def timestamp
  @timestamp
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



74
75
76
# File 'lib/alogram_payrisk/models/payment_event.rb', line 74

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



79
80
81
# File 'lib/alogram_payrisk/models/payment_event.rb', line 79

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/alogram_payrisk/models/payment_event.rb', line 61

def self.attribute_map
  {
    :'payment_intent_id' => :'paymentIntentId',
    :'event_type' => :'eventType',
    :'timestamp' => :'timestamp',
    :'amount' => :'amount',
    :'currency' => :'currency',
    :'outcome' => :'outcome',
    :'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



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/alogram_payrisk/models/payment_event.rb', line 363

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



97
98
99
100
# File 'lib/alogram_payrisk/models/payment_event.rb', line 97

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

.openapi_typesObject

Attribute type mapping.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/alogram_payrisk/models/payment_event.rb', line 84

def self.openapi_types
  {
    :'payment_intent_id' => :'String',
    :'event_type' => :'PaymentEventType',
    :'timestamp' => :'String',
    :'amount' => :'Float',
    :'currency' => :'String',
    :'outcome' => :'PaymentOutcome',
    :'metadata' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



336
337
338
339
340
341
342
343
344
345
346
# File 'lib/alogram_payrisk/models/payment_event.rb', line 336

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      payment_intent_id == o.payment_intent_id &&
      event_type == o.event_type &&
      timestamp == o.timestamp &&
      amount == o.amount &&
      currency == o.currency &&
      outcome == o.outcome &&
       == o.
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


350
351
352
# File 'lib/alogram_payrisk/models/payment_event.rb', line 350

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



356
357
358
# File 'lib/alogram_payrisk/models/payment_event.rb', line 356

def hash
  [payment_intent_id, event_type, timestamp, amount, currency, outcome, ].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/alogram_payrisk/models/payment_event.rb', line 155

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @payment_intent_id.nil?
    invalid_properties.push('invalid value for "payment_intent_id", payment_intent_id cannot be nil.')
  end

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

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

  pattern = Regexp.new(/^pi_[a-f0-9]{32}$/)
  if @payment_intent_id !~ pattern
    invalid_properties.push("invalid value for \"payment_intent_id\", must conform to the pattern #{pattern}.")
  end

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

  if @timestamp.nil?
    invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
  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 !~ pattern
    invalid_properties.push("invalid value for \"timestamp\", must conform to the pattern #{pattern}.")
  end

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

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

  if !@currency.nil? && @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.nil? && @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.nil? && @currency !~ pattern
    invalid_properties.push("invalid value for \"currency\", must conform to the pattern #{pattern}.")
  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



385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/alogram_payrisk/models/payment_event.rb', line 385

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



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/alogram_payrisk/models/payment_event.rb', line 222

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @payment_intent_id.nil?
  return false if @payment_intent_id.to_s.length > 35
  return false if @payment_intent_id.to_s.length < 35
  return false if @payment_intent_id !~ Regexp.new(/^pi_[a-f0-9]{32}$/)
  return false if @event_type.nil?
  return false if @timestamp.nil?
  return false if @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 !@amount.nil? && @amount > 1.0E+7
  return false if !@amount.nil? && @amount < 0.01
  return false if !@currency.nil? && @currency.to_s.length > 3
  return false if !@currency.nil? && @currency.to_s.length < 3
  return false if !@currency.nil? && @currency !~ Regexp.new(/^[A-Z]{3}$/)
  return false if !@metadata.nil? && @metadata.to_s.length > 2048
  return false if !@metadata.nil? && @metadata.to_s.length < 1
  true
end