Sha256: a22160c4ff99b7596bf291754aac2b84309338f4ce54600cfe9401de156f2aea

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

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
          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

6 entries across 6 versions & 1 rubygems

Version Path
fullcontact-0.7.0 lib/fullcontact/connection.rb
fullcontact-0.6.1 lib/fullcontact/connection.rb
fullcontact-0.6.0 lib/fullcontact/connection.rb
fullcontact-0.5.0 lib/fullcontact/connection.rb
fullcontact-0.4.4 lib/fullcontact/connection.rb
fullcontact-0.4.1 lib/fullcontact/connection.rb