class Organizer::Request
Attributes
path[RW]
query[RW]
Public Class Methods
new(path = "", query = {})
click to toggle source
# File lib/organizer/request.rb, line 5 def initialize(path = "", query = {}) @path = path @query = query end
Public Instance Methods
delete()
click to toggle source
# File lib/organizer/request.rb, line 33 def delete response = api.delete(path, query) Response.new(response) end
get()
click to toggle source
# File lib/organizer/request.rb, line 10 def get response = api.get(path, query) Response.new(response) end
method_missing(method, *args)
click to toggle source
# File lib/organizer/request.rb, line 38 def method_missing(method, *args) params = args[0].is_a?(Hash) ? args[0] : {} id = params.delete(:id) route = path + "#{method}/#{id}" Request.new(route, params) end
post()
click to toggle source
# File lib/organizer/request.rb, line 15 def post response = api.post do |req| req.url path req.headers['Content-Type'] = 'application/json' req.body = query.to_json end Response.new(response) end
put()
click to toggle source
# File lib/organizer/request.rb, line 24 def put response = api.put do |req| req.url path req.headers['Content-Type'] = 'application/json' req.body = query.to_json end Response.new(response) end
Private Instance Methods
api()
click to toggle source
# File lib/organizer/request.rb, line 46 def api Faraday.new(Config.url_prefix, {params: {token: Config.access_token}}) end