module Skittles::Request
Public Instance Methods
delete(path, options = {}, headers = {}, raw = false)
click to toggle source
Performs an HTTP DELETE request
# File lib/skittles/request.rb, line 23 def delete(path, options = {}, headers = {}, raw = false) request(:delete, path, options, headers, raw) end
get(path, options = {}, headers = {}, raw = false)
click to toggle source
Perform an HTTP GET request
# File lib/skittles/request.rb, line 8 def get(path, options = {}, headers = {}, raw = false) request(:get, path, options, headers, raw) end
post(path, options = {}, headers = {}, raw = false)
click to toggle source
Performs an HTTP POST request
# File lib/skittles/request.rb, line 13 def post(path, options = {}, headers = {}, raw = false) request(:post, path, options, headers, raw) end
put(path, options = {}, headers = {}, raw = false)
click to toggle source
Performs an HTTP PUT request
# File lib/skittles/request.rb, line 18 def put(path, options = {}, headers = {}, raw = false) request(:put, path, options, headers, raw) end
Private Instance Methods
paramify(path, params)
click to toggle source
Encode path and turn params into HTTP query.
# File lib/skittles/request.rb, line 59 def paramify(path, params) URI.encode("#{path}?#{params.map { |k,v| "#{k}=#{v}" }.join('&')}") end
request(method, path, options, headers, raw)
click to toggle source
Perform an HTTP request
# File lib/skittles/request.rb, line 29 def request(method, path, options, headers, raw) headers.merge!({ 'User-Agent' => user_agent }) options.merge!({ :client_id => client_id, :client_secret => client_secret }) options.merge!({ :v => Time.now.strftime('%Y%m%d') }) begin response = connection.request(method, paramify(path, options), headers) rescue OAuth2::Error => e Skittles::Utils.handle_foursquare_error(e.response) else Skittles::Error end unless raw result = Skittles::Utils.parse_json(response.body) end raw ? response : result.response end