Class: Mudbase::PaymentIntent

Inherits:
ApiModelBase show all
Defined in:
lib/mudbase/models/payment_intent.rb

Overview

Payment intent for checkout (id, amount, currency, status, etc.).

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/mudbase/models/payment_intent.rb', line 151

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#_idObject

Returns the value of attribute _id.



19
20
21
# File 'lib/mudbase/models/payment_intent.rb', line 19

def _id
  @_id
end

#amountObject

Payment amount



31
32
33
# File 'lib/mudbase/models/payment_intent.rb', line 31

def amount
  @amount
end

#commissionObject

Platform commission



49
50
51
# File 'lib/mudbase/models/payment_intent.rb', line 49

def commission
  @commission
end

#created_atObject

Returns the value of attribute created_at.



59
60
61
# File 'lib/mudbase/models/payment_intent.rb', line 59

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



33
34
35
# File 'lib/mudbase/models/payment_intent.rb', line 33

def currency
  @currency
end

#expires_atObject

Returns the value of attribute expires_at.



54
55
56
# File 'lib/mudbase/models/payment_intent.rb', line 54

def expires_at
  @expires_at
end

#finality_statusObject

Returns the value of attribute finality_status.



43
44
45
# File 'lib/mudbase/models/payment_intent.rb', line 43

def finality_status
  @finality_status
end

#merchantObject

Merchant ID



25
26
27
# File 'lib/mudbase/models/payment_intent.rb', line 25

def merchant
  @merchant
end

#merchant_receivesObject

Amount merchant receives after commission



52
53
54
# File 'lib/mudbase/models/payment_intent.rb', line 52

def merchant_receives
  @merchant_receives
end

#metadataObject

Additional metadata



57
58
59
# File 'lib/mudbase/models/payment_intent.rb', line 57

def 
  
end

#networkObject

Returns the value of attribute network.



35
36
37
# File 'lib/mudbase/models/payment_intent.rb', line 35

def network
  @network
end

#payment_idObject

Unique payment identifier



22
23
24
# File 'lib/mudbase/models/payment_intent.rb', line 22

def payment_id
  @payment_id
end

#projectObject

Project ID



28
29
30
# File 'lib/mudbase/models/payment_intent.rb', line 28

def project
  @project
end

#statusObject

Returns the value of attribute status.



41
42
43
# File 'lib/mudbase/models/payment_intent.rb', line 41

def status
  @status
end

#tokenObject

Returns the value of attribute token.



37
38
39
# File 'lib/mudbase/models/payment_intent.rb', line 37

def token
  @token
end

#total_dueObject

Total amount due including fees



46
47
48
# File 'lib/mudbase/models/payment_intent.rb', line 46

def total_due
  @total_due
end

#typeObject

Returns the value of attribute type.



39
40
41
# File 'lib/mudbase/models/payment_intent.rb', line 39

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



61
62
63
# File 'lib/mudbase/models/payment_intent.rb', line 61

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



110
111
112
# File 'lib/mudbase/models/payment_intent.rb', line 110

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



115
116
117
# File 'lib/mudbase/models/payment_intent.rb', line 115

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/mudbase/models/payment_intent.rb', line 86

def self.attribute_map
  {
    :'_id' => :'_id',
    :'payment_id' => :'paymentId',
    :'merchant' => :'merchant',
    :'project' => :'project',
    :'amount' => :'amount',
    :'currency' => :'currency',
    :'network' => :'network',
    :'token' => :'token',
    :'type' => :'type',
    :'status' => :'status',
    :'finality_status' => :'finalityStatus',
    :'total_due' => :'totalDue',
    :'commission' => :'commission',
    :'merchant_receives' => :'merchantReceives',
    :'expires_at' => :'expiresAt',
    :'metadata' => :'metadata',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt'
  }
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



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/mudbase/models/payment_intent.rb', line 355

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



144
145
146
147
# File 'lib/mudbase/models/payment_intent.rb', line 144

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

.openapi_typesObject

Attribute type mapping.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/mudbase/models/payment_intent.rb', line 120

def self.openapi_types
  {
    :'_id' => :'String',
    :'payment_id' => :'String',
    :'merchant' => :'String',
    :'project' => :'String',
    :'amount' => :'Float',
    :'currency' => :'String',
    :'network' => :'String',
    :'token' => :'String',
    :'type' => :'String',
    :'status' => :'String',
    :'finality_status' => :'String',
    :'total_due' => :'Float',
    :'commission' => :'Float',
    :'merchant_receives' => :'Float',
    :'expires_at' => :'Time',
    :'metadata' => :'Object',
    :'created_at' => :'Time',
    :'updated_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/mudbase/models/payment_intent.rb', line 317

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      _id == o._id &&
      payment_id == o.payment_id &&
      merchant == o.merchant &&
      project == o.project &&
      amount == o.amount &&
      currency == o.currency &&
      network == o.network &&
      token == o.token &&
      type == o.type &&
      status == o.status &&
      finality_status == o.finality_status &&
      total_due == o.total_due &&
      commission == o.commission &&
      merchant_receives == o.merchant_receives &&
      expires_at == o.expires_at &&
       == o. &&
      created_at == o.created_at &&
      updated_at == o.updated_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


342
343
344
# File 'lib/mudbase/models/payment_intent.rb', line 342

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



348
349
350
# File 'lib/mudbase/models/payment_intent.rb', line 348

def hash
  [_id, payment_id, merchant, project, amount, currency, network, token, type, status, finality_status, total_due, commission, merchant_receives, expires_at, , created_at, updated_at].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



242
243
244
245
246
# File 'lib/mudbase/models/payment_intent.rb', line 242

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/mudbase/models/payment_intent.rb', line 377

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



250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/mudbase/models/payment_intent.rb', line 250

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  network_validator = EnumAttributeValidator.new('String', ["polygon", "arbitrum", "tron", "solana", "lightning", "ton"])
  return false unless network_validator.valid?(@network)
  token_validator = EnumAttributeValidator.new('String', ["USDC", "USDT", "BTC"])
  return false unless token_validator.valid?(@token)
  type_validator = EnumAttributeValidator.new('String', ["one_time", "subscription"])
  return false unless type_validator.valid?(@type)
  status_validator = EnumAttributeValidator.new('String', ["created", "awaiting_payment", "partially_paid", "confirmed", "completed", "expired", "failed"])
  return false unless status_validator.valid?(@status)
  finality_status_validator = EnumAttributeValidator.new('String', ["pending_confirmation", "confirmed", "finalized"])
  return false unless finality_status_validator.valid?(@finality_status)
  true
end