Sha256: e493674cc352044087463a649d08858506b2cdee968e630cb9c45f7958768b35

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module IEX
  module Cloud
    module Connection
      private

      def headers
        {}
      end

      def connection
        options = {}

        options[:headers] = {}
        options[:headers]['Accept'] = 'application/json; charset=utf-8'
        options[:headers]['User-Agent'] = user_agent if user_agent
        options[:proxy] = proxy if proxy
        options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file
        options[:params] = { token: publishable_token } if publishable_token

        request_options = {}
        request_options[:timeout] = timeout if timeout
        request_options[:open_timeout] = open_timeout if open_timeout
        request_options[:params_encoder] = Faraday::FlatParamsEncoder
        options[:request] = request_options if request_options.any?

        ::Faraday::Connection.new(endpoint, options) do |connection|
          connection.use ::Faraday::Request::Multipart
          connection.use ::Faraday::Request::UrlEncoded
          connection.use ::IEX::Cloud::Response::RaiseError
          connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
          connection.response :logger, logger if logger
          connection.adapter ::Faraday.default_adapter
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iex-ruby-client-1.1.0 lib/iex/cloud/connection.rb
iex-ruby-client-1.0.1 lib/iex/cloud/connection.rb
iex-ruby-client-1.0.0 lib/iex/cloud/connection.rb