Sha256: 988d99679ff2bca9d2a54b37a33bc951f957b32aa16842f63664312406533a26

Contents?: true

Size: 986 Bytes

Versions: 8

Compression:

Stored size: 986 Bytes

Contents

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


module FullContact
  # @private
  module Connection
    private

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

      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
          when 'xml'
            builder.use Faraday::Response::ParseXml
          end
        end
        builder.use Faraday::Response::FullContactErrors
        builder.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
fullcontact-0.3.3 lib/fullcontact/connection.rb
fullcontact-0.3.2 lib/fullcontact/connection.rb
fullcontacter-0.3.2 lib/fullcontact/connection.rb
fullcontact-0.3.1 lib/fullcontact/connection.rb
fullcontact-0.3.0 lib/fullcontact/connection.rb
fullcontact-0.2.0 lib/fullcontact/connection.rb
fullcontact-0.1.4 lib/fullcontact/connection.rb
fullcontact-0.1.3 lib/fullcontact/connection.rb