Class: ModernTreasury::VirtualAccountCreateRequest

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

Overview

VirtualAccountCreateRequest 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(name:, internal_account_id:, description: SKIP, counterparty_id: SKIP, account_details: SKIP, routing_details: SKIP, debit_ledger_account_id: SKIP, credit_ledger_account_id: SKIP, metadata: SKIP, additional_properties: nil) ⇒ VirtualAccountCreateRequest

Returns a new instance of VirtualAccountCreateRequest.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 87

def initialize(name:, internal_account_id:, description: SKIP,
               counterparty_id: SKIP, account_details: SKIP,
               routing_details: SKIP, debit_ledger_account_id: SKIP,
               credit_ledger_account_id: SKIP, metadata: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @description = description unless description == SKIP
  @counterparty_id = counterparty_id unless counterparty_id == SKIP
  @internal_account_id = 
  @account_details =  unless  == SKIP
  @routing_details = routing_details unless routing_details == SKIP
  @debit_ledger_account_id =  unless  == SKIP
  @credit_ledger_account_id =  unless  == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_detailsArray[AccountDetailCreateRequest]

An array of account detail objects.

Returns:



31
32
33
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 31

def 
  @account_details
end

#counterparty_idUUID | String

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

Returns:

  • (UUID | String)


22
23
24
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 22

def counterparty_id
  @counterparty_id
end

#credit_ledger_account_idUUID | String

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

Returns:

  • (UUID | String)


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

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)


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

def 
  @debit_ledger_account_id
end

#descriptionString

An optional description for internal use.

Returns:

  • (String)


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

def description
  @description
end

#internal_account_idUUID | String

The ID of the internal account that this virtual account is associated with.

Returns:

  • (UUID | String)


27
28
29
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 27

def 
  @internal_account_id
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


52
53
54
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 52

def 
  @metadata
end

#nameString

The name of the virtual account.

Returns:

  • (String)


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

def name
  @name
end

#routing_detailsArray[RoutingDetailCreateRequest]

An array of routing detail objects.

Returns:



35
36
37
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 35

def routing_details
  @routing_details
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 108

def self.from_hash(hash)
  return nil unless hash

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

   = SKIP 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 << (RoutingDetailCreateRequest.from_hash(structure) if structure)
    end
  end

  routing_details = SKIP unless hash.key?('routing_details')
   =
    hash.key?('debit_ledger_account_id') ? hash['debit_ledger_account_id'] : SKIP
   =
    hash.key?('credit_ledger_account_id') ? hash['credit_ledger_account_id'] : SKIP
   = hash.key?('metadata') ? hash['metadata'] : 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.
  VirtualAccountCreateRequest.new(name: name,
                                  internal_account_id: ,
                                  description: description,
                                  counterparty_id: counterparty_id,
                                  account_details: ,
                                  routing_details: routing_details,
                                  debit_ledger_account_id: ,
                                  credit_ledger_account_id: ,
                                  metadata: ,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 55

def self.names
  @_hash = {} if @_hash.nil?
  @_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



83
84
85
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 83

def self.nullables
  []
end

.optionalsObject

An array for optional fields



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 70

def self.optionals
  %w[
    description
    counterparty_id
    account_details
    routing_details
    debit_ledger_account_id
    credit_ledger_account_id
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



175
176
177
178
179
180
181
182
183
184
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 175

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} 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},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



165
166
167
168
169
170
171
172
# File 'lib/modern_treasury/models/virtual_account_create_request.rb', line 165

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} 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}, additional_properties: #{@additional_properties}>"
end