Class: VpnSdk::Client
- Inherits:
-
Object
- Object
- VpnSdk::Client
- Defined in:
- lib/vpn_sdk.rb
Constant Summary collapse
- BASE_URL =
'https://vpn-gateway-deploy--bxhxbb352.replit.app'.freeze
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #check_health ⇒ Object
- #connect(country_code) ⇒ Object
- #countries ⇒ Object
- #create_session(country_code = nil) ⇒ Object
- #disconnect ⇒ Object
-
#initialize(base_url = BASE_URL, timeout: 10) ⇒ Client
constructor
A new instance of Client.
- #servers(country_code = nil) ⇒ Object
- #status ⇒ Object
Constructor Details
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/vpn_sdk.rb', line 9 def base_url @base_url end |
#timeout ⇒ Object
Returns the value of attribute timeout.
9 10 11 |
# File 'lib/vpn_sdk.rb', line 9 def timeout @timeout end |
Instance Method Details
#check_health ⇒ Object
16 17 18 |
# File 'lib/vpn_sdk.rb', line 16 def check_health get('/api/healthz') end |
#connect(country_code) ⇒ Object
42 43 44 |
# File 'lib/vpn_sdk.rb', line 42 def connect(country_code) post('/api/vpn/connect', { countryCode: country_code }) end |
#countries ⇒ Object
20 21 22 |
# File 'lib/vpn_sdk.rb', line 20 def countries get('/api/vpn/countries') end |
#create_session(country_code = nil) ⇒ Object
37 38 39 40 |
# File 'lib/vpn_sdk.rb', line 37 def create_session(country_code = nil) payload = country_code ? { countryCode: country_code } : {} post('/api/vpn/create', payload) end |
#disconnect ⇒ Object
46 47 48 |
# File 'lib/vpn_sdk.rb', line 46 def disconnect post('/api/vpn/disconnect', {}) end |
#servers(country_code = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/vpn_sdk.rb', line 24 def servers(country_code = nil) path = if country_code && !country_code.to_s.empty? "/api/vpn/servers?countryCode=#{URI.encode_www_form_component(country_code)}" else '/api/vpn/servers' end get(path) end |
#status ⇒ Object
33 34 35 |
# File 'lib/vpn_sdk.rb', line 33 def status get('/api/vpn/status') end |