def paginate(path, options = {}, &block)
      opts           = parse_query_and_convenience_headers path, options.dup
      auto_paginate  = opts[:params].delete(:auto_paginate) { |k| @auto_paginate }
      @last_response = request :get, opts
      data           = @last_response.body
      raise PivotalApi::Errors::UnexpectedData, 'Array expected' unless data.is_a? Array

      if auto_paginate
        pager = Pagination.new @last_response.headers

        while pager.more?
          opts[:params].update(pager.next_page_params)

          @last_response = request :get, opts
          pager          = Pagination.new @last_response.headers
          if block_given?
            yield(data, @last_response)
          else
            data.concat(@last_response.body) if @last_response.body.is_a?(Array)
          end
        end
      end

      data
    end
def paginate(path, options = {}, &block)
      opts           = parse_query_and_convenience_headers path, options.dup
      auto_paginate  = opts[:params].delete(:auto_paginate) { |k| @auto_paginate }
      @last_response = request :get, opts
      data           = @last_response.body
      raise PivotalApi::Errors::UnexpectedData, 'Array expected' unless data.is_a? Array

      if auto_paginate
        pager = Pagination.new @last_response.headers

        while pager.more?
          opts[:params].update(pager.next_page_params)

          @last_response = request :get, opts
          pager          = Pagination.new @last_response.headers
          if block_given?
            yield(data, @last_response)
          else
            data.concat(@last_response.body) if @last_response.body.is_a?(Array)
          end
        end
      end

      data
    end
Make one or more HTTP GET requests, optionally fetching
 the next page of results from information passed back in headers
 based on value in {#auto_paginate}.

 @param path [String] The path, relative to {#api_endpoint}
 @param options [Hash] Query and header params for request
 @param block [Block] Block to perform the data concatenation of the
   multiple requests. The block is called with two parameters, the first
   contains the contents of the requests so far and the second parameter
   contains the latest response.
 @return [Array]