def paginate(url, options = {}, &block)
      opts = options.dup
      if @auto_paginate || @per_page
        opts[:query] ||= {}
        opts[:query][:per_page] ||= @per_page || (@auto_paginate ? MAX_PER_PAGE : nil)
      end

      data = request(:get, url, nil, opts)

      if @auto_paginate
        while @last_response.rels[:next]
          @last_response = @last_response.rels[:next].get(headers: opts[:headers])
          if block_given?
            yield(data, @last_response)
          else
            data.concat(@last_response.data) if @last_response.data.is_a?(Array)
          end
        end
      end

      data
     end
def paginate(url, options = {}, &block)
      opts = options.dup
      if @auto_paginate || @per_page
        opts[:query] ||= {}
        opts[:query][:per_page] ||= @per_page || (@auto_paginate ? MAX_PER_PAGE : nil)
      end

      data = request(:get, url, nil, opts)

      if @auto_paginate
        while @last_response.rels[:next]
          @last_response = @last_response.rels[:next].get(headers: opts[:headers])
          if block_given?
            yield(data, @last_response)
          else
            data.concat(@last_response.data) if @last_response.data.is_a?(Array)
          end
        end
      end

      data
     end
Fetch all elements for requested API resource when {#auto_paginate} is turned on.

 @see http://www.voog.com/developers/api/basics/pagination