lita-chilean-bip 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/lib/lita/handlers/chilean_bip.rb +5 -11
- data/lita-chilean-bip.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881687b6571a7531f9c15f031a4b05fb0d64edbc
|
4
|
+
data.tar.gz: 6a8a4707e3804ac5806d228e754c12d662af8e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee19161a594ea48ff97080719430a0a6bd0e1240d324af41bea3be04b25e35dc1e0a9902f8782e6d6694057c7090dc221f46d5eb473e9b0cd59addbf621b7c49
|
7
|
+
data.tar.gz: 1c651cfe9e4505a230ff0d724459eb03f97d05b79fdaf62c12081b491e1e99c7d9aaad5acbd66989beca86bc87f97becd63626525ae55edaa1915836f7de4eda
|
data/README.md
CHANGED
@@ -18,17 +18,22 @@ gem "lita-chilean-bip"
|
|
18
18
|
|
19
19
|
To check your balance:
|
20
20
|
```
|
21
|
-
|
21
|
+
You: Lita, bip 12345678
|
22
|
+
Lita: ..and your balance is: $10.000 (until 22/03/2014)
|
22
23
|
```
|
23
24
|
|
24
25
|
Also you can store your number for future requests:
|
25
26
|
|
26
27
|
```
|
27
|
-
|
28
|
+
You: Lita, my bip is 12345678
|
29
|
+
Lita: Yay! I'll remember it for later.
|
28
30
|
```
|
29
|
-
|
31
|
+
|
32
|
+
and at any time...
|
33
|
+
|
30
34
|
```
|
31
|
-
|
35
|
+
You: Lita, bip
|
36
|
+
Lita: ..and your balance is: $10.000 (until 22/03/2014)
|
32
37
|
```
|
33
38
|
|
34
39
|
Requests are case-insensitive
|
@@ -5,7 +5,7 @@ module Lita
|
|
5
5
|
class ChileanBip < Handler
|
6
6
|
|
7
7
|
REDIS_KEY = 'lita-chilean-bip'
|
8
|
-
QUERY_URL = 'http://saldobip.com'
|
8
|
+
QUERY_URL = 'http://saldobip.com/'
|
9
9
|
PARSE_SELECTOR = '#resultados #datos strong'
|
10
10
|
POST_HEADERS = {
|
11
11
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
@@ -15,9 +15,9 @@ module Lita
|
|
15
15
|
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36'
|
16
16
|
}
|
17
17
|
|
18
|
-
route %r{^bip\s*(\d+)}i, :bip_balance, help: { 'bip ...' => 'gets the balance for BIP card ...' }
|
19
|
-
route %r{^my bip is (\d+)}i, :store_bip, help: { 'my bip is ...' => "stores the user's BIP card ..." }
|
20
|
-
route %r{^bip}i, :stored_bip_balance, help: { 'bip' => "gets the balance for stored user's BIP card" }
|
18
|
+
route %r{^bip\s*(\d+)$}i, :bip_balance, help: { 'bip ...' => 'gets the balance for BIP card ...' }
|
19
|
+
route %r{^my bip is (\d+)$}i, :store_bip, help: { 'my bip is ...' => "stores the user's BIP card ..." }
|
20
|
+
route %r{^bip$}i, :stored_bip_balance, help: { 'bip' => "gets the balance for stored user's BIP card" }
|
21
21
|
|
22
22
|
def bip_balance(response)
|
23
23
|
card_number = card_number_from_response(response)
|
@@ -61,13 +61,7 @@ module Lita
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def post_query_for_card(card_number)
|
64
|
-
|
65
|
-
faraday.request :url_encoded # form-encode POST params
|
66
|
-
faraday.response :logger # log requests to STDOUT
|
67
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
68
|
-
end
|
69
|
-
response = conn.post '/', { NumTarjeta: card_number, pedirSaldo: '' }, POST_HEADERS
|
70
|
-
response.body
|
64
|
+
http.post(QUERY_URL, { NumTarjeta: card_number, pedirSaldo: '' }, POST_HEADERS).body
|
71
65
|
end
|
72
66
|
|
73
67
|
def parse_data_from_html(response)
|
data/lita-chilean-bip.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-chilean-bip'
|
3
|
-
spec.version = '1.1.
|
3
|
+
spec.version = '1.1.2'
|
4
4
|
spec.authors = ['Emilio Figueroa']
|
5
5
|
spec.email = ['emiliofigueroatorres@gmail.com']
|
6
6
|
spec.description = %q{A Lita handler for checking the BIP card balance}
|