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.
-
#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.
25 26 27 28 29 30 |
# File 'lib/vodacom/client.rb', line 25 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 |
#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 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
37 38 39 |
# File 'lib/vodacom/client.rb', line 37 def self.api_version 'v3 2021-03-13' end |
.compatible_api_version ⇒ Object
32 33 34 |
# File 'lib/vodacom/client.rb', line 32 def self.compatible_api_version 'v3' end |
Instance Method Details
#balance(phone_number) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vodacom/client.rb', line 41 def balance(phone_number) start_time = get_micro_second_time login unless 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 |