Class: ModernTreasury::VirtualAccount

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

Overview

VirtualAccount 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(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, name:, description:, counterparty_id:, internal_account_id:, account_details:, routing_details:, debit_ledger_account_id:, credit_ledger_account_id:, metadata:) ⇒ VirtualAccount

Returns a new instance of VirtualAccount.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/modern_treasury/models/virtual_account.rb', line 120

def initialize(id:, object:, live_mode:, created_at:, updated_at:,
               discarded_at:, name:, description:, counterparty_id:,
               internal_account_id:, account_details:, routing_details:,
               debit_ledger_account_id:, credit_ledger_account_id:,
               metadata:)
  @id = id
  @object = object
  @live_mode = live_mode
  @created_at = created_at
  @updated_at = updated_at
  @discarded_at = discarded_at
  @name = name
  @description = description
  @counterparty_id = counterparty_id
  @internal_account_id = 
  @account_details = 
  @routing_details = routing_details
  @debit_ledger_account_id = 
  @credit_ledger_account_id = 
  @metadata = 
end

Instance Attribute Details

#account_detailsArray[AccountDetail]

An array of account detail objects.

Returns:



59
60
61
# File 'lib/modern_treasury/models/virtual_account.rb', line 59

def 
  @account_details
end

#counterparty_idUUID | String

The ID of a counterparty that the virtual account belongs to. Optional.

Returns:

  • (UUID | String)


51
52
53
# File 'lib/modern_treasury/models/virtual_account.rb', line 51

def counterparty_id
  @counterparty_id
end

#created_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


29
30
31
# File 'lib/modern_treasury/models/virtual_account.rb', line 29

def created_at
  @created_at
end

#credit_ledger_account_idUUID | String

The ID of a credit normal ledger account. When money enters the virtual account, this ledger account will be credited. Must be accompanied by a debit_ledger_account_id if present.

Returns:

  • (UUID | String)


76
77
78
# File 'lib/modern_treasury/models/virtual_account.rb', line 76

def 
  @credit_ledger_account_id
end

#debit_ledger_account_idUUID | String

The ID of a debit normal ledger account. When money enters the virtual account, this ledger account will be debited. Must be accompanied by a credit_ledger_account_id if present.

Returns:

  • (UUID | String)


70
71
72
# File 'lib/modern_treasury/models/virtual_account.rb', line 70

def 
  @debit_ledger_account_id
end

#descriptionString

An optional free-form description for internal use.

Returns:

  • (String)


47
48
49
# File 'lib/modern_treasury/models/virtual_account.rb', line 47

def description
  @description
end

#discarded_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


39
40
41
# File 'lib/modern_treasury/models/virtual_account.rb', line 39

def discarded_at
  @discarded_at
end

#idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


15
16
17
# File 'lib/modern_treasury/models/virtual_account.rb', line 15

def id
  @id
end

#internal_account_idUUID | String

The ID of the internal account that the virtual account is in.

Returns:

  • (UUID | String)


55
56
57
# File 'lib/modern_treasury/models/virtual_account.rb', line 55

def 
  @internal_account_id
end

#live_modeTrueClass | FalseClass

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/modern_treasury/models/virtual_account.rb', line 24

def live_mode
  @live_mode
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


81
82
83
# File 'lib/modern_treasury/models/virtual_account.rb', line 81

def 
  @metadata
end

#nameString

The name of the virtual account.

Returns:

  • (String)


43
44
45
# File 'lib/modern_treasury/models/virtual_account.rb', line 43

def name
  @name
end

#objectString

TODO: Write general description for this method

Returns:

  • (String)


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

def object
  @object
end

#routing_detailsArray[RoutingDetail]

An array of routing detail objects. These will be the routing details of the internal account.

Returns:



64
65
66
# File 'lib/modern_treasury/models/virtual_account.rb', line 64

def routing_details
  @routing_details
end

#updated_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


