Class: Kookaburra::APIDriver
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Kookaburra::APIDriver
- Defined in:
- lib/kookaburra/api_driver.rb
Instance Method Summary collapse
-
#delete(path, options = {}) ⇒ Object
Makes a DELETE request via the
:http_client
. -
#get(path, options = {}) ⇒ Object
Makes a GET request via the
:http_client
. -
#initialize(configuration, http_client = Patron::Session.new) ⇒ APIDriver
constructor
Wraps
http_client
in aSimpleDelegator
that causes request methods to either return the response body or raise an exception on an unexpected response status code. -
#post(path, data, options = {}) ⇒ Object
Makes a POST request via the
:http_client
. -
#put(path, data, options = {}) ⇒ Object
Makes a PUT request via the
:http_client
.
Constructor Details
#initialize(configuration, http_client = Patron::Session.new) ⇒ APIDriver
Wraps http_client
in a SimpleDelegator
that causes request methods to
either return the response body or raise an exception on an unexpected
response status code.
13 14 15 16 |
# File 'lib/kookaburra/api_driver.rb', line 13 def initialize(configuration, http_client = Patron::Session.new) http_client.base_url = configuration.app_host super(http_client) end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
Makes a DELETE request via the :http_client
62 63 64 |
# File 'lib/kookaburra/api_driver.rb', line 62 def delete(path, = {}) request(:delete, path, ) end |
#get(path, options = {}) ⇒ Object
Makes a GET request via the :http_client
51 52 53 |
# File 'lib/kookaburra/api_driver.rb', line 51 def get(path, = {}) request(:get, path, ) end |
#post(path, data, options = {}) ⇒ Object
Makes a POST request via the :http_client
27 28 29 |
# File 'lib/kookaburra/api_driver.rb', line 27 def post(path, data, = {}) request(:post, path, , data) end |
#put(path, data, options = {}) ⇒ Object
Makes a PUT request via the :http_client
40 41 42 |
# File 'lib/kookaburra/api_driver.rb', line 40 def put(path, data, = {}) request(:put, path, , data) end |