Sha256: 7fc895dea58c4760db86c7e27622a2fb2f591e2421214cce86bcba291a84a5ec

Contents?: true

Size: 654 Bytes

Versions: 6

Compression:

Stored size: 654 Bytes

Contents

# 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

Version data entries

6 entries across 6 versions & 1 rubygems

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