class Giftrocket::Request
Public Class Methods
delete(path, *opts)
click to toggle source
# File lib/giftrocket/request.rb, line 12 def self.delete(path, *opts) handle_response(HTTParty.delete(url(path), *opts)) end
get(path, *opts)
click to toggle source
# File lib/giftrocket/request.rb, line 3 def self.get(path, *opts) handle_response(HTTParty.get(url(path), *opts)) end
handle_response(response)
click to toggle source
# File lib/giftrocket/request.rb, line 19 def self.handle_response(response) if response.success? response_json = JSON.parse(response.body).with_indifferent_access else raise Giftrocket::Error.new(response) end end
post(path, *opts)
click to toggle source
# File lib/giftrocket/request.rb, line 6 def self.post(path, *opts) handle_response(HTTParty.post(url(path), *opts)) end
put(path, *opts)
click to toggle source
# File lib/giftrocket/request.rb, line 9 def self.put(path, *opts) handle_response(HTTParty.put(url(path), *opts)) end
url(path, params={})
click to toggle source
# File lib/giftrocket/request.rb, line 15 def self.url(path, params={}) url = URI.join(Giftrocket.config[:base_api_uri], path) end