bankscrap 2.0.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/generators/adapter_generator.rb +8 -8
- data/generators/templates/lib/bankscrap/%bank_name_dasherized%/bank.rb.tt +46 -0
- data/lib/bankscrap/account.rb +11 -3
- data/lib/bankscrap/bank.rb +5 -3
- data/lib/bankscrap/card.rb +34 -0
- data/lib/bankscrap/cli.rb +73 -34
- data/lib/bankscrap/exporters/csv.rb +53 -7
- data/lib/bankscrap/exporters/json.rb +89 -0
- data/lib/bankscrap/investment.rb +1 -1
- data/lib/bankscrap/loan.rb +33 -0
- data/lib/bankscrap/transaction.rb +2 -2
- data/lib/bankscrap/version.rb +1 -1
- data/lib/bankscrap.rb +3 -0
- metadata +37 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f598489f53a242aa5cb5a24f13ac4cb7311743
|
4
|
+
data.tar.gz: 75729f1b0fceb649218919b8a58a416ddaddb321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9304e7a9d6df0162edc510847e99a9a037214d7cd2237e6cde5b4c4cef183bcdea4cd2fbfe8f4f30a45f4460114e07489522d02dc3661874b3ab0062d0ccf3e5
|
7
|
+
data.tar.gz: 2c6e2c11d7613f0c7ad1f5721663d4a601ee7897c105746a47b1f69f6167f8dbb42cd6a43f971b87fcdae495f7e3b12e85235ab4c617b18da54d6b91896fcca8
|
@@ -12,14 +12,14 @@ module Bankscrap
|
|
12
12
|
self.destination_root = File.expand_path('.', gem_name)
|
13
13
|
directory '.'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
STDERR.puts ''
|
16
|
+
STDERR.puts "Great! Now you can start implementing your bank's adapter for Bankscrap.".yellow
|
17
|
+
STDERR.puts ''
|
18
|
+
STDERR.puts 'To get started take a look to:', :yellow
|
19
|
+
STDERR.puts "#{destination_root}/lib/bankscrap/#{bank_name_dasherized}/bank.rb".yellow
|
20
|
+
STDERR.puts ''
|
21
|
+
STDERR.puts 'If you need help you can join our Slack chat room. Click the Slack badge on Github:'.yellow
|
22
|
+
STDERR.puts 'https://github.com/bankscrap/bankscrap'.yellow
|
23
23
|
end
|
24
24
|
|
25
25
|
protected
|
@@ -10,6 +10,8 @@ module Bankscrap
|
|
10
10
|
# LOGIN_ENDPOINT = '/login'.freeze
|
11
11
|
# ACCOUNTS_ENDPOINT = '/accounts'.freeze
|
12
12
|
# TRANSACTIONS_ENDPOINT = '/transactions'.freeze
|
13
|
+
# CARDS_ENDPOINT = '/cards'.freeze
|
14
|
+
# LOANS_ENDPOINT = '/loans'.freeze
|
13
15
|
|
14
16
|
# TODO: change this for the proper credentials required in your adapter.
|
15
17
|
# It can be anything (user, birthday, ID, whatever you need).
|
@@ -35,6 +37,26 @@ module Bankscrap
|
|
35
37
|
# json['accounts'].map { |data| build_account(data) }
|
36
38
|
end
|
37
39
|
|
40
|
+
# Fetch all the loans for the given user
|
41
|
+
#
|
42
|
+
# Should returns an array of Bankscrap::Loan objects
|
43
|
+
def fetch_loans
|
44
|
+
# Example if the API expects a JSON POST request
|
45
|
+
# response = post(BASE_ENDPOINT + LOANS_ENDPOINT, fields: {}.to_json)
|
46
|
+
# json = JSON.parse(response)
|
47
|
+
# json['accounts'].map { |data| build_loan(data) }
|
48
|
+
end
|
49
|
+
|
50
|
+
# Fetch all the credit cards for the given user
|
51
|
+
#
|
52
|
+
# Should returns an array of Bankscrap::Card objects
|
53
|
+
def fetch_cards
|
54
|
+
# Example if the API expects a JSON POST request
|
55
|
+
# response = post(BASE_ENDPOINT + CARDS_ENDPOINT, fields: {}.to_json)
|
56
|
+
# json = JSON.parse(response)
|
57
|
+
# json['accounts'].map { |data| build_card(data) }
|
58
|
+
end
|
59
|
+
|
38
60
|
# Fetch transactions for the given account.
|
39
61
|
#
|
40
62
|
# Account should be a Bankscrap::Account object
|
@@ -68,6 +90,30 @@ module Bankscrap
|
|
68
90
|
)
|
69
91
|
end
|
70
92
|
|
93
|
+
# Build a loan object from API data
|
94
|
+
def build_loan(data)
|
95
|
+
Loan.new(
|
96
|
+
bank: self,
|
97
|
+
id: REPLACE_ME,
|
98
|
+
name: REPLACE_ME,
|
99
|
+
description: REPLACE_ME,
|
100
|
+
amount: REPLACE_ME,
|
101
|
+
is_mortage: REPLACE_ME
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Build a card object from API data
|
106
|
+
def build_card(data)
|
107
|
+
Card.new(
|
108
|
+
bank: self,
|
109
|
+
id: REPLACE_ME,
|
110
|
+
name: REPLACE_ME,
|
111
|
+
description: REPLACE_ME,
|
112
|
+
amount: REPLACE_ME,
|
113
|
+
is_credit: REPLACE_ME
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
71
117
|
# Build a transaction object from API data
|
72
118
|
def build_transaction(data, account)
|
73
119
|
Transaction.new(
|
data/lib/bankscrap/account.rb
CHANGED
@@ -8,8 +8,8 @@ module Bankscrap
|
|
8
8
|
:raw_data
|
9
9
|
|
10
10
|
def initialize(params = {})
|
11
|
-
raise NotMoneyObjectError
|
12
|
-
raise NotMoneyObjectError
|
11
|
+
raise NotMoneyObjectError, :balance unless params[:balance].is_a?(Money)
|
12
|
+
raise NotMoneyObjectError, :available_balance unless params[:available_balance].is_a?(Money)
|
13
13
|
|
14
14
|
params.each { |key, value| send "#{key}=", value }
|
15
15
|
end
|
@@ -26,10 +26,18 @@ module Bankscrap
|
|
26
26
|
balance.try(:currency)
|
27
27
|
end
|
28
28
|
|
29
|
+
def to_s
|
30
|
+
description
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_a
|
34
|
+
[id, iban, name, description, balance]
|
35
|
+
end
|
36
|
+
|
29
37
|
private
|
30
38
|
|
31
39
|
def inspect_attributes
|
32
|
-
%i
|
40
|
+
%i[id name balance available_balance description iban bic]
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/bankscrap/bank.rb
CHANGED
@@ -5,9 +5,9 @@ module Bankscrap
|
|
5
5
|
class Bank
|
6
6
|
WEB_USER_AGENT = 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, ' \
|
7
7
|
'like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19'.freeze
|
8
|
-
attr_accessor :headers, :accounts, :investments
|
8
|
+
attr_accessor :headers, :accounts, :cards, :loans, :investments
|
9
9
|
|
10
|
-
REQUIRED_CREDENTIALS = %i
|
10
|
+
REQUIRED_CREDENTIALS = %i[user password].freeze
|
11
11
|
|
12
12
|
class MissingCredential < ArgumentError; end
|
13
13
|
|
@@ -29,8 +29,10 @@ module Bankscrap
|
|
29
29
|
login
|
30
30
|
@accounts = fetch_accounts
|
31
31
|
|
32
|
-
# Not all the adapters have support for investments
|
32
|
+
# Not all the adapters have support for investments, loans or cards
|
33
33
|
@investments = fetch_investments if respond_to?(:fetch_investments)
|
34
|
+
@loans = fetch_loans if respond_to?(:fetch_loans)
|
35
|
+
@cards = fetch_cards if respond_to?(:fetch_cards)
|
34
36
|
end
|
35
37
|
|
36
38
|
# Interface method placeholders
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bankscrap
|
2
|
+
class Card
|
3
|
+
include Utils::Inspectable
|
4
|
+
|
5
|
+
attr_accessor :bank, :id, :name, :pan, :amount,
|
6
|
+
:avaliable, :is_credit, :description,
|
7
|
+
:raw_data
|
8
|
+
|
9
|
+
def initialize(params = {})
|
10
|
+
raise NotMoneyObjectError, :amount unless params[:amount].is_a?(Money)
|
11
|
+
raise NotMoneyObjectError, :avaliable unless params[:avaliable].is_a?(Money)
|
12
|
+
|
13
|
+
params.each { |key, value| send "#{key}=", value }
|
14
|
+
end
|
15
|
+
|
16
|
+
def currency
|
17
|
+
amount.try(:currency)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
description
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_a
|
25
|
+
[id, name, description, pan, amount, avaliable, is_credit]
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def inspect_attributes
|
31
|
+
%i[id name description pan amount avaliable is_credit]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/bankscrap/cli.rb
CHANGED
@@ -17,17 +17,51 @@ module Bankscrap
|
|
17
17
|
option :output
|
18
18
|
end
|
19
19
|
|
20
|
-
desc 'balance BankName', "get
|
20
|
+
desc 'balance BankName', "get account's balance"
|
21
21
|
shared_options
|
22
22
|
def balance(bank)
|
23
23
|
assign_shared_options
|
24
24
|
initialize_client_for(bank)
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
if options[:format]
|
27
|
+
export_to_file(nil, @client.accounts, options[:format], options[:output])
|
28
|
+
else
|
29
|
+
@client.accounts.each do |account|
|
30
|
+
STDERR.puts "Account: #{account.description} (#{account.iban})".cyan
|
31
|
+
STDERR.puts "Balance: #{account.balance.format}".green
|
32
|
+
if account.balance != account.available_balance
|
33
|
+
STDERR.puts "Available: #{account.available_balance.format}".yellow
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'cards BankName', "get account's credit cards"
|
40
|
+
shared_options
|
41
|
+
def cards(bank)
|
42
|
+
assign_shared_options
|
43
|
+
initialize_client_for(bank)
|
44
|
+
|
45
|
+
if options[:format]
|
46
|
+
export_to_file(nil, @client.cards, options[:format], options[:output])
|
47
|
+
else
|
48
|
+
@client.cards.each do |card|
|
49
|
+
STDERR.puts "Card: #{card.name} #{card.description} #{card.amount.format}".green
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'loans BankName', "get account's loans"
|
55
|
+
shared_options
|
56
|
+
def loans(bank)
|
57
|
+
assign_shared_options
|
58
|
+
initialize_client_for(bank)
|
59
|
+
|
60
|
+
if options[:format]
|
61
|
+
export_to_file(nil, @client.loans, options[:format], options[:output])
|
62
|
+
else
|
63
|
+
@client.loans.each do |loan|
|
64
|
+
STDERR.puts "Loan: #{loan.name} #{loan.description} #{loan.amount.format}".green
|
31
65
|
end
|
32
66
|
end
|
33
67
|
end
|
@@ -47,7 +81,7 @@ module Bankscrap
|
|
47
81
|
|
48
82
|
if start_date && end_date
|
49
83
|
if start_date > end_date
|
50
|
-
|
84
|
+
STDERR.puts 'From date must be lower than to date'.red
|
51
85
|
exit
|
52
86
|
end
|
53
87
|
|
@@ -56,11 +90,13 @@ module Bankscrap
|
|
56
90
|
transactions = account.transactions
|
57
91
|
end
|
58
92
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
93
|
+
if options[:format]
|
94
|
+
export_to_file(account, transactions, options[:format], options[:output])
|
95
|
+
else
|
96
|
+
STDERR.puts "Transactions for: #{account.description} (#{account.iban})".cyan
|
97
|
+
print_transactions_header
|
98
|
+
transactions.each { |t| print_transaction(t) }
|
99
|
+
end
|
64
100
|
end
|
65
101
|
|
66
102
|
register(Bankscrap::AdapterGenerator, 'generate_adapter', 'generate_adapter MyBankName',
|
@@ -69,10 +105,10 @@ module Bankscrap
|
|
69
105
|
private
|
70
106
|
|
71
107
|
def assign_shared_options
|
72
|
-
@credentials
|
73
|
-
@iban
|
74
|
-
@log
|
75
|
-
@debug
|
108
|
+
@credentials = options[:credentials]
|
109
|
+
@iban = options[:iban]
|
110
|
+
@log = options[:log]
|
111
|
+
@debug = options[:debug]
|
76
112
|
end
|
77
113
|
|
78
114
|
def initialize_client_for(bank_name)
|
@@ -86,46 +122,49 @@ module Bankscrap
|
|
86
122
|
require "bankscrap-#{bank_name.underscore.dasherize}"
|
87
123
|
Object.const_get("Bankscrap::#{bank_name}::Bank")
|
88
124
|
rescue LoadError
|
89
|
-
raise ArgumentError
|
125
|
+
raise ArgumentError, 'Invalid bank name.'
|
90
126
|
rescue NameError
|
91
|
-
raise ArgumentError
|
127
|
+
raise ArgumentError, "Invalid bank name. Did you mean \"#{bank_name.upcase}\"?"
|
92
128
|
end
|
93
129
|
|
94
130
|
def parse_date(string)
|
95
131
|
Date.strptime(string, '%d-%m-%Y')
|
96
132
|
rescue ArgumentError
|
97
|
-
|
133
|
+
STDERR.puts 'Invalid date format. Correct format d-m-Y (eg: 31-12-2016)'.red
|
98
134
|
exit
|
99
135
|
end
|
100
136
|
|
101
|
-
def export_to_file(data, format, path)
|
102
|
-
exporter(
|
137
|
+
def export_to_file(account, data, format, path)
|
138
|
+
exporter(account, format).write_to_file(data, path)
|
103
139
|
end
|
104
140
|
|
105
|
-
def exporter(
|
141
|
+
def exporter(account, format)
|
106
142
|
case format.downcase
|
107
|
-
when 'csv'
|
143
|
+
when 'csv'
|
144
|
+
BankScrap::Exporter::Csv.new(account)
|
145
|
+
when 'json'
|
146
|
+
BankScrap::Exporter::Json.new(account)
|
108
147
|
else
|
109
|
-
|
148
|
+
STDERR.puts 'Sorry, file format not supported.'.red
|
110
149
|
exit
|
111
150
|
end
|
112
151
|
end
|
113
152
|
|
114
153
|
def print_transactions_header
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
154
|
+
STDERR.puts "\n"
|
155
|
+
STDERR.puts 'DATE'.ljust(13)
|
156
|
+
STDERR.puts 'DESCRIPTION'.ljust(50) + SPACER
|
157
|
+
STDERR.puts 'AMOUNT'.rjust(15) + SPACER
|
158
|
+
STDERR.puts 'BALANCE'.rjust(15)
|
159
|
+
STDERR.puts '-' * 99
|
121
160
|
end
|
122
161
|
|
123
162
|
def print_transaction(transaction)
|
124
163
|
color = (transaction.amount.to_i > 0 ? :green : :red)
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
164
|
+
STDERR.puts transaction.effective_date.strftime('%d/%m/%Y') + SPACER
|
165
|
+
STDERR.puts Utils::CliString.new(transaction.description).squish.truncate(50).ljust(50) + SPACER.colorize(color)
|
166
|
+
STDERR.puts Utils::CliString.new(transaction.amount.format).rjust(15) + SPACER.colorize(color)
|
167
|
+
STDERR.puts Utils::CliString.new(transaction.balance.format).rjust(15)
|
129
168
|
end
|
130
169
|
end
|
131
170
|
end
|
@@ -1,18 +1,64 @@
|
|
1
1
|
require 'csv'
|
2
|
+
require 'thor'
|
2
3
|
|
3
4
|
module BankScrap
|
4
5
|
module Exporter
|
6
|
+
# Csv exporter
|
5
7
|
class Csv
|
6
|
-
|
8
|
+
def initialize(account)
|
9
|
+
@account = account
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_filename(data, output)
|
13
|
+
if output
|
14
|
+
if output == '-'
|
15
|
+
'/dev/stdout'
|
16
|
+
else
|
17
|
+
output
|
18
|
+
end
|
19
|
+
else
|
20
|
+
if check_array_class(data, Bankscrap::Transaction)
|
21
|
+
'transactions.json'
|
22
|
+
elsif check_array_class(data, Bankscrap::Account)
|
23
|
+
'accounts.json'
|
24
|
+
elsif check_array_class(data, Bankscrap::Loan)
|
25
|
+
'loans.json'
|
26
|
+
elsif check_array_class(data, Bankscrap::Card)
|
27
|
+
'cards.json'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
7
31
|
|
8
|
-
def
|
9
|
-
|
32
|
+
def check_array_class(data, tclass)
|
33
|
+
data.all? { |x| x.is_a? tclass }
|
10
34
|
end
|
11
35
|
|
12
|
-
def write_to_file(data)
|
13
|
-
|
14
|
-
|
15
|
-
|
36
|
+
def write_to_file(data, output)
|
37
|
+
output = get_filename(data, output)
|
38
|
+
if check_array_class(data, Bankscrap::Transaction)
|
39
|
+
CSV.open(output, 'wb') do |csv|
|
40
|
+
csv << %w[Date Description Amount]
|
41
|
+
data.each { |line| csv << line.to_a }
|
42
|
+
end
|
43
|
+
STDERR.puts "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}".cyan
|
44
|
+
elsif check_array_class(data, Bankscrap::Account)
|
45
|
+
CSV.open(output, 'wb') do |csv|
|
46
|
+
csv << %w[Id Iban Name Description Bank Balance]
|
47
|
+
data.each { |line| csv << line.to_a }
|
48
|
+
end
|
49
|
+
STDERR.puts "Accounts exported to #{output}".cyan
|
50
|
+
elsif check_array_class(data, Bankscrap::Loan)
|
51
|
+
CSV.open(output, 'wb') do |csv|
|
52
|
+
csv << %w[Id Name Description Amount]
|
53
|
+
data.each { |line| csv << line.to_a }
|
54
|
+
end
|
55
|
+
STDERR.puts "Accounts exported to #{output}".cyan
|
56
|
+
elsif check_array_class(data, Bankscrap::Card)
|
57
|
+
CSV.open(output, 'wb') do |csv|
|
58
|
+
csv << %w[Id Name Description Pan Amount Avaliable Is_credit]
|
59
|
+
data.each { |line| csv << line.to_a }
|
60
|
+
end
|
61
|
+
STDERR.puts "Accounts exported to #{output}".cyan
|
16
62
|
end
|
17
63
|
end
|
18
64
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
module BankScrap
|
5
|
+
module Exporter
|
6
|
+
# Json exporter
|
7
|
+
class Json
|
8
|
+
def initialize(account)
|
9
|
+
@account = account
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_filename(data, output)
|
13
|
+
if output
|
14
|
+
if output == '-'
|
15
|
+
'/dev/stdout'
|
16
|
+
else
|
17
|
+
output
|
18
|
+
end
|
19
|
+
else
|
20
|
+
if check_array_class(data, Bankscrap::Transaction)
|
21
|
+
'transactions.json'
|
22
|
+
elsif check_array_class(data, Bankscrap::Account)
|
23
|
+
'accounts.json'
|
24
|
+
elsif check_array_class(data, Bankscrap::Loan)
|
25
|
+
'loans.json'
|
26
|
+
elsif check_array_class(data, Bankscrap::Card)
|
27
|
+
'cards.json'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def check_array_class(data, tclass)
|
33
|
+
data.all? { |x| x.is_a? tclass }
|
34
|
+
end
|
35
|
+
|
36
|
+
def write_to_file(data, output)
|
37
|
+
output = get_filename(data, output)
|
38
|
+
json_array = []
|
39
|
+
if check_array_class(data, Bankscrap::Transaction)
|
40
|
+
data.each do |line|
|
41
|
+
array = line.to_a
|
42
|
+
hash = { date: array[0], description: array[1], amount: array[2] }
|
43
|
+
json_array << hash
|
44
|
+
end
|
45
|
+
json_hash = { account: { description: @account.description, iban: @account.iban }, transactions: json_array }
|
46
|
+
elsif check_array_class(data, Bankscrap::Account)
|
47
|
+
data.each do |line|
|
48
|
+
array = line.to_a
|
49
|
+
|
50
|
+
hash = { iban: array[1], name: array[2], description: array[3], amount: array[4] }
|
51
|
+
json_array << hash
|
52
|
+
end
|
53
|
+
|
54
|
+
json_hash = { accounts: json_array }
|
55
|
+
elsif check_array_class(data, Bankscrap::Loan)
|
56
|
+
data.each do |line|
|
57
|
+
array = line.to_a
|
58
|
+
|
59
|
+
hash = { id: array[0], name: array[1], description: array[2], amount: array[3] }
|
60
|
+
json_array << hash
|
61
|
+
end
|
62
|
+
|
63
|
+
json_hash = { loans: json_array }
|
64
|
+
elsif check_array_class(data, Bankscrap::Card)
|
65
|
+
data.each do |line|
|
66
|
+
array = line.to_a
|
67
|
+
|
68
|
+
hash = { id: array[0], name: array[1], description: array[2], pan: array[3], amount: array[4], avaliable: array[5], isCredit: array[6] }
|
69
|
+
json_array << hash
|
70
|
+
end
|
71
|
+
|
72
|
+
json_hash = { cards: json_array }
|
73
|
+
end
|
74
|
+
File.open(output, 'w') do |f|
|
75
|
+
f.write(JSON.pretty_generate(json_hash) + "\n")
|
76
|
+
end
|
77
|
+
if check_array_class(data, Bankscrap::Transaction)
|
78
|
+
STDERR.puts "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}".cyan
|
79
|
+
elsif check_array_class(data, Bankscrap::Account)
|
80
|
+
STDERR.puts "Accounts exported to #{output}".cyan
|
81
|
+
elsif check_array_class(data, Bankscrap::Loan)
|
82
|
+
STDERR.puts "Loans exported to #{output}".cyan
|
83
|
+
elsif check_array_class(data, Bankscrap::Card)
|
84
|
+
STDERR.puts "Cards exported to #{output}".cyan
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/bankscrap/investment.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Bankscrap
|
2
|
+
class Loan
|
3
|
+
include Utils::Inspectable
|
4
|
+
|
5
|
+
attr_accessor :bank, :id, :name, :amount,
|
6
|
+
:description,
|
7
|
+
:raw_data
|
8
|
+
|
9
|
+
def initialize(params = {})
|
10
|
+
raise NotMoneyObjectError, :amount unless params[:amount].is_a?(Money)
|
11
|
+
|
12
|
+
params.each { |key, value| send "#{key}=", value }
|
13
|
+
end
|
14
|
+
|
15
|
+
def currency
|
16
|
+
amount.try(:currency)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
description
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_a
|
24
|
+
[id, name, description, amount]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def inspect_attributes
|
30
|
+
%i[id name description amount]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -5,7 +5,7 @@ module Bankscrap
|
|
5
5
|
attr_accessor :id, :amount, :description, :description_detail, :effective_date, :operation_date, :balance, :account
|
6
6
|
|
7
7
|
def initialize(params = {})
|
8
|
-
raise NotMoneyObjectError
|
8
|
+
raise NotMoneyObjectError, :amount unless params[:amount].is_a?(Money)
|
9
9
|
|
10
10
|
params.each { |key, value| send "#{key}=", value }
|
11
11
|
end
|
@@ -25,7 +25,7 @@ module Bankscrap
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def inspect_attributes
|
28
|
-
%i
|
28
|
+
%i[id amount effective_date description balance]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/bankscrap/version.rb
CHANGED
data/lib/bankscrap.rb
CHANGED
@@ -10,7 +10,10 @@ require_relative 'bankscrap/bank'
|
|
10
10
|
require_relative 'bankscrap/account'
|
11
11
|
require_relative 'bankscrap/investment'
|
12
12
|
require_relative 'bankscrap/transaction'
|
13
|
+
require_relative 'bankscrap/card'
|
14
|
+
require_relative 'bankscrap/loan'
|
13
15
|
require_relative 'bankscrap/exporters/csv'
|
16
|
+
require_relative 'bankscrap/exporters/json'
|
14
17
|
|
15
18
|
module Bankscrap
|
16
19
|
class << self
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankscrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Cuevas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: activesupport
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: colorize
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -82,7 +82,21 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: json
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: mechanize
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
102
|
- - ">="
|
@@ -109,6 +123,20 @@ dependencies:
|
|
109
123
|
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: thor
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
112
140
|
- !ruby/object:Gem::Dependency
|
113
141
|
name: unicode-display_width
|
114
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,10 +175,13 @@ files:
|
|
147
175
|
- lib/bankscrap.rb
|
148
176
|
- lib/bankscrap/account.rb
|
149
177
|
- lib/bankscrap/bank.rb
|
178
|
+
- lib/bankscrap/card.rb
|
150
179
|
- lib/bankscrap/cli.rb
|
151
180
|
- lib/bankscrap/config.rb
|
152
181
|
- lib/bankscrap/exporters/csv.rb
|
182
|
+
- lib/bankscrap/exporters/json.rb
|
153
183
|
- lib/bankscrap/investment.rb
|
184
|
+
- lib/bankscrap/loan.rb
|
154
185
|
- lib/bankscrap/locale/en.yml
|
155
186
|
- lib/bankscrap/transaction.rb
|
156
187
|
- lib/bankscrap/utils/cli_string.rb
|
@@ -176,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
207
|
version: '0'
|
177
208
|
requirements: []
|
178
209
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.6.14
|
180
211
|
signing_key:
|
181
212
|
specification_version: 4
|
182
213
|
summary: Get your bank account details.
|