Class: AdvancedBilling::InvoicePayment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/invoice_payment.rb

Overview

InvoicePayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(transaction_time = SKIP, memo = SKIP, original_amount = SKIP, applied_amount = SKIP, payment_method = SKIP, transaction_id = SKIP, prepayment = SKIP, gateway_handle = SKIP, gateway_used = SKIP, gateway_transaction_id = SKIP) ⇒ InvoicePayment

Returns a new instance of InvoicePayment.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/advanced_billing/models/invoice_payment.rb', line 92

def initialize(transaction_time = SKIP, memo = SKIP, original_amount = SKIP,
               applied_amount = SKIP, payment_method = SKIP,
               transaction_id = SKIP, prepayment = SKIP,
               gateway_handle = SKIP, gateway_used = SKIP,
               gateway_transaction_id = SKIP)
  @transaction_time = transaction_time unless transaction_time == SKIP
  @memo = memo unless memo == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @applied_amount = applied_amount unless applied_amount == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @transaction_id = transaction_id unless transaction_id == SKIP
  @prepayment = prepayment unless prepayment == SKIP
  @gateway_handle = gateway_handle unless gateway_handle == SKIP
  @gateway_used = gateway_used unless gateway_used == SKIP
  @gateway_transaction_id = gateway_transaction_id unless gateway_transaction_id == SKIP
end

Instance Attribute Details

#applied_amountString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/invoice_payment.rb', line 26

def applied_amount
  @applied_amount
end

#gateway_handleString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/invoice_payment.rb', line 42

def gateway_handle
  @gateway_handle
end

#gateway_transaction_idString

The transaction ID for the payment as returned from the payment gateway

Returns:

  • (String)


50
51
52
# File 'lib/advanced_billing/models/invoice_payment.rb', line 50

def gateway_transaction_id
  @gateway_transaction_id
end

#gateway_usedString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/advanced_billing/models/invoice_payment.rb', line 46

def gateway_used
  @gateway_used
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/invoice_payment.rb', line 18

def memo
  @memo
end

#original_amountString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/invoice_payment.rb', line 22

def original_amount
  @original_amount
end

#payment_methodInvoicePaymentMethod

TODO: Write general description for this method



30
31
32
# File 'lib/advanced_billing/models/invoice_payment.rb', line 30

def payment_method
  @payment_method
end

#prepaymentTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


38
39
40
# File 'lib/advanced_billing/models/invoice_payment.rb', line 38

def prepayment
  @prepayment
end

#transaction_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/advanced_billing/models/invoice_payment.rb', line 34

def transaction_id
  @transaction_id
end

#transaction_timeString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/invoice_payment.rb', line 14

def transaction_time
  @transaction_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/advanced_billing/models/invoice_payment.rb', line 110

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_time =
    hash.key?('transaction_time') ? hash['transaction_time'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  original_amount =
    hash.key?('original_amount') ? hash['original_amount'] : SKIP
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : SKIP
  payment_method = InvoicePaymentMethod.from_hash(hash['payment_method']) if
    hash['payment_method']
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : SKIP
  prepayment = hash.key?('prepayment') ? hash['prepayment'] : SKIP
  gateway_handle =
    hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP
  gateway_used = hash.key?('gateway_used') ? hash['gateway_used'] : SKIP
  gateway_transaction_id =
    hash.key?('gateway_transaction_id') ? hash['gateway_transaction_id'] : SKIP

  # Create object from extracted values.
  InvoicePayment.new(transaction_time,
                     memo,
                     original_amount,
                     applied_amount,
                     payment_method,
                     transaction_id,
                     prepayment,
                     gateway_handle,
                     gateway_used,
                     gateway_transaction_id)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/invoice_payment.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_time'] = 'transaction_time'
  @_hash['memo'] = 'memo'
  @_hash['original_amount'] = 'original_amount'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash['payment_method'] = 'payment_method'
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['prepayment'] = 'prepayment'
  @_hash['gateway_handle'] = 'gateway_handle'
  @_hash['gateway_used'] = 'gateway_used'
  @_hash['gateway_transaction_id'] = 'gateway_transaction_id'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
88
89
90
# File 'lib/advanced_billing/models/invoice_payment.rb', line 85

def self.nullables
  %w[
    gateway_handle
    gateway_transaction_id
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    transaction_time
    memo
    original_amount
    applied_amount
    payment_method
    transaction_id
    prepayment
    gateway_handle
    gateway_used
    gateway_transaction_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoicePayment | Hash)

    value against the validation is performed.



147
148
149
150
151
152
153
# File 'lib/advanced_billing/models/invoice_payment.rb', line 147

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end