Sha256: d3f1392e986c3f3e66a77956b3104fc9363127db88cef0a9c875268a27d5a801

Contents?: true

Size: 931 Bytes

Versions: 6

Compression:

Stored size: 931 Bytes

Contents

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

module Instagram
  # @private
  module Connection
    private

    def connection(raw=false)
      options = {
        :headers => {'Accept' => "application/#{format}; charset=utf-8", 'User-Agent' => user_agent},
        :proxy => proxy,
        :url => endpoint,
      }.merge(connection_options)

      Faraday::Connection.new(options) do |connection|
        connection.use FaradayMiddleware::InstagramOAuth2, client_id, access_token
        connection.use Faraday::Request::UrlEncoded
        connection.use FaradayMiddleware::Mashify unless raw
        unless raw
          case format.to_s.downcase
          when 'json' then connection.use Faraday::Response::ParseJson
          end
        end
        connection.use FaradayMiddleware::RaiseHttpException
        connection.adapter(adapter)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
instagram-1.1.4 lib/instagram/connection.rb
instagram-1.1.3 lib/instagram/connection.rb
instagram-1.1.2 lib/instagram/connection.rb
instagram-1.1.1 lib/instagram/connection.rb
instagram-1.1.0 lib/instagram/connection.rb
instagram-1.0.0 lib/instagram/connection.rb