Method: APISmith::Client::InstanceMethods#request!
- Defined in:
- lib/api_smith/client.rb
#request!(method, path, options, *param_types) ⇒ Object
Performs a HTTP request using HTTParty, using a set of expanded options built up by the current client.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/api_smith/client.rb', line 103 def request!(method, path, , *param_types) # Merge in the default request options, e.g. those to be passed to HTTParty raw = (:request, ) # Exapdn the path out into a full version when the endpoint is present. full_path = [:skip_endpoint] ? path : path_for(path) # For each of the given param_types (e.g. :query, :body) will automatically # merge in the options for the current request. param_types.each do |type| [type] = (type, ) end # Finally, use HTTParty to get the response response = instrument_request method, full_path, do self.class.send method, full_path, end # Pre-process the response to check for errors. check_response_errors response # Unpack the response using the :response_container option inner_response = extract_response path, response, # Finally, apply any transformations transform_response inner_response, end |