bank_scrap 0.0.4 → 0.0.5

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: 33d61fafde1f7ffbfc87e7da3171fd063aecbaa8
4
- data.tar.gz: 15c312c337ba38ff1976cf1a9da9ffbe7d6a1458
3
+ metadata.gz: 7e07ddabb163c0283055e9b48996e8a03bff8db6
4
+ data.tar.gz: d0bc91897c4c607e61de130ca32ac10118140283
5
5
  SHA512:
6
- metadata.gz: 034b2b526bc7abf50eaaf669e823696842037e4910cd6242ebac9f4e635d6c90053f693aa1d0f7db4df5677db31fb9d52fb7a64983a19d95656623b8259d151c
7
- data.tar.gz: 9208005841d935817596cd9d9c6421ade12fd64aed9f0eb30a7e5056eac803998c5bc7f1c0e1d16e557e104ea85eb8ca598fa57d77af5fe60b7f0aa38e0cd410
6
+ metadata.gz: 67cd5e951a7701884e44fc40990b9f7d17afdc84e0928c496f7789b057b9c09a27667452dc364b5f96e575e943c6db4bcdb8ff01d78a154933551de3ee5063d6
7
+ data.tar.gz: 086880bb1048f771821aa16e63620e6c509e4574dd5aac83e497ce8066aeaba76f796d99f133991c2b5c0eadb2436b691a4a888eacd356c62ff720a5940405af
@@ -7,7 +7,7 @@ module BankScrap
7
7
  BASE_ENDPOINT = "https://movil.bankinter.es"
8
8
  LOGIN_ENDPOINT = "/mov/es-es/cgi/ebkmovil+md+login"
9
9
 
10
- def initialize(user, password, log: false, debug: false)
10
+ def initialize(user, password, log: false, debug: false, extra_args: nil)
11
11
  @user = user
12
12
  @password = password
13
13
  @log = log
@@ -7,7 +7,7 @@ module BankScrap
7
7
  BALANCE_ENDPOINT = '/ENPP/enpp_mult_web_mobility_02/products/v1'
8
8
  USER_AGENT = 'Android;LGE;Nexus 5;1080x1776;Android;4.4.4;BMES;4.0.4'
9
9
 
10
- def initialize(user, password, log: false, debug: false)
10
+ def initialize(user, password, log: false, debug: false, extra_args: nil)
11
11
  @user = format_user(user.dup)
12
12
  @password = password
13
13
  @log = log
@@ -3,48 +3,55 @@ require 'active_support/core_ext/string'
3
3
 
4
4
  module BankScrap
5
5
  class Cli < Thor
6
+ def self.shared_options
7
+ option :user, default: ENV['BANK_SCRAP_USER']
8
+ option :password, default: ENV['BANK_SCRAP_PASSWORD']
9
+ option :log, default: false
10
+ option :debug, default: false
11
+
12
+ # Some bank needs more input, like birthday, this would go here
13
+ # Usage:
14
+ # bank_scrap balance BANK_NAME --extra=birthday:01/12/1980
15
+ option :extra, type: :hash
16
+ end
6
17
 
7
18
  desc "balance BANK", "get account's balance"
8
- option :user, default: ENV['BANK_SCRAP_USER']
9
- option :password, default: ENV['BANK_SCRAP_PASSWORD']
10
- option :log, default: false
11
- option :debug, default: false
19
+ shared_options
12
20
  def balance(bank)
13
- @user = options[:user]
14
- @password = options[:password]
15
- @log = options[:log]
16
- @debug = options[:debug]
17
-
18
- bank_class = find_bank_class_for(bank)
19
- @client = bank_class.new(@user, @password, log: @log, debug: @debug)
21
+ assign_shared_options
22
+ initialize_client_for(bank)
20
23
 
21
- balance = @client.get_balance
22
- puts "Balance: #{balance}"
24
+ say "Balance: #{@client.get_balance}", :green
23
25
  end
24
26
 
25
27
  desc "transactions BANK", "get account's transactions"
26
- option :user, default: ENV['BANK_SCRAP_USER']
27
- option :password, default: ENV['BANK_SCRAP_PASSWORD']
28
- option :log, default: false
29
- option :debug, default: false
28
+ shared_options
30
29
  def transactions(bank)
31
- @user = options[:user]
32
- @password = options[:password]
33
- @log = options[:log]
34
- @debug = options[:debug]
35
-
36
- bank_class = find_bank_class_for(bank)
37
- @client = bank_class.new(@user, @password, log: @log, debug: @debug)
38
-
30
+ assign_shared_options
31
+ initialize_client_for(bank)
39
32
  transactions = @client.get_transactions
40
33
  end
41
34
 
42
35
  private
36
+
37
+ def assign_shared_options
38
+ @user = options[:user]
39
+ @password = options[:password]
40
+ @log = options[:log]
41
+ @debug = options[:debug]
42
+ @extra_args = options[:extra]
43
+ end
44
+
45
+ def initialize_client_for(bank_name)
46
+ bank_class = find_bank_class_for(bank_name)
47
+ @client = bank_class.new(@user, @password, log: @log, debug: @debug, extra_args: @extra_args)
48
+ end
43
49
 
44
50
  def find_bank_class_for(bank_name)
45
51
  Object.const_get("BankScrap::" + bank_name.classify)
46
52
  rescue NameError
47
53
  raise ArgumentError.new('Invalid bank name')
48
54
  end
55
+
49
56
  end
50
57
  end
@@ -1,3 +1,3 @@
1
1
  module BankScrap
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Sánchez
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-11-02 00:00:00.000000000 Z
14
+ date: 2014-11-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler