Sha256: ebe8ed27d4a1721ee633db09378732fb7dcbcac05e2d2ab2cf4591eed3b9853f

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

module Atrium
  class Account
    include ::ActiveAttr::Model

    # ATTRIBUTES
    attribute :apr
    attribute :apy
    attribute :available_balance
    attribute :available_credit
    attribute :balance
    attribute :created_at
    attribute :credit_limit
    attribute :day_payment_is_due
    attribute :guid
    attribute :institution_code
    attribute :interest_rate
    attribute :is_closed
    attribute :last_payment
    attribute :last_payment_at
    attribute :matures_on
    attribute :member_guid
    attribute :minimum_balance
    attribute :minimum_payment
    attribute :name
    attribute :original_balance
    attribute :payment_due_at
    attribute :payoff_balance
    attribute :started_on
    attribute :subtype
    attribute :total_account_value
    attribute :type
    attribute :updated_at
    attribute :user_guid

    def self.list(user_guid:)
      endpoint = "/users/#{user_guid}/accounts"
      accounts_response = ::Atrium.client.make_request(:get, endpoint)

      accounts_response["accounts"].map do |account|
        ::Atrium::Account.new(account)
      end
    end

    def self.read(user_guid:, account_guid:)
      endpoint = "/users/#{user_guid}/accounts/#{account_guid}"
      account_response = ::Atrium.client.make_request(:get, endpoint)

      account_params = account_response["account"]
      ::Atrium::Account.new(account_params)
    end

    def transactions
      endpoint = "/users/#{user_guid}/accounts/#{guid}/transactions"
      account_transactions_response = ::Atrium.client.make_request(:get, endpoint)

      account_transactions_response["transactions"].map do |transaction|
        ::Atrium::Transaction.new(transaction)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atrium-ruby-0.5.0 lib/atrium/account.rb