Sha256: c41e068f2d25e25fcd63c846001dd1549e3505406079d328d7aa3f00e7cbef72

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

module PapierkramApi
  module V1
    module Endpoints
      module Income
        # This class is responsible for all the API calls related to income invoices.
        class Invoices < PapierkramApi::V1::Endpoints::Base
          def by(id:, pdf: false)
            if pdf == true
              return get("#{@url_api_path}/income/invoices/#{id}/pdf", nil,
                         { headers: { 'Content-Type' => 'application/pdf' } })
            end

            get("#{@url_api_path}/income/invoices/#{id}")
          end

          def all(page: 1, # rubocop:disable Metrics/CyclomaticComplexity
                  page_size: 100,
                  order_by: nil,
                  order_direction: nil,
                  creditor_id: nil,
                  project_id: nil,
                  document_date_range_start: nil,
                  document_date_range_end: nil)
            query = {
              page: page,
              page_size: page_size
            }
            query[:order_by] = order_by if order_by
            query[:order_direction] = order_direction if order_direction
            query[:creditor_id] = creditor_id if creditor_id
            query[:project_id] = project_id if project_id
            query[:document_date_range_start] = document_date_range_start if document_date_range_start
            if document_date_range_end && document_date_range_start
              query[:document_date_range_end] =
                document_date_range_end
            end

            get("#{@url_api_path}/income/invoices", query)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
papierkram_api_client-0.2.4 lib/papierkram_api/v1/endpoints/income/invoices.rb
papierkram_api_client-0.2.3 lib/papierkram_api/v1/endpoints/income/invoices.rb
papierkram_api_client-0.2.2 lib/papierkram_api/v1/endpoints/income/invoices.rb
papierkram_api_client-0.2.1 lib/papierkram_api/v1/endpoints/income/invoices.rb
papierkram_api_client-0.2.0 lib/papierkram_api/v1/endpoints/income/invoices.rb