Module: LogCabin::Modules::Plaid
- Defined in:
- lib/burglar/modules/plaid.rb
Overview
Plaid
Constant Summary collapse
- PLAID_DOMAIN =
'https://plaid.com'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #balance ⇒ Object
-
#raw_transactions ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.load_accounts(client, access_token) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/burglar/modules/plaid.rb', line 13 def self.load_accounts(client, access_token) @accounts ||= {} return @accounts[access_token] if @accounts[access_token] req = ::Plaid::AccountsGetRequest.new(access_token: access_token) @accounts[access_token] = client.accounts_get(req).accounts end |
Instance Method Details
#balance ⇒ Object
40 41 42 |
# File 'lib/burglar/modules/plaid.rb', line 40 def balance @balance ||= load_balance end |
#raw_transactions ⇒ Object
rubocop:disable Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/burglar/modules/plaid.rb', line 20 def raw_transactions # rubocop:disable Metrics/MethodLength @raw_transactions ||= all_transactions.map do |row| amount = format('$%.2f', row.amount) name = row.name.downcase action = guess_action(name) state = row.pending ? :pending : :cleared ::Ledger::Entry.new( name: name, state: state, date: row.date, actions: [ { name: action, amount: amount }, { name: account_name } ], tags: { 'transaction_id' => row.transaction_id } ) end end |