# 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