Sha256: e08e30570b07e462b526417cfe092874273c90fd88e53969140ac243e1fa8791

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'faraday_middleware'
require 'open311/response/raise_error'

module Open311
  class Client
    # @private
    module Connection
    private

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open311-0.3.1 lib/open311/client/connection.rb
open311-0.3.0 lib/open311/client/connection.rb