Sha256: cef2a50a729fe00975b7420f66833e75a2fcf60d40dbf37edfa05e617271c2d5

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require_relative '../base/converters'
require_relative '../base/validators'
require_relative '../base/account_transaction_helpers'

module WireClient
  class Account
    include ActiveModel::Validations
    include AccountTransactionHelpers
    extend Converter

    attr_accessor :name,
                  :iban,
                  :bic,
                  :account_number,
                  :wire_routing_number,
                  :clear_system_code,
                  :postal_code,
                  :address_line,
                  :city,
                  :country_subdivision,
                  :country,
                  :currency,
                  :schema_code,
                  :identifier,
                  :charge_bearer

    convert :name, to: :text
    validates_length_of :currency, is: 3
    validates_length_of :name, within: 1..70
    validates_with CurrencyValidator,
                   CountryValidator,
                   CountrySubdivisionValidator,
                   BICValidator,
                   IBANValidator,
                   CreditorIdentifierValidator,
                   message: "%{value} is invalid"

    def initialize(attributes = {})
      attributes.each do |name, value|
        public_send("#{name}=", value)
      end

      @currency ||= 'USD'
      @postal_code ||= 'NA'
      @address_line ||= 'NA'
      @city ||= 'NA'
      @country ||= 'US'
      @country_subdivision ||= 'MA' if self.country == 'US'
      @schema_code ||= 'CUST'
      @clear_system_code ||= 'USABA'
      custom_defaults if self.respond_to? :custom_defaults
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wire_client-0.4.1 lib/wire_client/account/account.rb
wire_client-0.4.0 lib/wire_client/account/account.rb
wire_client-0.2.0 lib/wire_client/account/account.rb
wire_client-0.1.4 lib/wire_client/account/account.rb
wire_client-0.1.3 lib/wire_client/account/account.rb