Sets up the HTTP client for communicating with the WaniKani API.

 @return [Faraday::Connection] the HTTP client to communicate with the
   WaniKani API.
176841
def client
      Faraday.new(url: Wanikani::API_ENDPOINT) do |conn|
        conn.response :json, :content_type => /\bjson$/
        conn.adapter Faraday.default_adapter
      end
    end
256295
def connection
      if ::Fog::const_defined? @account[:service]
        service_mod = ::Fog::const_get @account[:service]
        provider_class = service_mod.send(:const_get, @account[:provider])
        @fog_service ||= provider_class.new(@account[:credentials])
      else
        provider_mod = ::Fog::const_get @account[:provider]
        service_class = provider_mod.send(:const_get, @account[:service])
        @fog_service ||= service_class.new(@account[:credentials])
      end
    end
363325
def client
      Faraday.new(url: address) do |conn|
        conn.request :json
        conn.response :json, content_type: /\bjson$/
        conn.adapter Faraday.default_adapter # make requests with Net::HTTP
      end
    end
165037
def request(uri, method = :get, body = nil, query = nil, content_type = nil)
      headers = {}

      {
        'Content-Type'                  => content_type || 'application/json',
        'User-Agent'                    => "Parse for Ruby, #{VERSION}",
        Protocol::HEADER_MASTER_KEY     => @master_key,
        Protocol::HEADER_APP_ID         => @application_id,
        Protocol::HEADER_API_KEY        => @api_key,
        Protocol::HEADER_SESSION_TOKEN  => @session_token
      }.each do |key, value|
        headers[key] = value if value
      end

      uri = ::File.join(path, uri)
      response = @session.send(method, uri, query || body || {}, headers)
      response.body

    # NOTE: Don't leak our internal libraries to our clients.
    # Extend this list of exceptions as needed.
    rescue Faraday::Error::ClientError => e
      raise Parse::ConnectionError, e.message
    end
1177037
def connect!
      @connection = HTTParty.post(File.join(url, "rest/user/login"), body: credentials_hash )
      @cookies['Cookie'] = @connection.headers['set-cookie']
      @connection.code
    end
576480
def use_proxy(uri, port, user=nil, pass=nil)
      @http_class = Net::HTTP::Proxy(uri, port, user, pass)
    end
582557
def connect(host, port, connection_name = nil, *initializer_args, &block)
      if block_given?
        initializer_args.unshift connection_name if connection_name

        klass = Class.new Cool.io::TCPSocket
        connection_builder = ConnectionBuilder.new klass
        connection_builder.instance_eval(&block)
      else
        raise ArgumentError, "no connection name or block given" unless connection_name
        klass = self[connection_name]
      end

      client = klass.connect host, port, *initializer_args
      client.attach Cool.io::Loop.default
      client
    end
899450
def perform_request(request_options: {}, parameters: {}, uri:)
      args = parameters
      request_options = request_options.merge(faraday_options)
      # figure out our options for this request
      # set up our Faraday connection
      connection = Faraday.new(faraday_options) do |faraday|
        faraday.adapter  Faraday.default_adapter
      end
      connection.get(uri, args)
    end
936231
def api_server(connection, server_class):
    

    # run api server on connection
    return server_class(
        link=xbahn.connection.link.Link(
            # use the connection to receive messages
            receive=connection,
            # use the connection to respond to received messages
            respond=connection
        )
    )
686403
def connect(self):
        
        if not self.idle and not self.closed:
            raise ConnectionStateError(self.state_description)
        LOGGER.debug('Connecting to %s', self.url)
        self.state = self.STATE_CONNECTING
        self.connection = pika.TornadoConnection(
            parameters=self.parameters,
            on_open_callback=self.on_connection_open,
            on_open_error_callback=self.on_connection_open_error,
            on_close_callback=self.on_connection_closed,
            custom_ioloop=self.io_loop)
1364065
def send_connection_preface
      return unless @state == :waiting_connection_preface
      @state = :connected
      emit(:frame, CONNECTION_PREFACE_MAGIC)

      payload = @local_settings.reject { |k, v| v == SPEC_DEFAULT_CONNECTION_SETTINGS[k] }
      settings(payload)
    end
522575
def connection opts={}
      connection = Faraday.new(opts) do |conn|

        if opts[:force_urlencoded]
          conn.request :url_encoded
        else
          conn.request :json
        end

        conn.request :json
        conn.use FaradayMiddleware::FollowRedirects
        conn.use FaradayMiddleware::Mashify
        conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
        conn.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
        conn.adapter adapter
      end

      connection.headers[:user_agent] = user_agent
      connection
    end
464936
def _get_connection(self):
        
        if self._connection is None:
            uri = self.settings.SERVER_URI
            if callable(uri):
                uri = uri()

            self._connection = self.backend.ldap.initialize(uri)

            for opt, value in self.settings.CONNECTION_OPTIONS.items():
                self._connection.set_option(opt, value)

            if self.settings.START_TLS:
                logger.debug("Initiating TLS")
                self._connection.start_tls_s()

        return self._connection
179210
def connection
      @connection ||= Faraday.new(faraday_options) do |builder|
        builder.use Faraday::Request::UrlEncoded
        builder.use Restforce::Middleware::Mashify, nil, @options
        builder.response :json

        if Restforce.log?
          builder.use Restforce::Middleware::Logger,
                      Restforce.configuration.logger,
                      @options
        end

        builder.adapter @options[:adapter]
      end
    end
728820
def connect(self):
        
        if not (self.consumer_key and self.consumer_secret and self.access_token
                and self.access_token_secret):
            raise RuntimeError("MissingKeys")

        if self.client:
            log.info("closing existing http session")
            self.client.close()
        if self.last_response:
            log.info("closing last response")
            self.last_response.close()
        log.info("creating http session")

        self.client = OAuth1Session(
            client_key=self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.access_token,
            resource_owner_secret=self.access_token_secret
        )
53354
def init
      return if @has_been_init

      @socket = init_socket(@socket)
      @socket.connect # costly and blocking !

      internalWrapper = (Struct.new :url, :socket do
        def write(*args)
          self.socket.write(*args)
        end
      end).new @url.to_s, @socket

      # this, also, is costly and blocking
      @driver = WebSocket::Driver.client internalWrapper
      @driver.on :open do
        @connected = true
        unless @callbacks[:open].nil?
          @callbacks[:open].call
        end
      end

      @driver.on :error do |event|
        @connected = false
        unless @callbacks[:error].nil?
          @callbacks[:error].call
        end
      end

      @driver.on :message do |event|
        data = JSON.parse event.data
        unless @callbacks[:message].nil?
          @callbacks[:message].call data
        end
      end
      @driver.start
      @has_been_init = true
    end
670865
def prepare_http_connection
      conn = HTTPClient.new(options[:proxy] || self.class.proxy)
      set_http_connection_options(conn, options)
      conn
    end