Sha256: 15d4131523ca4832bd2e48959cea262ab03b32cb1d41bbac6286044227e75a39

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

require 'faraday_middleware'
require 'faraday/request/gateway'
require 'faraday/response/fullcontact_errors'


module FullContact
  # @private
  module Connection
    private

    def connection(raw=false, faraday_options={})
      options = {
          :headers => {'Accept' => "application/#{format}", 'User-Agent' => user_agent},
          :proxy => proxy,
          :ssl => {:verify => false},
          :url => api_endpoint,
      }.merge(faraday_options)

      Faraday.new(options) do |builder|
        builder.use Faraday::Request::UrlEncoded
        builder.use Faraday::Request::Gateway, gateway if gateway
        builder.use Faraday::Response::Rashify unless raw
        unless raw
          case format.to_s.downcase
            when 'json'
              builder.use Faraday::Response::ParseJson
          end
        end
        builder.use Faraday::Response::FullContactErrors
        builder.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fullcontact-0.8.2 lib/fullcontact/connection.rb