Class: AdvancedBilling::CreateInvoicePayment

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

Overview

CreateInvoicePayment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(amount: SKIP, memo: SKIP, method: SKIP, details: SKIP, payment_profile_id: SKIP, additional_properties: {}) ⇒ CreateInvoicePayment

Returns a new instance of CreateInvoicePayment.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 59

def initialize(amount: SKIP, memo: SKIP, method: SKIP, details: SKIP,
               payment_profile_id: SKIP, additional_properties: {})
  @amount = amount unless amount == SKIP
  @memo = memo unless memo == SKIP
  @method = method unless method == SKIP
  @details = details unless details == SKIP
  @payment_profile_id = payment_profile_id unless payment_profile_id == SKIP

  # Add additional model properties to the instance.

  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#amountObject

A string of the dollar amount to be refunded (eg. “10.50” => $10.50)

Returns:

  • (Object)


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

def amount
  @amount
end

#detailsString

Additional information related to the payment method (eg. Check #)

Returns:

  • (String)


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

def details
  @details
end

#memoString

A description to be attached to the payment.

Returns:

  • (String)


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

def memo
  @memo
end

#methodInvoicePaymentMethodType

The type of payment method used. Defaults to other.



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

def method
  @method
end

#payment_profile_idInteger

The ID of the payment profile to be used for the payment.

Returns:

  • (Integer)


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

def payment_profile_id
  @payment_profile_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  amount = hash.key?('amount') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoicePaymentAmount), hash['amount']
  ) : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  method = hash.key?('method') ? hash['method'] : SKIP
  details = hash.key?('details') ? hash['details'] : SKIP
  payment_profile_id =
    hash.key?('payment_profile_id') ? hash['payment_profile_id'] : SKIP

  # Clean out expected properties from Hash.

  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.

  CreateInvoicePayment.new(amount: amount,
                           memo: memo,
                           method: method,
                           details: details,
                           payment_profile_id: payment_profile_id,
                           additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['memo'] = 'memo'
  @_hash['method'] = 'method'
  @_hash['details'] = 'details'
  @_hash['payment_profile_id'] = 'payment_profile_id'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 44

def self.optionals
  %w[
    amount
    memo
    method
    details
    payment_profile_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



101
102
103
104
105
106
107
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 101

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

  return false unless value.instance_of? Hash

  true
end