Sha256: cb59274e4c85cc6127190c6d0d0d1e89a5063de605e4ff3e5945a5b91db493d0

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

module Atrium
  class Transaction
    extend ::Atrium::Pageable
    include ::ActiveAttr::Model

    attribute :account_guid
    attribute :amount
    attribute :category
    attribute :check_number
    attribute :check_number_string
    attribute :created_at
    attribute :date
    attribute :description
    attribute :guid
    attribute :is_bill_pay
    attribute :is_direct_deposit
    attribute :is_expense
    attribute :is_fee
    attribute :is_income
    attribute :is_overdraft_fee
    attribute :is_payroll_advance
    attribute :latitude
    attribute :longitude
    attribute :member_guid
    attribute :memo
    attribute :merchant_category_code
    attribute :original_description
    attribute :posted_at
    attribute :status
    attribute :top_level_category
    attribute :transacted_at
    attribute :type
    attribute :updated_at
    attribute :user_guid

    def self.list(options = {})
      options = _transaction_pagination_options(options)
      paginate(options)
    end

    def self.list_each(options = {})
      options = _transaction_pagination_options(options)
      paginate_each(options) { |transaction| yield transaction }
    end

    def self.list_in_batches(options = {})
      options = _transaction_pagination_options(options)
      paginate_in_batches(options) { |batch| yield batch }
    end

    def self.read(user_guid:, transaction_guid:)
      endpoint = "/users/#{user_guid}/transactions/#{transaction_guid}"
      raw_transaction = ::Atrium.client.make_request(:get, endpoint)
      ::Atrium::Transaction.new(raw_transaction["transaction"])
    end

    def self._transaction_pagination_options(options)
      user_guid = options.fetch(:user_guid)
      endpoint = "/users/#{user_guid}/transactions"
      options.merge(:endpoint => endpoint, :resource => "transactions")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atrium-ruby-1.3.0 lib/atrium/transaction.rb
atrium-ruby-1.2.3 lib/atrium/transaction.rb
atrium-ruby-1.2.1 lib/atrium/transaction.rb
atrium-ruby-1.2.0 lib/atrium/transaction.rb