Class: HttpApiBuilder::BaseClient
- Inherits:
-
Object
- Object
- HttpApiBuilder::BaseClient
- Extended by:
- Dsl
- Includes:
- Helpers
- Defined in:
- lib/http_api_builder.rb
Overview
A basic HTTP client. Meant to be extended from.
Constant Summary
Constants included from Dsl
Instance Method Summary collapse
-
#initialize ⇒ BaseClient
constructor
A new instance of BaseClient.
-
#perform(method, path, form: nil, query: nil, body: nil, json: nil, &_block) ⇒ Object
Perform the request, post processors, and return the result.
-
#request ⇒ Object
Placeholder for your request method.
Methods included from Dsl
Constructor Details
#initialize ⇒ BaseClient
Returns a new instance of BaseClient.
11 |
# File 'lib/http_api_builder.rb', line 11 def initialize(); end |
Instance Method Details
#perform(method, path, form: nil, query: nil, body: nil, json: nil, &_block) ⇒ Object
Perform the request, post processors, and return the result
14 15 16 17 18 19 |
# File 'lib/http_api_builder.rb', line 14 def perform(method, path, form: nil, query: nil, body: nil, json: nil, &_block) # rubocop:disable Metrics/ParameterLists response = request(method, path, form: form, query: query, body: body, json: json) status = response.status resource = response.body block_given? ? yield(resource, status, response) : resource end |
#request ⇒ Object
Placeholder for your request method. Accepts these params, for you to do whatever you like with. See the HTTPrb_client implementation
30 31 32 |
# File 'lib/http_api_builder.rb', line 30 def request(*) raise 'HttpApiBuilder::BaseClient#request must be implemented, see documentation' end |