module Github::Request
def request(method, path, params) # :nodoc:
Returns a Github::ResponseWrapper
params - ParamsHash to configure the request API
path - String relative URL to access
method - The Symbol the HTTP verb
Performs a request
def request(method, path, params) # :nodoc: unless METHODS.include?(method) raise ArgumentError, "unkown http method: #{method}" end puts "EXECUTED: #{method} - #{path} with PARAMS: #{params}" if ENV['DEBUG'] request_options = params.options connection_options = current_options.merge(request_options) conn = connection(connection_options) if conn.path_prefix != '/' && path.index(conn.path_prefix) != 0 path = (conn.path_prefix + path).gsub(/\/(\/)*/, '/') end response = conn.send(method) do |request| case method.to_sym when *(METHODS - METHODS_WITH_BODIES) request.body = params.data if params.has_key?('data') if params.has_key?('encoder') request.params.params_encoder(params.encoder) end request.url(path, params.to_hash) when *METHODS_WITH_BODIES request.url(path, connection_options[:query] || {}) request.body = params.data unless params.empty? end end ResponseWrapper.new(response, self) end