ba 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -13
- data/lib/ba/banks/bancolombia.rb +67 -29
- data/lib/ba/banks/bank.sample.rb +0 -6
- data/lib/ba/cli.rb +0 -1
- data/lib/ba/version.rb +1 -1
- data/spec/lib/ba/cli_spec.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -19,23 +19,11 @@ And then execute:
|
|
19
19
|
|
20
20
|
$ bundle
|
21
21
|
|
22
|
-
Or install it yourself as:
|
23
|
-
|
24
|
-
$ gem install ba
|
25
|
-
|
26
22
|
## Usage
|
27
23
|
|
28
24
|
### Checkout the different commands by running
|
29
25
|
$ ba
|
30
26
|
|
31
|
-
### Install
|
32
|
-
Run the following command if you don't have any config/config.yml file in your local path
|
33
|
-
|
34
|
-
$ ba install
|
35
|
-
|
36
|
-
### Modify the ~/config/config.yml with your bank info
|
37
|
-
$ vi ~/config/config.yml
|
38
|
-
|
39
27
|
### Run the command for your bank
|
40
28
|
$ ba [BANK] balance
|
41
29
|
|
@@ -49,7 +37,6 @@ Or install it yourself as:
|
|
49
37
|
|
50
38
|
### Adding new Scripts
|
51
39
|
- Follow the bank.sample.rb example
|
52
|
-
- Add the bank to the config/config.sample.yml
|
53
40
|
- Push it!
|
54
41
|
|
55
42
|
## CONTRIBUTORS
|
data/lib/ba/banks/bancolombia.rb
CHANGED
@@ -1,24 +1,40 @@
|
|
1
1
|
module Ba::Banks
|
2
2
|
class Bancolombia < Thor
|
3
3
|
|
4
|
-
desc "balance", "Returns the Bancolombia account balance"
|
5
|
-
def balance
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
desc "balance optional: [username] [password]", "Returns the Bancolombia account balance"
|
5
|
+
def balance(username = nil , password = nil)
|
6
|
+
go_to_root
|
7
|
+
process_username_authentication(username)
|
8
|
+
process_password_authentication(password)
|
9
|
+
page = go_to_authentication_path
|
10
|
+
process_questions(page) if need_to_answer_banks_questions?(page)
|
11
|
+
balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
|
12
|
+
balance = balancePage.search(".contentTotalNegrita").last.children.text
|
13
|
+
puts "Your actual balance is: $#{balance}"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def go_to_authentication_path
|
19
|
+
agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
|
20
|
+
end
|
21
|
+
|
22
|
+
def need_to_answer_banks_questions?(page)
|
23
|
+
!get_question_form(page).nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_question_form(page)
|
27
|
+
@question_form ||= page.form_with(name: "checkChallQuestForm")
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_password_authentication(password)
|
31
|
+
passwordPageHtml = get_password_path.body
|
16
32
|
##Insert \r for correct regex on password scripts
|
17
33
|
passwordPageHtml.gsub!(/document.getElementById/, "\r\n\t document.getElementById")
|
18
34
|
enc_password = ""
|
19
|
-
password = ask("Password: ")
|
35
|
+
password = password || ask("Password: ")
|
20
36
|
password.to_s.split('').each do |n|
|
21
|
-
passwordPageHtml.match(/\'td_#{n}\'\)\.addEventListener\(\'click\'\,\sfunction\(\)\{\S*\(\"(.*)\"\)\;\}/)
|
37
|
+
passwordPageHtml.match(/\'td_#{n}\'\)\.addEventListener\(\'click\'\,\sfunction\(\)\{\S*\(\"(.*)\"\)\;\}/)
|
22
38
|
enc_password << $1
|
23
39
|
end
|
24
40
|
|
@@ -27,31 +43,53 @@ module Ba::Banks
|
|
27
43
|
secretHiddenField = $1
|
28
44
|
|
29
45
|
##Post encripted password and secret hidden field
|
30
|
-
|
46
|
+
form = get_password_path.form_with(name: "authenticationForm") do |f|
|
31
47
|
f.userId = "0"
|
32
48
|
f.password = enc_password
|
33
49
|
f.add_field!(secretHiddenField, value = enc_password)
|
34
|
-
end
|
50
|
+
end
|
35
51
|
|
36
|
-
|
37
|
-
page = agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
|
38
|
-
process_questions(page) if page.forms_with(name: "checkChallQuestForm").any?
|
39
|
-
balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
|
40
|
-
balance = balancePage.search(".contentTotalNegrita").last.children.text
|
41
|
-
puts "Your actual balance is: $#{balance}"
|
52
|
+
form.click_button
|
42
53
|
end
|
43
54
|
|
44
|
-
|
55
|
+
def process_username_authentication(username)
|
56
|
+
form = get_login_path.form_with(name: "authenticationForm") do |f|
|
57
|
+
f.userId = username || ask("Username: ")
|
58
|
+
end
|
45
59
|
|
60
|
+
form.click_button
|
61
|
+
end
|
62
|
+
|
63
|
+
def go_to_root
|
64
|
+
agent.get "https://bancolombia.olb.todo1.com/olb/Init"
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_login_path
|
68
|
+
agent.get "https://bancolombia.olb.todo1.com/olb/Login"
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_password_path
|
72
|
+
@password_path ||= agent.get("https://bancolombia.olb.todo1.com/olb/GetUserProfile")
|
73
|
+
end
|
74
|
+
|
46
75
|
def process_questions(page)
|
47
76
|
puts "The answer for the following questions will not be saved"
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
f.
|
77
|
+
first_question = first_question(page)
|
78
|
+
second_question = second_question(page)
|
79
|
+
|
80
|
+
form = get_question_form(page) do |f|
|
81
|
+
f.userAnswer1 = first_question
|
82
|
+
f.userAnswer2 = secound_question
|
53
83
|
end
|
54
|
-
|
84
|
+
agent.submit(form)
|
85
|
+
end
|
86
|
+
|
87
|
+
def first_question(page)
|
88
|
+
ask(page.search("#luserAnswer1").text.strip)
|
89
|
+
end
|
90
|
+
|
91
|
+
def second_question(page)
|
92
|
+
ask(page.search("#luserAnswer2").text.strip)
|
55
93
|
end
|
56
94
|
|
57
95
|
def agent
|
data/lib/ba/banks/bank.sample.rb
CHANGED
data/lib/ba/cli.rb
CHANGED
data/lib/ba/version.rb
CHANGED
data/spec/lib/ba/cli_spec.rb
CHANGED