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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 616e8f37264023776722f3257b0a3f2f0fb81c44ac7be438e4b1696944e55bbf
4
- data.tar.gz: 622956d5c44f8212bad1e9f8c9e082708373e9b45884701403c39bdfa4c754ff
3
+ metadata.gz: 7d5cd3cea8e229a836f015cc1d7019f426120edaa73e42133bf4486244cdd43f
4
+ data.tar.gz: 01ebd6ef24494043458022eab9694446096815f0280b02f7de772ad37b389579
5
5
  SHA512:
6
- metadata.gz: 937f6afefe92045f0483fa7a678a8f53ae9033cf3a9da1e25991a6cab361ff619e5cb0224f0758a426889406926f52fd86f2107741db9c3624581096cafd17a8
7
- data.tar.gz: 0a6bff1375032eb927764f2907e184ff9a3545d677c7628a219dde7957b0e0156b2ff59e474226f6e54a0073a4912f9966a01930bf4e3f5f153a026513e80bd5
6
+ metadata.gz: 34ee4f4a5410c737cd3428319ad2487ea43090d128595a5c55dc169cfb63e22446b6158b84572ca2b3efbdf6bd85639ce3e7d16af607cf3f1fa3fbd43ca28d48
7
+ data.tar.gz: a650496dec3d952323a196b1851dbbc468bb7959ca87a34d051059cfb45746c6c2c2f4291073b3d8c4eb13c0c1b63aa585217272984f79aa94b092a0d669ac55
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vodacom (0.0.1)
4
+ vodacom (0.0.2)
5
5
  active_attr (~> 0.15)
6
6
  httparty (~> 0.18)
7
7
  nokogiri (~> 1.11.2)
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(key: 'your key', secret: 'your secret')
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
@@ -10,17 +10,8 @@ module Vodacom
10
10
  :base_path,
11
11
  :port,
12
12
  :login_response,
13
- # :gateway_session,
14
- # :gateway_session_expiry,
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
- # @gateway_session, _ = parse_cookie(raw_cookie, 'gatewaysession')
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: {})
@@ -1,3 +1,3 @@
1
1
  module Vodacom
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vodacom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22