Module: Poms::Api::JsonClient
- Defined in:
- lib/poms/api/json_client.rb
Overview
The JsonClient module is a wrapper around the regular Client module. It requests and responses to handle JSON-formatted bodies.
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.freeze
Class Method Summary collapse
Class Method Details
.get(uri, credentials, headers = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/poms/api/json_client.rb', line 15 def get(uri, credentials, headers = {}) response = Client.get( uri, credentials, DEFAULT_HEADERS.merge(headers) ) JSON.parse(response.body) end |
.post(uri, body, credentials, headers = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/poms/api/json_client.rb', line 24 def post(uri, body, credentials, headers = {}) response = Client.post( uri, body.to_json, credentials, DEFAULT_HEADERS.merge(headers) ) JSON.parse(response.body) end |