Method: Github::Request#request
- Defined in:
-
lib/github_api/request.rb,
lib/github_api/requestable.rb
Performs a request
method - The Symbol the HTTP verb path - String relative URL to access params - ParamsHash to configure the request API
Returns a Github::ResponseWrapper
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/github_api/request.rb', line 40 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'] = params. = .merge() conn = connection() 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, [:query] || {}) request.body = params.data unless params.empty? end end ResponseWrapper.new(response, self) end |