Class: Internode::Client
- Inherits:
-
Object
- Object
- Internode::Client
- Defined in:
- lib/internode/client.rb
Defined Under Namespace
Classes: ServerError
Constant Summary collapse
- URL =
"https://customer-webtools-api.internode.on.net"
Instance Method Summary collapse
- #get(path, *args) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 |
# File 'lib/internode/client.rb', line 10 def initialize( = {}) username = .fetch(:username){ ENV["INTERNODE_USERNAME"] } password = .fetch(:password){ ENV["INTERNODE_PASSWORD"] } @url = .fetch(:url){ URL } @client = HTTPClient.new @client.set_auth(@url, username, password) @client. = nil end |
Instance Method Details
#get(path, *args) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/internode/client.rb', line 19 def get(path, *args) url = "#{@url}#{path}" content = @client.get_content(url) Oga.parse_xml(content).at_css("internode api") rescue HTTPClient::BadResponseError => err raise ServerError.new("#{err.res.status_code} #{err.res.reason}") end |