Class: Yapstone::BankAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/yapstone-payments/models/bank_account.rb

Overview

Details for the bank account the customer wants to use for payment.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BankAccount

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
163
164
165
# File 'lib/yapstone-payments/models/bank_account.rb', line 109

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Yapstone::BankAccount` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Yapstone::BankAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'account_number')
    self. = attributes[:'account_number']
  end

  if attributes.key?(:'routing_number')
    self.routing_number = attributes[:'routing_number']
  end

  if attributes.key?(:'account_type')
    self. = attributes[:'account_type']
  end

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.key?(:'bank_name')
    self.bank_name = attributes[:'bank_name']
  end

  if attributes.key?(:'country')
    self.country = attributes[:'country']
  end

  if attributes.key?(:'bic')
    self.bic = attributes[:'bic']
  end

  if attributes.key?(:'bank_code')
    self.bank_code = attributes[:'bank_code']
  end

  if attributes.key?(:'branch_code')
    self.branch_code = attributes[:'branch_code']
  end

  if attributes.key?(:'iban')
    self.iban = attributes[:'iban']
  end

  if attributes.key?(:'name_on_account')
    self. = attributes[:'name_on_account']
  end
end

Instance Attribute Details

#account_numberObject

The full bank account number.



19
20
21
# File 'lib/yapstone-payments/models/bank_account.rb', line 19

def 
  @account_number
end

#account_typeObject

The type of account being paid from - choose from checking or savings account.



25
26
27
# File 'lib/yapstone-payments/models/bank_account.rb', line 25

def 
  @account_type
end

#bank_codeObject

A bank code is a code assigned by a central bank, a bank supervisory body or a Bankers Association in a country to all its licensed member banks or financial institutions. The name of bank codes can vary.



40
41
42
# File 'lib/yapstone-payments/models/bank_account.rb', line 40

def bank_code
  @bank_code
end

#bank_nameObject

The name of the bank.



31
32
33
# File 'lib/yapstone-payments/models/bank_account.rb', line 31

def bank_name
  @bank_name
end

#bicObject

The bank identifier code (BIC) is the SWIFT address assigned to a bank in order to send automated payments quicky and accurately to the banks concerned.



37
38
39
# File 'lib/yapstone-payments/models/bank_account.rb', line 37

def bic
  @bic
end

#branch_codeObject

A branch code is part of the Indian Financial System Code (IFSC), which is an 11 character alphanumeric code where the first four characters represent the bank’s name, the fifth character is always 0 and the rest of the digits are the branch code.



43
44
45
# File 'lib/yapstone-payments/models/bank_account.rb', line 43

def branch_code
  @branch_code
end

#countryObject

The country the bank is located in.



34
35
36
# File 'lib/yapstone-payments/models/bank_account.rb', line 34

def country
  @country
end

#currencyObject

The currency of the bank account.



28
29
30
# File 'lib/yapstone-payments/models/bank_account.rb', line 28

def currency
  @currency
end

#ibanObject

This is an International Bank Account Number (IBAN) which is an internationally agreed system of identifying bank accounts across national borders to facilitate the communication and processing of cross border transactions with a reduced risk of transcription errors.



46
47
48
# File 'lib/yapstone-payments/models/bank_account.rb', line 46

def iban
  @iban
end

#name_on_accountObject

The name of the person or business entity associated with the account.



49
50
51
# File 'lib/yapstone-payments/models/bank_account.rb', line 49

def 
  @name_on_account
end

#routing_numberObject

The routing transit number for the bank account



22
23
24
# File 'lib/yapstone-payments/models/bank_account.rb', line 22

def routing_number
  @routing_number
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/yapstone-payments/models/bank_account.rb', line 74

def self.attribute_map
  {
    :'account_number' => :'accountNumber',
    :'routing_number' => :'routingNumber',
    :'account_type' => :'accountType',
    :'currency' => :'currency',
    :'bank_name' => :'bankName',
    :'country' => :'country',
    :'bic' => :'bic',
    :'bank_code' => :'bankCode',
    :'branch_code' => :'branchCode',
    :'iban' => :'iban',
    :'name_on_account' => :'nameOnAccount'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



240
241
242
# File 'lib/yapstone-payments/models/bank_account.rb', line 240

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_typesObject

Attribute type mapping.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/yapstone-payments/models/bank_account.rb', line 91

def self.openapi_types
  {
    :'account_number' => :'String',
    :'routing_number' => :'String',
    :'account_type' => :'String',
    :'currency' => :'String',
    :'bank_name' => :'String',
    :'country' => :'String',
    :'bic' => :'String',
    :'bank_code' => :'String',
    :'branch_code' => :'String',
    :'iban' => :'String',
    :'name_on_account' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/yapstone-payments/models/bank_account.rb', line 209

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
       == o. &&
      routing_number == o.routing_number &&
       == o. &&
      currency == o.currency &&
      bank_name == o.bank_name &&
      country == o.country &&
      bic == o.bic &&
      bank_code == o.bank_code &&
      branch_code == o.branch_code &&
      iban == o.iban &&
       == o.
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/yapstone-payments/models/bank_account.rb', line 268

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    Yapstone.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/yapstone-payments/models/bank_account.rb', line 333

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/yapstone-payments/models/bank_account.rb', line 247

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


227
228
229
# File 'lib/yapstone-payments/models/bank_account.rb', line 227

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



233
234
235
# File 'lib/yapstone-payments/models/bank_account.rb', line 233

def hash
  [, routing_number, , currency, bank_name, country, bic, bank_code, branch_code, iban, ].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/yapstone-payments/models/bank_account.rb', line 169

def list_invalid_properties
  invalid_properties = Array.new
  if @account_number.nil?
    invalid_properties.push('invalid value for "account_number", account_number cannot be nil.')
  end

  if @account_type.nil?
    invalid_properties.push('invalid value for "account_type", account_type cannot be nil.')
  end

  if @currency.nil?
    invalid_properties.push('invalid value for "currency", currency cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



313
314
315
# File 'lib/yapstone-payments/models/bank_account.rb', line 313

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



319
320
321
322
323
324
325
326
327
# File 'lib/yapstone-payments/models/bank_account.rb', line 319

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



307
308
309
# File 'lib/yapstone-payments/models/bank_account.rb', line 307

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



188
189
190
191
192
193
194
195
# File 'lib/yapstone-payments/models/bank_account.rb', line 188

def valid?
  return false if @account_number.nil?
  return false if @account_type.nil?
   = EnumAttributeValidator.new('String', ["checking", "saving"])
  return false unless .valid?(@account_type)
  return false if @currency.nil?
  true
end