Class: AdvancedBilling::InvoiceRefund

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

Overview

InvoiceRefund 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_id = SKIP, payment_id = SKIP, memo = SKIP, original_amount = SKIP, applied_amount = SKIP, gateway_transaction_id = SKIP) ⇒ InvoiceRefund

Returns a new instance of InvoiceRefund.



67
68
69
70
71
72
73
74
75
76
# File 'lib/advanced_billing/models/invoice_refund.rb', line 67

def initialize(transaction_id = SKIP, payment_id = SKIP, memo = SKIP,
               original_amount = SKIP, applied_amount = SKIP,
               gateway_transaction_id = SKIP)
  @transaction_id = transaction_id unless transaction_id == SKIP
  @payment_id = payment_id unless payment_id == SKIP
  @memo = memo unless memo == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @applied_amount = applied_amount unless applied_amount == 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)


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

def applied_amount
  @applied_amount
end

#gateway_transaction_idString

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

Returns:

  • (String)


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

def gateway_transaction_id
  @gateway_transaction_id
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


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

def memo
  @memo
end

#original_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def original_amount
  @original_amount
end

#payment_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def payment_id
  @payment_id
end

#transaction_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def transaction_id
  @transaction_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/advanced_billing/models/invoice_refund.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_id =
    hash.key?('transaction_id') ? hash['transaction_id'] : SKIP
  payment_id = hash.key?('payment_id') ? hash['payment_id'] : 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
  gateway_transaction_id =
    hash.key?('gateway_transaction_id') ? hash['gateway_transaction_id'] : SKIP

  # Create object from extracted values.
  InvoiceRefund.new(transaction_id,
                    payment_id,
                    memo,
                    original_amount,
                    applied_amount,
                    gateway_transaction_id)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/models/invoice_refund.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_id'] = 'transaction_id'
  @_hash['payment_id'] = 'payment_id'
  @_hash['memo'] = 'memo'
  @_hash['original_amount'] = 'original_amount'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash['gateway_transaction_id'] = 'gateway_transaction_id'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
64
65
# File 'lib/advanced_billing/models/invoice_refund.rb', line 61

def self.nullables
  %w[
    gateway_transaction_id
  ]
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/advanced_billing/models/invoice_refund.rb', line 49

def self.optionals
  %w[
    transaction_id
    payment_id
    memo
    original_amount
    applied_amount
    gateway_transaction_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceRefund | Hash)

    value against the validation is performed.



105
106
107
108
109
110
111
# File 'lib/advanced_billing/models/invoice_refund.rb', line 105

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

  return false unless value.instance_of? Hash

  true
end