Class: NS1::Transport::NetHttp
- Inherits:
-
Object
- Object
- NS1::Transport::NetHttp
- Defined in:
- lib/ns1/transport/net_http.rb
Instance Method Summary collapse
-
#initialize(base_url, api_key) ⇒ NetHttp
constructor
A new instance of NetHttp.
- #request(method, path, body = nil) ⇒ Object
Constructor Details
#initialize(base_url, api_key) ⇒ NetHttp
Returns a new instance of NetHttp.
13 14 15 16 |
# File 'lib/ns1/transport/net_http.rb', line 13 def initialize(base_url, api_key) @base_url = base_url @api_key = api_key end |
Instance Method Details
#request(method, path, body = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ns1/transport/net_http.rb', line 18 def request(method, path, body = nil) uri = URI.join(@base_url, path) Net::HTTP.start(uri.host, uri.port, opts(uri)) do |http| response = http.send_request(method, uri, body, headers(body)) process_response(response) end end |