Class: ApiReference::PaymentAttempt

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/payment_attempt.rb

Overview

PaymentAttempt Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, payment_provider:, payment_provider_id:, amount:, succeeded:, created_at:, receipt_pdf:, additional_properties: nil) ⇒ PaymentAttempt

Returns a new instance of PaymentAttempt.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/api_reference/models/payment_attempt.rb', line 69

def initialize(id:, payment_provider:, payment_provider_id:, amount:,
               succeeded:, created_at:, receipt_pdf:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @payment_provider = payment_provider
  @payment_provider_id = payment_provider_id
  @amount = amount
  @succeeded = succeeded
  @created_at = created_at
  @receipt_pdf = receipt_pdf
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

The amount of the payment attempt.

Returns:

  • (String)


27
28
29
# File 'lib/api_reference/models/payment_attempt.rb', line 27

def amount
  @amount
end

#created_atDateTime

The time at which the payment attempt was created.

Returns:

  • (DateTime)


35
36
37
# File 'lib/api_reference/models/payment_attempt.rb', line 35

def created_at
  @created_at
end

#idString

The ID of the payment attempt.

Returns:

  • (String)


15
16
17
# File 'lib/api_reference/models/payment_attempt.rb', line 15

def id
  @id
end

#payment_providerPaymentProvider

The payment provider that attempted to collect the payment.

Returns:



19
20
21
# File 'lib/api_reference/models/payment_attempt.rb', line 19

def payment_provider
  @payment_provider
end

#payment_provider_idString

The ID of the payment attempt in the payment provider.

Returns:

  • (String)


23
24
25
# File 'lib/api_reference/models/payment_attempt.rb', line 23

def payment_provider_id
  @payment_provider_id
end

#receipt_pdfString

URL to the downloadable PDF version of the receipt. This field will be null for payment attempts that did not succeed.

Returns:

  • (String)


40
41
42
# File 'lib/api_reference/models/payment_attempt.rb', line 40

def receipt_pdf
  @receipt_pdf
end

#succeededTrueClass | FalseClass

Whether the payment attempt succeeded.

Returns:

  • (TrueClass | FalseClass)


31
32
33
# File 'lib/api_reference/models/payment_attempt.rb', line 31

def succeeded
  @succeeded
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/api_reference/models/payment_attempt.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  payment_provider =
    hash.key?('payment_provider') ? hash['payment_provider'] : nil
  payment_provider_id =
    hash.key?('payment_provider_id') ? hash['payment_provider_id'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  succeeded = hash.key?('succeeded') ? hash['succeeded'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  receipt_pdf = hash.key?('receipt_pdf') ? hash['receipt_pdf'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PaymentAttempt.new(id: id,
                     payment_provider: payment_provider,
                     payment_provider_id: payment_provider_id,
                     amount: amount,
                     succeeded: succeeded,
                     created_at: created_at,
                     receipt_pdf: receipt_pdf,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/api_reference/models/payment_attempt.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['payment_provider'] = 'payment_provider'
  @_hash['payment_provider_id'] = 'payment_provider_id'
  @_hash['amount'] = 'amount'
  @_hash['succeeded'] = 'succeeded'
  @_hash['created_at'] = 'created_at'
  @_hash['receipt_pdf'] = 'receipt_pdf'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
64
65
66
67
# File 'lib/api_reference/models/payment_attempt.rb', line 61

def self.nullables
  %w[
    payment_provider
    payment_provider_id
    receipt_pdf
  ]
end

.optionalsObject

An array for optional fields



56
57
58
# File 'lib/api_reference/models/payment_attempt.rb', line 56

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (PaymentAttempt | Hash)

    value against the validation is performed.



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
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/api_reference/models/payment_attempt.rb', line 126

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.payment_provider,
                              ->(val) { PaymentProvider.validate(val) }) and
        APIHelper.valid_type?(value.payment_provider_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.succeeded,
                              ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { val.instance_of? DateTime }) and
        APIHelper.valid_type?(value.receipt_pdf,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['payment_provider'],
                            ->(val) { PaymentProvider.validate(val) }) and
      APIHelper.valid_type?(value['payment_provider_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['succeeded'],
                            ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['receipt_pdf'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



176
177
178
179
180
181
182
# File 'lib/api_reference/models/payment_attempt.rb', line 176

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, payment_provider: #{@payment_provider.inspect},"\
  " payment_provider_id: #{@payment_provider_id.inspect}, amount: #{@amount.inspect},"\
  " succeeded: #{@succeeded.inspect}, created_at: #{@created_at.inspect}, receipt_pdf:"\
  " #{@receipt_pdf.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



120
121
122
# File 'lib/api_reference/models/payment_attempt.rb', line 120

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



167
168
169
170
171
172
173
# File 'lib/api_reference/models/payment_attempt.rb', line 167

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, payment_provider: #{@payment_provider}, payment_provider_id:"\
  " #{@payment_provider_id}, amount: #{@amount}, succeeded: #{@succeeded}, created_at:"\
  " #{@created_at}, receipt_pdf: #{@receipt_pdf}, additional_properties:"\
  " #{@additional_properties}>"
end