Sha256: 22586812b4f8ae8c6fec73fcb8a84c415c982b7fd767ef813f75fc8dd6a92994

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

require 'time'
require 'fractal_api/base_model'
require 'fractal_api/paginator'

module FractalApi
  module Forecasting
    class Transaction < BaseModel
      attributes :id, :bank_id, :forecast_id, :account_id,
                 :value_date, :amount, :currency,
                 :type, :merchant, :category, :reasons, :source

      def self.all(company_id, filters = {})
        filters = filters.transform_keys { |key| key_transformer.transform(key) }

        Paginator.new('/forecasting/v2/transactions', self) do |url|
          get(
            url,
            params: filters,
            headers: { 'X-Company-Id' => company_id }
          )
        end
      end

      def self.build(json:)
        super.tap do |record|
          record.value_date = Time.parse(record.value_date) if record.value_date
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fractal_api-0.1.6 lib/fractal_api/forecasting/transaction.rb
fractal_api-0.1.5 lib/fractal_api/forecasting/transaction.rb
fractal_api-0.1.4 lib/fractal_api/forecasting/transaction.rb
fractal_api-0.1.3 lib/fractal_api/forecasting/transaction.rb
fractal_api-0.1.2 lib/fractal_api/forecasting/transaction.rb