Class: Bambora::Rest::JSONClient
- Defined in:
- lib/bambora/rest/json_client.rb
Overview
The base class for making JSON requests.
Constant Summary collapse
- CONTENT_TYPE =
'application/json'
Instance Attribute Summary
Attributes inherited from Client
#base_url, #merchant_id, #sub_merchant_id
Instance Method Summary collapse
-
#delete(path:, api_key:) ⇒ Hash
Make a DELETE Request.
-
#get(path:, api_key:, params: nil) ⇒ Hash
Make a GET Request.
-
#post(path:, body:, api_key:) ⇒ Hash
Make a POST Request.
-
#put(path:, body:, api_key:) ⇒ Hash
Make a PUT Request.
Methods inherited from Client
Constructor Details
This class inherits a constructor from Bambora::Rest::Client
Instance Method Details
#delete(path:, api_key:) ⇒ Hash
Make a DELETE Request.
96 97 98 99 100 |
# File 'lib/bambora/rest/json_client.rb', line 96 def delete(path:, api_key:) parse_response_body( super(path: path, headers: build_headers(api_key: api_key)), ).to_h end |
#get(path:, api_key:, params: nil) ⇒ Hash
Make a GET Request.
33 34 35 36 37 |
# File 'lib/bambora/rest/json_client.rb', line 33 def get(path:, api_key:, params: nil) parse_response_body( super(path: path, params: params, headers: build_headers(api_key: api_key)), ).to_h end |
#post(path:, body:, api_key:) ⇒ Hash
Make a POST Request.
73 74 75 76 77 |
# File 'lib/bambora/rest/json_client.rb', line 73 def post(path:, body:, api_key:) parse_response_body( super(path: path, body: body.to_json.to_s, headers: build_headers(api_key: api_key)), ).to_h end |
#put(path:, body:, api_key:) ⇒ Hash
Make a PUT Request.
145 146 147 148 149 |
# File 'lib/bambora/rest/json_client.rb', line 145 def put(path:, body:, api_key:) parse_response_body( super(path: path, body: body.to_json.to_s, headers: build_headers(api_key: api_key)), ).to_h end |