Sha256: 0509f17533001de2d6580545c15f95946f36985ab6c6c2b31bca0d661eea6738
Contents?: true
Size: 1020 Bytes
Versions: 4
Compression:
Stored size: 1020 Bytes
Contents
# frozen_string_literal: true require 'codat/base_model' require 'codat/models/bank_statement' require 'codat/models/metadata' module Codat module Models # Bank statements for a given company. This endpoint will return an array of records and also # metadata (page size, page number and total results). class BankStatementList < BaseModel ENDPOINT = '/companies/:company_id/data/bankStatements' attr_reader :records, :metadata 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 def initialize(json:) super records = json.delete(:results) || [] @records = records.map { |bank_statement| BankStatement.new(json: bank_statement) } @metadata = Metadata.new(json: json) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems