class HttpApiBuilder::BaseClient
A basic HTTP client. Meant to be extended from.
Public Class Methods
new()
click to toggle source
# File lib/http_api_builder.rb, line 11 def initialize(); end
Public Instance Methods
perform(method, path, form: nil, query: nil, body: nil, json: nil) { |response, status, resource| ... }
click to toggle source
Perform the request, post processors, and return the result
# 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 url = build_url(path) response = request(method, url, form: form, query: query, body: body, json: json) status = response.status resource = response.body block_given? ? yield(response, status, resource) : response end
request(*)
click to toggle source
Placeholder for your request method. Accepts these params, for you to do whatever you like with. See the HTTPrb_client implementation
@param [Symbol] method The HTTP VERB to use @param [URI] uri The url to make the request to @param [Hash] form: nil Form data, for encoding into HTTP form encoding @param [Hash] query: nil Query key/value pairs @param [String] body: nil A raw body @param [Hash, Array] json: nil Hash/Array data to be encoded as JSON.
# File lib/http_api_builder.rb, line 31 def request(*) raise 'HttpApiBuilder::BaseClient#request must be implemented, see documentation' end