Class: AtlanticNet::HttpTransport
- Inherits:
-
Object
- Object
- AtlanticNet::HttpTransport
- Defined in:
- lib/atlantic_net.rb
Constant Summary collapse
- API_URI =
"https://cloudapi.atlantic.net"
Instance Method Summary collapse
-
#send_request(data) ⇒ Object
Sends the request to the API endpoint.
Instance Method Details
#send_request(data) ⇒ Object
Sends the request to the API endpoint
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/atlantic_net.rb', line 30 def send_request (data) uri = URI.parse(API_URI) uri.query = URI.encode_www_form(data) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true response = http.get(uri.request_uri) unless response.code.to_i == 200 fail AtlanticNetException.new(nil, {}, "The Atlantic.net api endpoint was unexpectedly unavailable. The HTTP Status code was #{response.code}") end JSON.parse(response.body) end |