lib/amee/connection.rb
def do_request(request, format = @format, options = {})

      # Is this a v3 request?
      v3_request = request.url.include?("/#{v3_hostname}/")

      # make sure we have our auth token before we start
      # any v1 or v2 requests
      if !@auth_token && !v3_request
        d "Authenticating first before we hit #{request.url}"
        authenticate 
      end

      request.headers['Accept'] = content_type(format)
      # Set AMEE source header if set
      request.headers['X-AMEE-Source'] = @amee_source if @amee_source

      # path+query string only (split with an int limits the number of splits)
      path_and_query = '/' + request.url.split('/', 4)[3]

      if options[:cache]
        # Get response with caching
        response = cache(path_and_query) { run_request(request, :xml) }
      else
        response = run_request(request, :xml)
      end
      response
    end
def do_request(request, format = @format, options = {})

      # Is this a v3 request?
      v3_request = request.url.include?("/#{v3_hostname}/")

      # make sure we have our auth token before we start
      # any v1 or v2 requests
      if !@auth_token && !v3_request
        d "Authenticating first before we hit #{request.url}"
        authenticate 
      end

      request.headers['Accept'] = content_type(format)
      # Set AMEE source header if set
      request.headers['X-AMEE-Source'] = @amee_source if @amee_source

      # path+query string only (split with an int limits the number of splits)
      path_and_query = '/' + request.url.split('/', 4)[3]

      if options[:cache]
        # Get response with caching
        response = cache(path_and_query) { run_request(request, :xml) }
      else
        response = run_request(request, :xml)
      end
      response
    end
Wrapper for sending requests through to the API.
 Takes care of making sure requests authenticated, and
 if set, attempts to retry a number of times set when
 initialising the class