Sha256: 9e15cceab38b0a8595ee91c77816f2f0ab904b040dd76197637fb8de48cbe234

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

require 'faraday_middleware'

module YellowApi
  class Client
    module Connection
      private

      def connection(options = {})
        sandbox_enable = options.fetch(:sandbox_enabled, sandbox_enabled)
        url = sandbox_enable ? options.fetch(:sandbox_endpoint, sandbox_endpoint) : options.fetch(:endpoint, endpoint)

        @connection ||= Faraday.new(url: url) do |builder|
          builder.use Faraday::Request::UrlEncoded
          builder.use Faraday::Response::RaiseError
          builder.use Faraday::Response::Rashify
          builder.use Faraday::Response::ParseJson
          builder.adapter(Faraday.default_adapter)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yellow-api-wrapper-0.0.2 lib/yellow_api/client/connection.rb
yellow-api-wrapper-0.0.1 lib/yellow_api/client/connection.rb