class Codat::Models::BankStatementList

Bank statements for a given company. This endpoint will return an array of records and also metadata (page size, page number and total results).

Constants

ENDPOINT

Attributes

metadata[R]
records[R]

Public Class Methods

for(company_id:, account_id:, page: 1) click to toggle source
# File lib/codat/models/bank_statement_list.rb, line 16
def self.for(company_id:, account_id:, page: 1)
  url = format_url(ENDPOINT, company_id: company_id.to_s.strip)

  result = get(url, accountId: account_id.to_s.strip, page: page.to_s.strip)

  return nil unless successful_response?(result)

  new(json: result.body)
end
new(json:) click to toggle source
Calls superclass method Codat::BaseModel::new
# File lib/codat/models/bank_statement_list.rb, line 26
def initialize(json:)
  super

  records = json.delete(:results) || []

  @records = records.map { |bank_statement| BankStatement.new(json: bank_statement) }

  @metadata = Metadata.new(json: json)
end