Skip to content

Commit

Permalink
add support for balance checking
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Oct 14, 2023
1 parent 3f48447 commit 10fdafe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
11 changes: 4 additions & 7 deletions burglar.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ require 'burglar/version'
Gem::Specification.new do |s|
s.name = 'burglar'
s.version = Burglar::VERSION
s.date = Time.now.strftime('%Y-%m-%d')
s.required_ruby_version = '>= 2.5.0'
s.required_ruby_version = '>= 3.0'

s.summary = 'Tool for parsing data from bank websites'
s.description = 'Tool for parsing data from bank websites'
Expand All @@ -16,16 +15,14 @@ Gem::Specification.new do |s|
s.license = 'MIT'

s.files = `git ls-files`.split
s.test_files = `git ls-files spec/*`.split
s.executables = ['burglar']

s.add_dependency 'cymbal', '~> 2.0.0'
s.add_dependency 'libledger', '~> 0.0.8'
s.add_dependency 'logcabin', '~> 0.1.3'
s.add_dependency 'mercenary', '~> 0.4.0'

s.add_development_dependency 'codecov', '~> 0.5.1'
s.add_development_dependency 'goodcop', '~> 0.9.3'
s.add_development_dependency 'rake', '~> 13.0.3'
s.add_development_dependency 'rspec', '~> 3.10.0'
s.add_development_dependency 'goodcop', '~> 0.9.7'

s.metadata['rubygems_mfa_required'] = 'true'
end
4 changes: 2 additions & 2 deletions lib/burglar/bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def end_date
@end_date ||= @options[:end]
end

private

def account_name
@account_name ||= @options[:account] || default_account_name
end

private

def default_account_name
raise('Module failed to override default_account_name')
end
Expand Down
16 changes: 15 additions & 1 deletion lib/burglar/modules/plaid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module LogCabin
module Modules
##
# Plaid
module Plaid
module Plaid # rubocop:disable Metrics/ModuleLength
include Burglar.helpers.find(:creds)
include Burglar.helpers.find(:ledger)

Expand All @@ -30,6 +30,10 @@ def raw_transactions # rubocop:disable Metrics/MethodLength
end
end

def balance
@balance ||= load_balance
end

private

def api_configuration
Expand All @@ -49,6 +53,16 @@ def client
@client ||= ::Plaid::PlaidApi.new(api_client)
end

def load_balance
resp = client.accounts_balance_get(::Plaid::AccountsBalanceGetRequest.new(
access_token: access_token,
options: ::Plaid::AccountsBalanceGetRequestOptions.new(
account_ids: [account_id]
)
))
resp.accounts.first.balances.current
end

def get_transactions_page(offset)
resp = client.transactions_get(::Plaid::TransactionsGetRequest.new(
access_token: access_token,
Expand Down
9 changes: 0 additions & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
if ENV['CI'] == 'true'
require 'simplecov'
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
SimpleCov.start do
add_filter '/spec/'
end
end

require 'rspec'
require 'burglar'

0 comments on commit 10fdafe

Please sign in to comment.