Sha256: 376f9049403e97a7e422854391513acb969a28d2c5d13096f558bd05ca0b62fe

Contents?: true

Size: 673 Bytes

Versions: 4

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require 'codat/base_model'

module Codat
  module Models
    # Bank accounts for a given company.
    class BankAccount < BaseModel
      ENDPOINT = '/companies/:company_id/data/bankAccounts'

      attributes :id, :account_name, :from_date, :to_date, :sort_code, :account_number, :iban
      attributes :currency, :balance, :available_balance, :modified_date, :source_modified_date

      def self.all(company_id:)
        url = format_url(ENDPOINT, company_id: company_id.to_s.strip)

        result = get(url)

        return [] if result.status == 404

        result.body.map { |account| new(json: account) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codat-0.1.4 lib/codat/models/bank_account.rb
codat-0.1.3 lib/codat/models/bank_account.rb
codat-0.1.2 lib/codat/models/bank_account.rb
codat-0.1.1 lib/codat/models/bank_account.rb