module RandomApi::Request
Defines HTTP request methods
Public Instance Methods
delete(path, options={}, raw=false)
click to toggle source
Perform an HTTP DELETE request
# File lib/randomapi/request.rb, line 22 def delete(path, options={}, raw=false) make_request(:delete, path, options, raw) end
get(path, options={}, raw=false)
click to toggle source
Perform an HTTP GET request
# File lib/randomapi/request.rb, line 7 def get(path, options={}, raw=false) make_request(:get, path, options, raw) end
post(path, options={}, raw=false)
click to toggle source
Perform an HTTP POST request
# File lib/randomapi/request.rb, line 12 def post(path, options={}, raw=false) make_request(:post, path, options, raw) end
put(path, options={}, raw=false)
click to toggle source
Perform an HTTP PUT request
# File lib/randomapi/request.rb, line 17 def put(path, options={}, raw=false) make_request(:put, path, options, raw) end
Private Instance Methods
make_request(method, path, options, raw=false)
click to toggle source
Perform an HTTP request
# File lib/randomapi/request.rb, line 29 def make_request(method, path, options, raw=false) options.merge!({:key => api_key, :id => api_id }) response = connection(raw).send(method) do |request| case method when :get, :delete request.url(path, options) when :post, :put request.path = path request.body = options unless options.empty? end end return response if raw return response.body end