Class: ModernTreasury::LedgerTransactionCreateRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::LedgerTransactionCreateRequest
- Defined in:
- lib/modern_treasury/models/ledger_transaction_create_request.rb
Overview
LedgerTransactionCreateRequest Model.
Instance Attribute Summary collapse
-
#description ⇒ String
An optional description for internal use.
-
#effective_at ⇒ Date
The timestamp (ISO8601 format) at which the ledger transaction happened for reporting purposes.
-
#effective_date ⇒ Date
The date (YYYY-MM-DD) on which the ledger transaction happened for reporting purposes.
-
#external_id ⇒ String
A unique string to represent the ledger transaction.
-
#ledger_entries ⇒ Array[LedgerEntryCreateRequest]
An array of ledger entry objects.
-
#ledgerable_id ⇒ UUID | String
If the ledger transaction can be reconciled to another object in Modern Treasury, the id will be populated here, otherwise null.
-
#ledgerable_type ⇒ LedgerableType2
If the ledger transaction can be reconciled to another object in Modern Treasury, the type will be populated here, otherwise null.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#status ⇒ Status11
To post a ledger transaction at creation, use ‘posted`.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(ledger_entries:, description: SKIP, status: SKIP, metadata: SKIP, effective_at: SKIP, effective_date: SKIP, external_id: SKIP, ledgerable_type: SKIP, ledgerable_id: SKIP, additional_properties: nil) ⇒ LedgerTransactionCreateRequest
constructor
A new instance of LedgerTransactionCreateRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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:, description: SKIP, status: SKIP, metadata: SKIP, effective_at: SKIP, effective_date: SKIP, external_id: SKIP, ledgerable_type: SKIP, ledgerable_id: SKIP, additional_properties: nil) ⇒ LedgerTransactionCreateRequest
Returns a new instance of LedgerTransactionCreateRequest.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 92 def initialize(ledger_entries:, description: SKIP, status: SKIP, metadata: SKIP, effective_at: SKIP, effective_date: SKIP, external_id: SKIP, ledgerable_type: SKIP, ledgerable_id: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 @additional_properties = additional_properties end |
Instance Attribute Details
#description ⇒ String
An optional description for internal use.
14 15 16 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 14 def description @description end |
#effective_at ⇒ Date
The timestamp (ISO8601 format) at which the ledger transaction happened for reporting purposes.
28 29 30 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 28 def effective_at @effective_at end |
#effective_date ⇒ Date
The date (YYYY-MM-DD) on which the ledger transaction happened for reporting purposes.
33 34 35 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 33 def effective_date @effective_date end |
#external_id ⇒ String
A unique string to represent the ledger transaction. Only one pending or posted ledger transaction may have this ID in the ledger.
42 43 44 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 42 def external_id @external_id end |
#ledger_entries ⇒ Array[LedgerEntryCreateRequest]
An array of ledger entry objects.
37 38 39 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 37 def ledger_entries @ledger_entries end |
#ledgerable_id ⇒ UUID | String
If the ledger transaction can be reconciled to another object in Modern Treasury, the id will be populated here, otherwise null.
54 55 56 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 54 def ledgerable_id @ledgerable_id end |
#ledgerable_type ⇒ LedgerableType2
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.
49 50 51 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 49 def ledgerable_type @ledgerable_type end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
23 24 25 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 23 def @metadata end |
#status ⇒ Status11
To post a ledger transaction at creation, use ‘posted`.
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.
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 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 112 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 a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. LedgerTransactionCreateRequest.new(ledger_entries: ledger_entries, description: description, status: status, metadata: , effective_at: effective_at, effective_date: effective_date, external_id: external_id, ledgerable_type: ledgerable_type, ledgerable_id: ledgerable_id, additional_properties: additional_properties) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
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 |
.optionals ⇒ Object
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
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
167 168 169 170 171 172 173 174 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 167 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}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
158 159 160 161 162 163 164 |
# File 'lib/modern_treasury/models/ledger_transaction_create_request.rb', line 158 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}, additional_properties: #{@additional_properties}>" end |