Class: ModernTreasury::LedgerEventHandlerLedgerTransactionTemplate

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb

Overview

LedgerEventHandlerLedgerTransactionTemplate Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(description:, effective_at:, ledger_entries:, metadata:) ⇒ LedgerEventHandlerLedgerTransactionTemplate

Returns a new instance of LedgerEventHandlerLedgerTransactionTemplate.



54
55
56
57
58
59
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 54

def initialize(description:, effective_at:, ledger_entries:, metadata:)
  @description = description
  @effective_at = effective_at
  @ledger_entries = ledger_entries
  @metadata = 
end

Instance Attribute Details

#descriptionString

An optional description for internal use.

Returns:

  • (String)


14
15
16
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 14

def description
  @description
end

#effective_atString

The timestamp (ISO8601 format) at which the ledger transaction happened for reporting purposes.

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 19

def effective_at
  @effective_at
end

#ledger_entriesArray[LedgerEventHandlerLedgerEntries]

An array of ledger entry objects.



23
24
25
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 23

def ledger_entries
  @ledger_entries
end

#metadataHash[String, String]

Additional data represented as key-value pairs. Both the key and value must be strings.

Returns:

  • (Hash[String, String])


28
29
30
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 28

def 
  @metadata
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
79
80
81
82
83
84
85
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  description = hash.key?('description') ? hash['description'] : nil
  effective_at = hash.key?('effective_at') ? hash['effective_at'] : nil
  # Parameter is an array, so we need to iterate through it
  ledger_entries = nil
  unless hash['ledger_entries'].nil?
    ledger_entries = []
    hash['ledger_entries'].each do |structure|
      ledger_entries << (LedgerEventHandlerLedgerEntries.from_hash(structure) if structure)
    end
  end

  ledger_entries = nil unless hash.key?('ledger_entries')
   = hash.key?('metadata') ? hash['metadata'] : nil

  # Create object from extracted values.
  LedgerEventHandlerLedgerTransactionTemplate.new(description: description,
                                                  effective_at: effective_at,
                                                  ledger_entries: ledger_entries,
                                                  metadata: )
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['description'] = 'description'
  @_hash['effective_at'] = 'effective_at'
  @_hash['ledger_entries'] = 'ledger_entries'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
50
51
52
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 46

def self.nullables
  %w[
    description
    effective_at
    metadata
  ]
end

.optionalsObject

An array for optional fields



41
42
43
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 41

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



95
96
97
98
99
100
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 95

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description.inspect}, effective_at:"\
  " #{@effective_at.inspect}, ledger_entries: #{@ledger_entries.inspect}, metadata:"\
  " #{@metadata.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



88
89
90
91
92
# File 'lib/modern_treasury/models/ledger_event_handler_ledger_transaction_template.rb', line 88

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description}, effective_at: #{@effective_at},"\
  " ledger_entries: #{@ledger_entries}, metadata: #{@metadata}>"
end