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 = InvoicePaymentMethodType::OTHER, details = SKIP) ⇒ CreateInvoicePayment

Returns a new instance of CreateInvoicePayment.



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

def initialize(amount = SKIP, memo = SKIP,
               method = InvoicePaymentMethodType::OTHER, details = SKIP)
  @amount = amount unless amount == SKIP
  @memo = memo unless memo == SKIP
  @method = method unless method == SKIP
  @details = details unless details == SKIP
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.



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

def method
  @method
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 62

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['method'] ||= InvoicePaymentMethodType::OTHER
  details = hash.key?('details') ? hash['details'] : SKIP

  # Create object from extracted values.

  CreateInvoicePayment.new(amount,
                           memo,
                           method,
                           details)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 29

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

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



82
83
84
85
86
87
88
# File 'lib/advanced_billing/models/create_invoice_payment.rb', line 82

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

  return false unless value.instance_of? Hash

  true
end