bank_scrap 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 011bc3352dbc67fd3346b8214de8761910772cb7
4
- data.tar.gz: 839d98e70e9755a1d8032e789f587655f7a52d55
3
+ metadata.gz: dd004b30d6dd4eb2d705fcbe0affc0579d104a37
4
+ data.tar.gz: f47e2c334a704fe27b256548fab622723dc429dd
5
5
  SHA512:
6
- metadata.gz: 3ed3e531ad452268c55e95cfb3c8dd0eaa7bc4b9c46ad884f4f2a16a1e0bca5edeafb1d02337864dd85b2d240cfe893b9252f7bc0a92177b61eeedcb845a3dfe
7
- data.tar.gz: 844bc92e681e981f6cede4963c1b64a0ffab36e3702fddf06fadd63c0c3e758fe61c85c4a671ee62afe4b140e1fdc756cebad0b1456820d057cc7ff6cb4e3973
6
+ metadata.gz: 9d6370a6ae37fb00162023fe6e500fa550f98ef49e1d6f58c4bf96a8b569b124a906dbed8837c669af3ba5224e216c97b2d60b67d5f7d6bb83fafd14acfc6356
7
+ data.tar.gz: 171fef5e6ca580034f30f8c5e15007b817ef72c3d76ce318c829f6dd1c38ac1593d256ef77406115fb98ba296c3e694e1817616ccf773e3e89295cbd7c8bf015
data/README.md CHANGED
@@ -74,6 +74,10 @@ Replace 01/01/1980 with your actual birthday.
74
74
 
75
75
  $ bank_scrap transactions ing --user YOUR_DNI --password YOUR_PASSWORD --extra=birthday:01/01/1980
76
76
 
77
+ #### Transactions with date range
78
+
79
+ $ bank_scrap transactions your_bank --user YOUR_BANK_USER --password YOUR_BANK_PASSWORD --extra=from:01-01-2015 to:01-02-2015
80
+
77
81
  ---
78
82
 
79
83
  By default it will use your first bank account, if you want to fetch transactions for a different account you can use this syntax:
@@ -12,7 +12,7 @@ module BankScrap
12
12
  # Some bank needs more input, like birthday, this would go here
13
13
  # Usage:
14
14
  # bank_scrap balance BANK_NAME --extra=birthday:01/12/1980
15
- option :extra, type: :hash
15
+ option :extra, type: :hash, default: {}
16
16
  end
17
17
 
18
18
  desc "balance BANK", "get accounts' balance"
@@ -31,9 +31,29 @@ module BankScrap
31
31
  shared_options
32
32
  def transactions(bank, iban = nil)
33
33
  assign_shared_options
34
+
35
+ begin
36
+ start_date = @extra_args.has_key?('from') ? Date.strptime(@extra_args['from'],'%d-%m-%Y') : nil
37
+ end_date = @extra_args.has_key?('to') ? Date.strptime(@extra_args['to'],'%d-%m-%Y') : nil
38
+ rescue ArgumentError
39
+ say "Invalid date format. Correct format d-m-Y", :red
40
+ end
41
+
34
42
  initialize_client_for(bank)
43
+
35
44
  account = iban ? @client.account_with_iban(iban) : @client.accounts.first
36
- transactions = account.transactions
45
+
46
+ if (!start_date.nil? && !end_date.nil?)
47
+ if (start_date > end_date)
48
+ say "From date must be lower than to date", :red
49
+ exit
50
+ end
51
+
52
+ transactions = account.fetch_transactions(start_date:start_date, end_date:end_date)
53
+ else
54
+ transactions = account.transactions
55
+ end
56
+
37
57
  say "Transactions for: #{account.description} (#{account.iban})", :cyan
38
58
 
39
59
  transactions.each do |transaction|
@@ -1,3 +1,3 @@
1
1
  module BankScrap
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bank_scrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Sánchez