Sha256: 83edf4c579c55a67cdd54d4b6b451487fcd6893e39566c022efba7954e3fe5d7

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

require 'faraday_middleware'
require 'faraday/response/raise_ted_api_error'

module TedApi
  module Connection
    private

    def connection(raw=false, force_urlencoded=false)
      url = "#{TedApi.api_endpoint}#{TedApi.api_version}"

      options = {
        url: url
      }
      
      connection = Faraday.new(options) do |builder|
        builder.use Faraday::Response::RaiseTedApiError
        unless raw
          builder.use FaradayMiddleware::Mashify
          if response_format == 'json'
            builder.use FaradayMiddleware::ParseJson
          elsif response_format == 'xml'
            builder.use FaradayMiddleware::ParseXml
          end
        end
        builder.adapter *adapter
      end
      connection
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ted_api-0.1 lib/ted_api/connection.rb