Class: ModernTreasury::LedgerableEvent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::LedgerableEvent
- Defined in:
- lib/modern_treasury/models/ledgerable_event.rb
Overview
LedgerableEvent Model.
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#currency ⇒ String
An ISO 4217 conformed currency or a custom currency.
-
#currency_exponent ⇒ Integer
Must be included if currency is a custom currency.
-
#custom_data ⇒ Object
Additionally data to be used by the Ledger Event Handler.
-
#description ⇒ String
Description of the ledgerable event.
-
#direction ⇒ String
One of ‘credit`, `debit`.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#ledger_event_handler_id ⇒ UUID | String
Id of the ledger event handler that is used to create a ledger transaction.
-
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#name ⇒ String
Name of the ledgerable event.
-
#object ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
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(id:, object:, live_mode:, created_at:, updated_at:, name:, description:, direction:, amount:, currency:, currency_exponent:, custom_data:, ledger_event_handler_id:, metadata:) ⇒ LedgerableEvent
constructor
A new instance of LedgerableEvent.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#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(id:, object:, live_mode:, created_at:, updated_at:, name:, description:, direction:, amount:, currency:, currency_exponent:, custom_data:, ledger_event_handler_id:, metadata:) ⇒ LedgerableEvent
Returns a new instance of LedgerableEvent.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 112 def initialize(id:, object:, live_mode:, created_at:, updated_at:, name:, description:, direction:, amount:, currency:, currency_exponent:, custom_data:, ledger_event_handler_id:, metadata:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @name = name @description = description @direction = direction @amount = amount @currency = currency @currency_exponent = currency_exponent @custom_data = custom_data @ledger_event_handler_id = ledger_event_handler_id @metadata = end |
Instance Attribute Details
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000.
51 52 53 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 51 def amount @amount end |
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
29 30 31 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 29 def created_at @created_at end |
#currency ⇒ String
An ISO 4217 conformed currency or a custom currency.
55 56 57 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 55 def currency @currency end |
#currency_exponent ⇒ Integer
Must be included if currency is a custom currency. The currency_exponent cannot exceed 30.
60 61 62 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 60 def currency_exponent @currency_exponent end |
#custom_data ⇒ Object
Additionally data to be used by the Ledger Event Handler.
64 65 66 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 64 def custom_data @custom_data end |
#description ⇒ String
Description of the ledgerable event.
42 43 44 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 42 def description @description end |
#direction ⇒ String
One of ‘credit`, `debit`.
46 47 48 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 46 def direction @direction end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 15 def id @id end |
#ledger_event_handler_id ⇒ UUID | String
Id of the ledger event handler that is used to create a ledger transaction.
69 70 71 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 69 def ledger_event_handler_id @ledger_event_handler_id end |
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
24 25 26 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 24 def live_mode @live_mode end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
74 75 76 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 74 def @metadata end |
#name ⇒ String
Name of the ledgerable event.
38 39 40 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 38 def name @name end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 19 def object @object end |
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
34 35 36 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 34 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 133 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil object = hash.key?('object') ? hash['object'] : nil live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) end name = hash.key?('name') ? hash['name'] : nil description = hash.key?('description') ? hash['description'] : nil direction = hash.key?('direction') ? hash['direction'] : nil amount = hash.key?('amount') ? hash['amount'] : nil currency = hash.key?('currency') ? hash['currency'] : nil currency_exponent = hash.key?('currency_exponent') ? hash['currency_exponent'] : nil custom_data = hash.key?('custom_data') ? hash['custom_data'] : nil ledger_event_handler_id = hash.key?('ledger_event_handler_id') ? hash['ledger_event_handler_id'] : nil = hash.key?('metadata') ? hash['metadata'] : nil # Create object from extracted values. LedgerableEvent.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, name: name, description: description, direction: direction, amount: amount, currency: currency, currency_exponent: currency_exponent, custom_data: custom_data, ledger_event_handler_id: ledger_event_handler_id, metadata: ) end |
.names ⇒ Object
A mapping from model property names to API property names.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 77 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['object'] = 'object' @_hash['live_mode'] = 'live_mode' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['name'] = 'name' @_hash['description'] = 'description' @_hash['direction'] = 'direction' @_hash['amount'] = 'amount' @_hash['currency'] = 'currency' @_hash['currency_exponent'] = 'currency_exponent' @_hash['custom_data'] = 'custom_data' @_hash['ledger_event_handler_id'] = 'ledger_event_handler_id' @_hash['metadata'] = 'metadata' @_hash end |
.nullables ⇒ Object
An array for nullable fields
102 103 104 105 106 107 108 109 110 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 102 def self.nullables %w[ description direction currency_exponent custom_data metadata ] end |
.optionals ⇒ Object
An array for optional fields
97 98 99 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 97 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 194 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\ " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\ " #{@updated_at.inspect}, name: #{@name.inspect}, description: #{@description.inspect},"\ " direction: #{@direction.inspect}, amount: #{@amount.inspect}, currency:"\ " #{@currency.inspect}, currency_exponent: #{@currency_exponent.inspect}, custom_data:"\ " #{@custom_data.inspect}, ledger_event_handler_id: #{@ledger_event_handler_id.inspect},"\ " metadata: #{@metadata.inspect}>" end |
#to_custom_created_at ⇒ Object
175 176 177 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 175 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
179 180 181 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 179 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
184 185 186 187 188 189 190 191 |
# File 'lib/modern_treasury/models/ledgerable_event.rb', line 184 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\ " #{@created_at}, updated_at: #{@updated_at}, name: #{@name}, description: #{@description},"\ " direction: #{@direction}, amount: #{@amount}, currency: #{@currency}, currency_exponent:"\ " #{@currency_exponent}, custom_data: #{@custom_data}, ledger_event_handler_id:"\ " #{@ledger_event_handler_id}, metadata: #{@metadata}>" end |