Sha256: f9a52ea815183e11072e4e94bb99a5df8a70e574c6b37cc0fe71413c0b093a9d

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true
module Usps
  module Faraday
    module Connection
      private

      def connection
        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 ::Faraday::Response::RaiseError
          connection.use ::Usps::Faraday::Response::RaiseError
          # connection.use ::FaradayMiddleware::Mashify, mash_class: Slack::Messages::Message
          connection.use ::FaradayMiddleware::ParseXml
          connection.response :logger, logger if logger
          connection.adapter ::Faraday.default_adapter
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
usps-ruby-client-0.2.0 lib/usps/faraday/connection.rb
usps-ruby-client-0.1.3 lib/usps/faraday/connection.rb
usps-ruby-client-0.1.2 lib/usps/faraday/connection.rb
usps-ruby-client-0.1.1 lib/usps/faraday/connection.rb
usps-ruby-client-0.1.0 lib/usps/faraday/connection.rb