We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of code using pagination as enumerator
def self.paginated_get(path, options = {}) Enumerator.new do |y| params = options.dup page = nil total = 0 size = params.delete(:size) { 50 } loop do response = get(path, { page: page, size: size }.merge(params)) data = JSON.parse(response.body) objects = data["_embedded"].present? ? data["_embedded"]["intelligenceObjects"] : [] total += objects.length objects.each do |element| y.yield element end break if (data["page"]["number"] >= (data["page"]["totalPages"] - 1) || objects.empty? || total >= MAX_OBJECTS) page = data["page"]["number"] + 1 end end end
usage:
Endpoint.paginated_get(params) do |response| # do somthing end
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Example of code using pagination as enumerator
usage:
The text was updated successfully, but these errors were encountered: