# frozen_string_literal: true require 'codat/base_model' module Codat module Models # Reports for a given company. class Report < BaseModel ENDPOINT = '/companies/:company_id/reports/agedDebtor' attributes :id, :customer_id, :customer_name, :aged_currency_outstanding, :currency attributes :aged_outstanding_amounts, :from_date, :to_date, :amount 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[:data].map { |report| new(json: report) } end end end end