Class: EPC::Client::JsonClient
- Inherits:
-
HttpClient
- Object
- BaseClient
- HttpClient
- EPC::Client::JsonClient
- Defined in:
- lib/epc/client/json_client.rb
Instance Method Summary collapse
- #delete(url, payload = {}) ⇒ Object
- #get(url, skip_signature = false) ⇒ Object
- #post(url, payload = {}, skip_signature = false) ⇒ Object
- #put(url, payload = {}) ⇒ Object
Methods inherited from BaseClient
Constructor Details
This class inherits a constructor from EPC::Client::BaseClient
Instance Method Details
#delete(url, payload = {}) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/epc/client/json_client.rb', line 33 def delete(url, payload = {}) begin status, body, headers = super(url, payload.to_json, 'application/json') [status, json_parse(body), headers] rescue JSON::ParserError raise BadResponse, "Can't parse response into JSON", body end end |
#get(url, skip_signature = false) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/epc/client/json_client.rb', line 6 def get(url, skip_signature = false) begin status, body, headers = super(url, 'application/json', skip_signature) [status, json_parse(body), headers] rescue JSON::ParserError raise BadResponse, "Can't parse response into JSON", body end end |
#post(url, payload = {}, skip_signature = false) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/epc/client/json_client.rb', line 15 def post(url, payload = {}, skip_signature = false) begin status, body, headers = super(url, payload.to_json, 'application/json', {}, skip_signature) [status, json_parse(body), headers] rescue JSON::ParserError raise BadResponse, "Can't parse response into JSON", body end end |
#put(url, payload = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/epc/client/json_client.rb', line 24 def put(url, payload = {}) begin status, body, headers = super(url, payload.to_json, 'application/json') [status, json_parse(body), headers] rescue JSON::ParserError raise BadResponse, "Can't parse response into JSON", body end end |