34
35
36
# File 'lib/modern_treasury/models/virtual_account.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.



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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/modern_treasury/models/virtual_account.rb', line 143

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
  discarded_at = if hash.key?('discarded_at')
                   (DateTimeHelper.from_rfc3339(hash['discarded_at']) if hash['discarded_at'])
                 end
  name = hash.key?('name') ? hash['name'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  counterparty_id =
    hash.key?('counterparty_id') ? hash['counterparty_id'] : nil
   =
    hash.key?('internal_account_id') ? hash['internal_account_id'] : nil
  # Parameter is an array, so we need to iterate through it
   = nil
  unless hash['account_details'].nil?
     = []
    hash['account_details'].each do |structure|
       << (AccountDetail.from_hash(structure) if structure)
    end
  end

   = nil unless hash.key?('account_details')
  # Parameter is an array, so we need to iterate through it
  routing_details = nil
  unless hash['routing_details'].nil?
    routing_details = []
    hash['routing_details'].each do |structure|
      routing_details << (RoutingDetail.from_hash(structure) if structure)
    end
  end

  routing_details = nil unless hash.key?('routing_details')
   =
    hash.key?('debit_ledger_account_id') ? hash['debit_ledger_account_id'] : nil
   =
    hash.key?('credit_ledger_account_id') ? hash['credit_ledger_account_id'] : nil
   = hash.key?('metadata') ? hash['metadata'] : nil

  # Create object from extracted values.
  VirtualAccount.new(id: id,
                     object: object,
                     live_mode: live_mode,
                     created_at: created_at,
                     updated_at: updated_at,
                     discarded_at: discarded_at,
                     name: name,
                     description: description,
                     counterparty_id: counterparty_id,
                     internal_account_id: ,
                     account_details: ,
                     routing_details: routing_details,
                     debit_ledger_account_id: ,
                     credit_ledger_account_id: ,
                     metadata: )
end

.namesObject

A mapping from model property names to API property names.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/modern_treasury/models/virtual_account.rb', line 84

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['discarded_at'] = 'discarded_at'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['counterparty_id'] = 'counterparty_id'
  @_hash['internal_account_id'] = 'internal_account_id'
  @_hash['account_details'] = 'account_details'
  @_hash['routing_details'] = 'routing_details'
  @_hash['debit_ledger_account_id'] = 'debit_ledger_account_id'
  @_hash['credit_ledger_account_id'] = 'credit_ledger_account_id'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



110
111
112
113
114
115
116
117
118
# File 'lib/modern_treasury/models/virtual_account.rb', line 110

def self.nullables
  %w[
    discarded_at
    description
    counterparty_id
    debit_ledger_account_id
    credit_ledger_account_id
  ]
end

.optionalsObject

An array for optional fields



105
106
107
# File 'lib/modern_treasury/models/virtual_account.rb', line 105

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



234
235
236
237
238
239
240
241
242
243
244
# File 'lib/modern_treasury/models/virtual_account.rb', line 234

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}, discarded_at: #{@discarded_at.inspect}, name: #{@name.inspect},"\
  " description: #{@description.inspect}, counterparty_id: #{@counterparty_id.inspect},"\
  " internal_account_id: #{@internal_account_id.inspect}, account_details:"\
  " #{@account_details.inspect}, routing_details: #{@routing_details.inspect},"\
  " debit_ledger_account_id: #{@debit_ledger_account_id.inspect}, credit_ledger_account_id:"\
  " #{@credit_ledger_account_id.inspect}, metadata: #{@metadata.inspect}>"
end

#to_custom_created_atObject



209
210
211
# File 'lib/modern_treasury/models/virtual_account.rb', line 209

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_discarded_atObject



217
218
219
# File 'lib/modern_treasury/models/virtual_account.rb', line 217

def to_custom_discarded_at
  DateTimeHelper.to_rfc3339(discarded_at)
end

#to_custom_updated_atObject



213
214
215
# File 'lib/modern_treasury/models/virtual_account.rb', line 213

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



222
223
224
225
226
227
228
229
230
231
# File 'lib/modern_treasury/models/virtual_account.rb', line 222

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}, discarded_at: #{@discarded_at}, name:"\
  " #{@name}, description: #{@description}, counterparty_id: #{@counterparty_id},"\
  " internal_account_id: #{@internal_account_id}, account_details: #{@account_details},"\
  " routing_details: #{@routing_details}, debit_ledger_account_id:"\
  " #{@debit_ledger_account_id}, credit_ledger_account_id: #{@credit_ledger_account_id},"\
  " metadata: #{@metadata}>"
end