Sha256: da7d669f992fde519f1ecbb8b5b2c48e821d029c6b77e54861e071d25e94f910

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

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

module Open311
  class Client
    # @private
    module Connection
      private

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open311-0.1.1 lib/open311/client/connection.rb
open311-0.1.0 lib/open311/client/connection.rb