Sha256: 425e4a4bfff7964bfdfd763b9e4d6f7ff32b78a8c59d60a5a9c749ad802f1f5a

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

require 'faraday_middleware'
Dir[File.expand_path('../../../faraday/*.rb', __FILE__)].each{|file| require file}

module Recalls
  class Client
    # @private
    module Connection
      private

      def connection(raw=false)
        options = {
          :headers => {'Accept' => 'application/json'},
          :proxy => proxy,
          :ssl => {:verify => false},
          :url => 'http://search.usa.gov/search/recalls' + endpoint.to_s
        }

        Faraday::Connection.new(options) do |connection|
          connection.use Faraday::Request::Multipart
          unless raw
            connection.use Faraday::Response::Mashify
            case format.to_s.downcase
            when 'json'
              connection.use Faraday::Response::ParseJson
            when 'xml'
              connection.use Faraday::Response::ParseXml
            end
          end
          connection.use Faraday::Response::RaiseError
          connection.adapter(adapter)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
recalls-0.1 lib/recalls/client/connection.rb
Recalls-0.1 lib/recalls/client/connection.rb