Class: ForestLiana::ForestApiRequester
- Inherits:
-
Object
- Object
- ForestLiana::ForestApiRequester
- Defined in:
- app/services/forest_liana/forest_api_requester.rb
Class Method Summary collapse
- .get(route, query: nil, headers: {}) ⇒ Object
- .post(route, body: nil, query: nil, headers: {}) ⇒ Object
Class Method Details
.get(route, query: nil, headers: {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/services/forest_liana/forest_api_requester.rb', line 5 def self.get(route, query: nil, headers: {}) begin HTTParty.get("#{forest_api_url}#{route}", { headers: base_headers.merge(headers), query: query, }).response rescue raise 'Cannot reach Forest API, it seems to be down right now.' end end |
.post(route, body: nil, query: nil, headers: {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/forest_liana/forest_api_requester.rb', line 16 def self.post(route, body: nil, query: nil, headers: {}) begin HTTParty.post("#{forest_api_url}#{route}", { headers: base_headers.merge(headers), query: query, body: body.to_json, }).response rescue raise 'Cannot reach Forest API, it seems to be down right now.' end end |