require 'faraday_middleware'

module TumblrOAuth
  # @private
  module Connection
    private

    def connection
      options = {
        :headers => {'Accept' => "application/json"},
        :url => endpoint,
      }

      Faraday.new(options) do |builder|
        builder.use Faraday::Request::OAuth, authentication if authenticated?
        builder.use Faraday::Request::UrlEncoded
        builder.use Faraday::Response::Mashify
        builder.use Faraday::Response::ParseJson
        builder.use Faraday::Response::Logger if debug
        builder.use Faraday::Adapter::NetHttp
        builder.adapter Faraday.default_adapter
      end
    end
  end
end

require 'faraday_middleware'

module TumblrOAuth
  # @private
  module Connection
    private

    def connection
      options = {
        :headers => {'Accept' => "application/json"},
        :url => endpoint,
      }

      Faraday.new(options) do |builder|
        builder.use Faraday::Request::OAuth, authentication if authenticated?
        builder.use Faraday::Request::UrlEncoded
        builder.use Faraday::Response::Mashify
        builder.use Faraday::Response::ParseJson
        builder.use Faraday::Response::Logger if debug
        builder.use Faraday::Response::RaiseError
        builder.use Faraday::Adapter::NetHttp
        builder.adapter Faraday.default_adapter
      end
    end
  end
end

Raise error on bad return status
Raise error on bad return status
