Sha256: 1687a7225e15ff2bd5d2776dd9a3de387e8c795c426fd807b5fe2523fba2f7a1

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 Bytes

Contents

require 'faraday_middleware'
require 'faraday/response/raise_error'

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

4 entries across 4 versions & 1 rubygems

Version Path
open311-0.2.3 lib/open311/client/connection.rb
open311-0.2.2 lib/open311/client/connection.rb
open311-0.2.1 lib/open311/client/connection.rb
open311-0.2.0 lib/open311/client/connection.rb