Sha256: 094c91358b94e6979b289a8b1b05c4b44b1a949c77204bf9bb05d504953d6747

Contents?: true

Size: 676 Bytes

Versions: 5

Compression:

Stored size: 676 Bytes

Contents

# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'

module Afterpay
  module HTTPService
    class << self
      # @return [Hash] default HTTPService configuration
      def configuration
        {
          middleware: DEFAULT_MIDDLEWARE,
          server: ::Afterpay.server
        }
      end
    end

    # Afterpay default middleware stack
    DEFAULT_MIDDLEWARE = proc do |builder|
      builder.request    :json
      builder.request    :basic_auth, *::Afterpay.configuration.values

      builder.response   :mashify
      builder.response   :json, content_type: /\bjson$/

      builder.adapter    Faraday.default_adapter
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
afterpay-0.6.0 lib/afterpay/http_service.rb
afterpay-0.5.0 lib/afterpay/http_service.rb
afterpay-0.4.0 lib/afterpay/http_service.rb
afterpay-0.3.0 lib/afterpay/http_service.rb
afterpay-0.2.0 lib/afterpay/http_service.rb