Class: Infreemation::API
- Inherits:
-
Object
- Object
- Infreemation::API
- Defined in:
- lib/infreemation/api.rb
Overview
This class is responsible for communicating with the remote API server
Class Method Summary collapse
-
.get(path, params) ⇒ Object
The #get method is doing a POST request.
- .post(path, body) ⇒ Object
Class Method Details
.get(path, params) ⇒ Object
The #get method is doing a POST request. This is because the Infreemation API is expecting raw POST data and the Ruby net/http core library understandably does not support this.
15 16 17 18 19 20 |
# File 'lib/infreemation/api.rb', line 15 def get(path, params) Infreemation.log :debug, "GET #{path} with #{params.inspect}" resource[path].post(with_auth(params), &parser) rescue RestClient::Exception => e raise RequestError, e. end |
.post(path, body) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/infreemation/api.rb', line 22 def post(path, body) Infreemation.log :debug, "POST #{path} with #{body.inspect}" resource[path].post(with_auth(body), &parser) rescue RestClient::Exception => e raise RequestError, e. end |