Sha256: ee76442fc19b0b54aec7cffdbb4901340b43e91958bb6cb3f2d77c4b2c2cdeea

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'faraday_middleware'
require 'faraday/multipart'
require 'faraday/raise_http_4xx'
require 'faraday/raise_http_5xx'
require 'faraday/parse_slideshare_xml'

module Slideshare
  # @private
  module Connection
    private
    
    def connection(raw=false)
      
      options = {
        :headers => {'Accept' => "application/#{format}", 'User-Agent' => user_agent},
        :ssl => {:verify => false},
        :url => api_endpoint,
      }

      Faraday::Connection.new(options) do |connection|
        connection.use Faraday::Request::Multipart2 #, authentication
        #connection.use Faraday::Request::OAuth, authentication if authenticated?
        connection.adapter(adapter)
        connection.use Faraday::Response::RaiseHttp5xx
        unless raw
          case format.to_s.downcase
          when 'json' then connection.use Faraday::Response::ParseJson # one can hope
          when 'xml' then connection.use Faraday::Response::ParseSlideshareXml
          end
        end
        connection.use Faraday::Response::RaiseHttp4xx
        connection.use Faraday::Response::Mashify unless raw
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-slideshare-0.1.7 lib/slideshare/connection.rb
ruby-slideshare-0.1.6 lib/slideshare/connection.rb
ruby-slideshare-0.1.5 lib/slideshare/connection.rb