Class: ModernTreasury::LedgerTransactionCreateRequest

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

Overview

LedgerTransactionCreateRequest 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(ledger_entries = nil, description = SKIP, status = SKIP, metadata = SKIP, effective_at = SKIP, effective_date = SKIP, external_id = SKIP, ledgerable_type = SKIP, ledgerable_id = SKIP) ⇒ LedgerTransactionCreateRequest

Returns a new instance of LedgerTransactionCreateRequest.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 92

def initialize(ledger_entries = nil, description = SKIP, status = SKIP,
                = SKIP, effective_at = SKIP, effective_date = SKIP,
               external_id = SKIP, ledgerable_type = SKIP,
               ledgerable_id = SKIP)
  @description = description unless description == SKIP
  @status = status unless status == SKIP
  @metadata =  unless  == SKIP
  @effective_at = effective_at unless effective_at == SKIP
  @effective_date = effective_date unless effective_date == SKIP
  @ledger_entries = ledger_entries
  @external_id = external_id unless external_id == SKIP
  @ledgerable_type = ledgerable_type unless ledgerable_type == SKIP
  @ledgerable_id = ledgerable_id unless ledgerable_id == SKIP
end

Instance Attribute Details

#descriptionString

An optional description for internal use.

Returns:

  • (String)


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

def description
  @description
end

#effective_atDate

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

Returns:

  • (Date)


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

def effective_at
  @effective_at
end

#effective_dateDate

The date (YYYY-MM-DD) on which the ledger transaction happened for reporting purposes.

Returns:

  • (Date)


33
34
35
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 33

def effective_date
  @effective_date
end

#external_idString

A unique string to represent the ledger transaction. Only one pending or posted ledger transaction may have this ID in the ledger.

Returns:

  • (String)


42
43
44
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 42

def external_id
  @external_id
end

#ledger_entriesArray[LedgerEntryCreateRequest]

An array of ledger entry objects.

Returns:



37
38
39
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 37

def ledger_entries
  @ledger_entries
end

#ledgerable_idUUID | String

If the ledger transaction can be reconciled to another object in Modern Treasury, the id will be populated here, otherwise null.

Returns:

  • (UUID | String)


54
55
56
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 54

def ledgerable_id
  @ledgerable_id
end

#ledgerable_typeLedgerableType2Enum

If the ledger transaction can be reconciled to another object in Modern Treasury, the type will be populated here, otherwise null. This can be one of payment_order, incoming_payment_detail, expected_payment, return, or reversal.

Returns:



49
50
51
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 49

def ledgerable_type
  @ledgerable_type
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


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

def 
  @metadata
end

#statusStatus11Enum

To post a ledger transaction at creation, use ‘posted`.

Returns:



18
19
20
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 18

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 108

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # 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 << (LedgerEntryCreateRequest.from_hash(structure) if structure)
    end
  end

  ledger_entries = nil unless hash.key?('ledger_entries')
  description = hash.key?('description') ? hash['description'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  effective_at = hash.key?('effective_at') ? hash['effective_at'] : SKIP
  effective_date =
    hash.key?('effective_date') ? hash['effective_date'] : SKIP
  external_id = hash.key?('external_id') ? hash['external_id'] : SKIP
  ledgerable_type =
    hash.key?('ledgerable_type') ? hash['ledgerable_type'] : SKIP
  ledgerable_id = hash.key?('ledgerable_id') ? hash['ledgerable_id'] : SKIP

  # Create object from extracted values.
  LedgerTransactionCreateRequest.new(ledger_entries,
                                     description,
                                     status,
                                     ,
                                     effective_at,
                                     effective_date,
                                     external_id,
                                     ledgerable_type,
                                     ledgerable_id)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 57

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

.nullablesObject

An array for nullable fields



86
87
88
89
90
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 86

def self.nullables
  %w[
    description
  ]
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 72

def self.optionals
  %w[
    description
    status
    metadata
    effective_at
    effective_date
    external_id
    ledgerable_type
    ledgerable_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



155
156
157
158
159
160
161
162
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 155

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

#to_sObject

Provides a human-readable string representation of the object.



146
147
148
149
150
151
152
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 146

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