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, :ssl => {:verify => false}, :url => endpoint, } Faraday::Connection.new(options) do |connection| connection.use Faraday::Request::OAuth2, client_id, access_token connection.adapter(adapter) connection.use Faraday::Response::RaiseHttp5xx unless raw case format.to_s.downcase when 'json' then connection.use Faraday::Response::ParseJson end end connection.use Faraday::Response::RaiseHttp4xx connection.use Faraday::Response::Mashify unless raw end end end end