vodacom 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/lib/vodacom/client.rb +4 -17
- data/lib/vodacom/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5cd3cea8e229a836f015cc1d7019f426120edaa73e42133bf4486244cdd43f
|
4
|
+
data.tar.gz: 01ebd6ef24494043458022eab9694446096815f0280b02f7de772ad37b389579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ee4f4a5410c737cd3428319ad2487ea43090d128595a5c55dc169cfb63e22446b6158b84572ca2b3efbdf6bd85639ce3e7d16af607cf3f1fa3fbd43ca28d48
|
7
|
+
data.tar.gz: a650496dec3d952323a196b1851dbbc468bb7959ca87a34d051059cfb45746c6c2c2f4291073b3d8c4eb13c0c1b63aa585217272984f79aa94b092a0d669ac55
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,10 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require 'vodacom'
|
26
|
-
client = Vodacom::Client.new(
|
26
|
+
client = Vodacom::Client.new(username: 'your key', password: 'your password from vodacom website')
|
27
|
+
|
28
|
+
phone_number = "27...."
|
29
|
+
client.balance(phone_number)
|
27
30
|
```
|
28
31
|
|
29
32
|
### Endpoints
|
data/lib/vodacom/client.rb
CHANGED
@@ -10,17 +10,8 @@ module Vodacom
|
|
10
10
|
:base_path,
|
11
11
|
:port,
|
12
12
|
:login_response,
|
13
|
-
|
14
|
-
|
15
|
-
# :vopToken,
|
16
|
-
# :vopToken_expiry,
|
17
|
-
# :vod_web_auth_token,
|
18
|
-
# :vod_web_auth_token_expiry,
|
19
|
-
# :jsessionid,
|
20
|
-
# :jsessionid_expiry,
|
21
|
-
# :oauth2_apps_token_db,
|
22
|
-
# :oauth2_apps_token_db_expiry,
|
23
|
-
:raw_cookie
|
13
|
+
:raw_cookie,
|
14
|
+
:expiry
|
24
15
|
|
25
16
|
def initialize(username:, password:, base_path: 'https://www.vodacom.co.za/cloud', port: 80)
|
26
17
|
@username = username
|
@@ -41,7 +32,7 @@ module Vodacom
|
|
41
32
|
def balance(phone_number)
|
42
33
|
start_time = get_micro_second_time
|
43
34
|
|
44
|
-
login unless raw_cookie
|
35
|
+
login unless (raw_cookie && (expiry.to_i > Time.now.to_i))
|
45
36
|
response = HTTParty.send(
|
46
37
|
:get,
|
47
38
|
"#{BALANCE_PATH}#{phone_number}",
|
@@ -80,11 +71,7 @@ module Vodacom
|
|
80
71
|
@login_response = construct_response_object(response, LOGIN_PATH, start_time, end_time)
|
81
72
|
|
82
73
|
@raw_cookie = @login_response.dig("headers").dig("set-cookie")
|
83
|
-
|
84
|
-
# @vopToken, @vopToken_expiry = parse_cookie(raw_cookie, 'vopToken')
|
85
|
-
# @vod_web_auth_token, @vod_web_auth_token_expiry = parse_cookie(raw_cookie, 'vod-web-auth-token')
|
86
|
-
# @jsessionid, @jsessionid_expiry = parse_cookie(raw_cookie, 'JSESSIONID')
|
87
|
-
# @oauth2_apps_token_db, @oauth2_apps_token_db_expiry = parse_cookie(raw_cookie, 'OAuth2AppsTokenDB')
|
74
|
+
_, @expiry = parse_cookie(raw_cookie, 'OAuth2AppsTokenDB')
|
88
75
|
end
|
89
76
|
|
90
77
|
# def authorise_and_send(http_method:, path:, payload: {}, params: {})
|
data/lib/vodacom/version.rb
CHANGED