Class: Vodacom::Client
- Inherits:
-
Object
- Object
- Vodacom::Client
- Defined in:
- lib/vodacom/client.rb
Constant Summary collapse
- LOGIN_PATH =
include HTTParty_with_cookies
'https://www.vodacom.co.za/cloud/login/v3/login'
- BALANCE_PATH =
'https://www.vodacom.co.za/cloud/rest/balances/v3/bundle/balances/'
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#expiry ⇒ Object
readonly
Returns the value of attribute expiry.
-
#login_response ⇒ Object
readonly
Returns the value of attribute login_response.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#raw_cookie ⇒ Object
readonly
Returns the value of attribute raw_cookie.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.api_version ⇒ Object
This is the version of the API docs this client was built off-of.
- .compatible_api_version ⇒ Object
Instance Method Summary collapse
- #balance(phone_number) ⇒ Object
-
#initialize(username:, password:, base_path: 'https://www.vodacom.co.za/cloud', port: 80) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(username:, password:, base_path: 'https://www.vodacom.co.za/cloud', port: 80) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 |
# File 'lib/vodacom/client.rb', line 16 def initialize(username:, password:, base_path: 'https://www.vodacom.co.za/cloud', port: 80) @username = username @password = password @base_path = base_path @port = port end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def base_path @base_path end |
#expiry ⇒ Object (readonly)
Returns the value of attribute expiry.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def expiry @expiry end |
#login_response ⇒ Object (readonly)
Returns the value of attribute login_response.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def login_response @login_response end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def port @port end |
#raw_cookie ⇒ Object (readonly)
Returns the value of attribute raw_cookie.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def @raw_cookie end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/vodacom/client.rb', line 8 def username @username end |
Class Method Details
.api_version ⇒ Object
This is the version of the API docs this client was built off-of
28 29 30 |
# File 'lib/vodacom/client.rb', line 28 def self.api_version 'v3 2021-03-13' end |
.compatible_api_version ⇒ Object
23 24 25 |
# File 'lib/vodacom/client.rb', line 23 def self.compatible_api_version 'v3' end |
Instance Method Details
#balance(phone_number) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vodacom/client.rb', line 32 def balance(phone_number) start_time = get_micro_second_time login unless ( && (expiry.to_i > Time.now.to_i)) response = HTTParty.send( :get, "#{BALANCE_PATH}#{phone_number}", headers: { 'Content-Type': 'application/json', 'Accept': '*/*', 'Cookie': }, port: port ) end_time = get_micro_second_time construct_response_object(response, BALANCE_PATH, start_time, end_time) end |