Class: AdvancedBilling::ApplyDebitNoteEventData

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

Overview

Example schema for an ‘apply_debit_note` event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(debit_note_number = SKIP, debit_note_uid = SKIP, original_amount = SKIP, applied_amount = SKIP) ⇒ ApplyDebitNoteEventData

Returns a new instance of ApplyDebitNoteEventData.



55
56
57
58
59
60
61
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 55

def initialize(debit_note_number = SKIP, debit_note_uid = SKIP,
               original_amount = SKIP, applied_amount = SKIP)
  @debit_note_number = debit_note_number unless debit_note_number == SKIP
  @debit_note_uid = debit_note_uid unless debit_note_uid == SKIP
  @original_amount = original_amount unless original_amount == SKIP
  @applied_amount = applied_amount unless applied_amount == SKIP
end

Instance Attribute Details

#applied_amountString

The amount of the debit note applied to invoice.

Returns:

  • (String)


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

def applied_amount
  @applied_amount
end

#debit_note_numberString

A unique, identifying string that appears on the debit note and in places it is referenced.

Returns:

  • (String)


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

def debit_note_number
  @debit_note_number
end

#debit_note_uidString

Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix “db_” followed by alphanumeric characters.

Returns:

  • (String)


20
21
22
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 20

def debit_note_uid
  @debit_note_uid
end

#original_amountString

The full, original amount of the debit note.

Returns:

  • (String)


24
25
26
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 24

def original_amount
  @original_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  debit_note_number =
    hash.key?('debit_note_number') ? hash['debit_note_number'] : SKIP
  debit_note_uid =
    hash.key?('debit_note_uid') ? hash['debit_note_uid'] : SKIP
  original_amount =
    hash.key?('original_amount') ? hash['original_amount'] : SKIP
  applied_amount =
    hash.key?('applied_amount') ? hash['applied_amount'] : SKIP

  # Create object from extracted values.
  ApplyDebitNoteEventData.new(debit_note_number,
                              debit_note_uid,
                              original_amount,
                              applied_amount)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['debit_note_number'] = 'debit_note_number'
  @_hash['debit_note_uid'] = 'debit_note_uid'
  @_hash['original_amount'] = 'original_amount'
  @_hash['applied_amount'] = 'applied_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    debit_note_number
    debit_note_uid
    original_amount
    applied_amount
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



86
87
88
89
90
91
92
# File 'lib/advanced_billing/models/apply_debit_note_event_data.rb', line 86

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

  return false unless value.instance_of? Hash

  true
end