Sha256: b3f590412ca053e6dbbcb01935c13ea4660ed0331d15f894c83dc1c1aad3ed1f

Contents?: true

Size: 940 Bytes

Versions: 6

Compression:

Stored size: 940 Bytes

Contents

require 'faraday_middleware'
require 'faraday/raise_paychex_http_exception'

module Paychex
  module Connection
    private

    def connection
      options = {
        headers: {
          'Accept' => "application/#{format}",
          'User-Agent' => user_agent
        },
        proxy: proxy,
        url: endpoint
      }.merge(connection_options)

      Faraday::Connection.new(options) do |conn|
        conn.authorization :Bearer, access_token unless access_token.nil?
        # https://github.com/lostisland/faraday/issues/417#issuecomment-223413386
        conn.options[:timeout] = timeout
        conn.options[:open_timeout] = open_timeout
        conn.request :json
        conn.request :instrumentation, name: 'request.paychex'

        conn.use ::PaychexFaradayMiddleWare::RaisePaychexHttpException
        conn.response :json, content_type: /\bjson$/
        conn.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
paychex-0.3.3 lib/paychex/connection.rb
paychex-0.3.2 lib/paychex/connection.rb
paychex-0.3.1 lib/paychex/connection.rb
paychex-0.3.0 lib/paychex/connection.rb
paychex-0.2.2 lib/paychex/connection.rb
paychex-0.2.1 lib/paychex/connection.rb