Sha256: da5b73ac7d7fcf74866483bd1852a7b23bbacc64cbfe17370c807d8a4244e22a

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
module Notion
  module Faraday
    module Connection
      private

      def connection
        @connection ||=
          begin
            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

            request_options = {}
            request_options[:timeout] = timeout if timeout
            request_options[:open_timeout] = open_timeout if open_timeout
            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 ::Notion::Faraday::Response::RaiseError
              connection.use ::FaradayMiddleware::Mashify, mash_class: Notion::Messages::Message
              connection.use ::FaradayMiddleware::ParseJson
              connection.use ::Notion::Faraday::Response::WrapError
              connection.response :logger, logger if logger
              connection.adapter adapter
            end
          end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
notion-ruby-client-1.0.0 lib/notion/faraday/connection.rb
notion-ruby-client-1.0.0.pre.beta2 lib/notion/faraday/connection.rb
notion-ruby-client-1.0.0.pre.beta1 lib/notion/faraday/connection.rb
notion-ruby-client-0.1.0.pre.beta1 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.8 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.7 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.6 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.5 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.4 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.3 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.2 lib/notion/faraday/connection.rb
notion-ruby-client-0.0.1 lib/notion/faraday/connection.rb