Class: AdvancedBilling::VoidInvoiceEventData

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

Overview

Example schema for an ‘void_invoice` event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(credit_note_attributes = SKIP, memo = SKIP, applied_amount = SKIP, transaction_time = SKIP, is_advance_invoice = SKIP) ⇒ VoidInvoiceEventData

Returns a new instance of VoidInvoiceEventData.



61
62
63
64
65
66
67
68
69
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 61

def initialize(credit_note_attributes = SKIP, memo = SKIP,
               applied_amount = SKIP, transaction_time = SKIP,
               is_advance_invoice = SKIP)
  @credit_note_attributes = credit_note_attributes unless credit_note_attributes == SKIP
  @memo = memo unless memo == SKIP
  @applied_amount = applied_amount unless applied_amount == SKIP
  @transaction_time = transaction_time unless transaction_time == SKIP
  @is_advance_invoice = is_advance_invoice unless is_advance_invoice == SKIP
end

Instance Attribute Details

#applied_amountString

The amount of the void.

Returns:

  • (String)


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

def applied_amount
  @applied_amount
end

#credit_note_attributesCreditNote

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 15

def credit_note_attributes
  @credit_note_attributes
end

#is_advance_invoiceTrueClass | FalseClass

If true, the invoice is an advance invoice.

Returns:

  • (TrueClass | FalseClass)


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

def is_advance_invoice
  @is_advance_invoice
end

#memoString

The memo provided during invoice voiding.

Returns:

  • (String)


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

def memo
  @memo
end

#transaction_timeDateTime

The time the refund was applied, in ISO 8601 format, i.e. “2019-06-07T17:20:06Z”

Returns:

  • (DateTime)


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

def transaction_time
  @transaction_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  credit_note_attributes = CreditNote.from_hash(hash['credit_note_attributes']) if
    hash['credit_note_attributes']
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : SKIP
  transaction_time = if hash.key?('transaction_time')
                       (DateTimeHelper.from_rfc3339(hash['transaction_time']) if hash['transaction_time'])
                     else
                       SKIP
                     end
  is_advance_invoice =
    hash.key?('is_advance_invoice') ? hash['is_advance_invoice'] : SKIP

  # Create object from extracted values.

  VoidInvoiceEventData.new(credit_note_attributes,
                           memo,
                           applied_amount,
                           transaction_time,
                           is_advance_invoice)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['credit_note_attributes'] = 'credit_note_attributes'
  @_hash['memo'] = 'memo'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash['transaction_time'] = 'transaction_time'
  @_hash['is_advance_invoice'] = 'is_advance_invoice'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
53
54
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 46

def self.optionals
  %w[
    credit_note_attributes
    memo
    applied_amount
    transaction_time
    is_advance_invoice
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



103
104
105
106
107
108
109
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 103

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

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#to_custom_transaction_timeObject



97
98
99
# File 'lib/advanced_billing/models/void_invoice_event_data.rb', line 97

def to_custom_transaction_time
  DateTimeHelper.to_rfc3339(transaction_time)
end