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, received_on: SKIP, additional_properties: {}) ⇒ CreateInvoicePayment

Returns a new instance of CreateInvoicePayment.



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

def initialize(amount: SKIP, memo: SKIP, method: SKIP, details: SKIP,
               payment_profile_id: SKIP, received_on: 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
  @received_on = received_on unless received_on == 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 #). Applicable only to ‘external` payments.

Returns:

  • (String)


28
29
30
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 28

def details
  @details
end

#memoString

A description to be attached to the payment. Applicable only to ‘external` payments.

Returns:

  • (String)


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

def memo
  @memo
end

#methodInvoicePaymentMethodType

The type of payment method used. Defaults to other.



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

def method
  @method
end

#payment_profile_idInteger

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

Returns:

  • (Integer)


32
33
34
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 32

def payment_profile_id
  @payment_profile_id
end

#received_onDate

Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to ‘external` payments.

Returns:

  • (Date)


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

def received_on
  @received_on
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
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 86

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
  received_on = hash.key?('received_on') ? hash['received_on'] : 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,
                           received_on: received_on,
                           additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 41

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['received_on'] = 'received_on'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



53
54
55
56
57
58
59
60
61
62
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 53

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



115
116
117
118
119
120
121
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 115

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

  return false unless value.instance_of? Hash

  true
end