Sha256: 46364e68707ed02e9734892f24a585fb4635331f165fc1de397502c7c60ad084

Contents?: true

Size: 685 Bytes

Versions: 6

Compression:

Stored size: 685 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 [] unless successful_response?(result)

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
codat-0.1.6.2 lib/codat/models/bank_account.rb
codat-0.1.6.1 lib/codat/models/bank_account.rb
codat-0.1.8 lib/codat/models/bank_account.rb
codat-0.1.7 lib/codat/models/bank_account.rb
codat-0.1.6 lib/codat/models/bank_account.rb
codat-0.1.5 lib/codat/models/bank_account.rb