Sha256: 70a0296c5c010252d817364eafaf7ca0f064b46e00db39047017db504086a23b

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# typed: strict
# frozen_string_literal: true

require_relative "../objects/plaid_account"

module LunchMoney
  module Calls
    # https://lunchmoney.dev/#plaid-accounts
    class PlaidAccounts < LunchMoney::Calls::Base
      sig { returns(T.any(T::Array[LunchMoney::Objects::PlaidAccount], LunchMoney::Errors)) }
      def plaid_accounts
        response = get("plaid_accounts")

        api_errors = errors(response)
        return api_errors if api_errors.present?

        response.body[:plaid_accounts].map do |plaid_account|
          LunchMoney::Objects::PlaidAccount.new(**plaid_account)
        end
      end

      sig do
        params(
          start_date: T.nilable(String),
          end_date: T.nilable(String),
          plaid_account_id: T.nilable(Integer),
        ).returns(T.any(T::Boolean, LunchMoney::Errors))
      end
      def plaid_accounts_fetch(start_date: nil, end_date: nil, plaid_account_id: nil)
        params = clean_params({ start_date:, end_date:, plaid_account_id: })
        response = post("plaid_accounts/fetch", params)

        api_errors = errors(response)
        return api_errors if api_errors.present?

        response.body
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lunchmoney-1.4.0 lib/lunchmoney/calls/plaid_accounts.rb
lunchmoney-1.2.0 lib/lunchmoney/calls/plaid_accounts.rb
lunchmoney-1.1.2 lib/lunchmoney/calls/plaid_accounts.rb
lunchmoney-1.1.1 lib/lunchmoney/calls/plaid_accounts.rb
lunchmoney-1.1.0 lib/lunchmoney/calls/plaid_accounts.rb