Sha256: 5b2b77db2e772b0e550cb0c57cec52b9cf5a2c7f2f9af96e839760c36dff00bd

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module Octokit
  class Client
    module Request
      def get(path, options={}, version=api_version, authenticate=true, raw=false)
        request(:get, path, options, version, authenticate, raw)
      end

      def post(path, options={}, version=api_version, authenticate=true, raw=false)
        request(:post, path, options, version, authenticate, raw)
      end

      def put(path, options={}, version=api_version, authenticate=true, raw=false)
        request(:put, path, options, version, authenticate, raw)
      end

      def delete(path, options={}, version=api_version, authenticate=true, raw=false)
        request(:delete, path, options, version, authenticate, raw)
      end

      private

      def request(method, path, options, version, authenticate, raw)
        if [1, 2].include? version
          url = "https://github.com/"
        elsif version >= 3
          url = "https://api.github.com/"
        end
        response = connection(url, authenticate, raw).send(method) do |request|
          case method
          when :get, :delete
            request.url(path, options)
          when :post, :put
            request.path = path
            request.body = options unless options.empty?
          end
        end
        raw ? response : response.body
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
octokit-0.6.3 lib/octokit/client/request.rb