def setup(api_host, options)
      token, username, password = options.values_at :token, :username, :password

      api_host  = api_host.api_host if api_host.respond_to? :api_host
      @api_host = Addressable::URI.parse(api_host)
      @headers  = {
        "User-Agent"      => options[:user_agent] || "GH/#{GH::VERSION}",
        "Accept"          => options[:accept] || "application/vnd.github.v3+json",
        "Accept-Charset"  => "utf-8",
      }

      @headers.merge! options[:headers] if options[:headers]
      @headers['Origin'] = options[:origin] if options[:origin]

      @prefix = ""
      @prefix << "#{token}@" if token
      @prefix << "#{username}:#{password}@" if username and password
      @prefix << @api_host.host

      faraday_options = {:url => api_host}
      faraday_options[:ssl] = options[:ssl] if options[:ssl]
      faraday_options.merge! options[:faraday_options] if options[:faraday_options]

      @connection = Faraday.new(faraday_options) do |builder|
        builder.request(:authorization, :token, token) if token
        builder.request(:basic_auth, username, password)  if username and password
        builder.request(:retry)
        builder.response(:raise_error)
        if defined? FaradayMiddleware::Instrumentation
          builder.use :instrumentation
        end
        builder.adapter(:net_http)
      end
    end
def setup(api_host, options)
      token, username, password = options.values_at :token, :username, :password

      api_host  = api_host.api_host if api_host.respond_to? :api_host
      @api_host = Addressable::URI.parse(api_host)
      @headers  = {
        "User-Agent"      => options[:user_agent] || "GH/#{GH::VERSION}",
        "Accept"          => options[:accept] || "application/vnd.github.v3+json",
        "Accept-Charset"  => "utf-8",
      }

      @headers.merge! options[:headers] if options[:headers]
      @headers['Origin'] = options[:origin] if options[:origin]

      @prefix = ""
      @prefix << "#{token}@" if token
      @prefix << "#{username}:#{password}@" if username and password
      @prefix << @api_host.host

      faraday_options = {:url => api_host}
      faraday_options[:ssl] = options[:ssl] if options[:ssl]
      faraday_options.merge! options[:faraday_options] if options[:faraday_options]

      @connection = Faraday.new(faraday_options) do |builder|
        builder.request(:authorization, :token, token) if token
        builder.request(:basic_auth, username, password)  if username and password
        builder.request(:retry)
        builder.response(:raise_error)
        if defined? FaradayMiddleware::Instrumentation
          builder.use :instrumentation
        end
        builder.adapter(:net_http)
      end
    end
Public: Generates a new Remote instance.

 api_host - HTTP host to send requests to, has to include schema (https or http)
 options  - Hash with configuration options:
            :token    - OAuth token to use (optional).
            :username - Github user used for login (optional).
            :password - Github password used for login (optional).
            :origin   - Value of the origin request header (optional).
            :headers  - HTTP headers to be send on every request (optional).

 It is highly recommended to set origin, but not to set headers.
 If you set the username, you should also set the password.