Class: Kipalog::APIClient
- Inherits:
-
Object
- Object
- Kipalog::APIClient
- Defined in:
- lib/kipalog/api_client.rb
Constant Summary collapse
- BASE_URI =
'kipalog.com/api/v1'.freeze
- X_KIPALOG_TOKEN =
'X-Kipalog-Token'.freeze
- ACCEPT_CHARSET =
'Accept-Charset'
- DEFAULT_CHARSET =
'application/json'
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(config = Kipalog.config) ⇒ APIClient
constructor
A new instance of APIClient.
- #post(path, request_body) ⇒ Object
- #send_request(method, path, body_hash = {}) ⇒ Object
Constructor Details
Instance Method Details
#get(path) ⇒ Object
15 16 17 |
# File 'lib/kipalog/api_client.rb', line 15 def get(path) send_request(:get, path) end |
#post(path, request_body) ⇒ Object
19 20 21 |
# File 'lib/kipalog/api_client.rb', line 19 def post(path, request_body) send_request(:post, path, request_body) end |
#send_request(method, path, body_hash = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kipalog/api_client.rb', line 23 def send_request(method, path, body_hash = {}) _make_request(method, path, body_hash) do |result| response = Kipalog::Response.new( result.code, result.headers, result.parsed_response ) if response.ok? response else raise RequestError, response.body end end end |