Module: Smplkit::ApiSupport::PaginatedFetch Private
- Defined in:
- lib/smplkit/api_support.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Walk a generated paginated list endpoint to completion.
The block receives a per-page opts hash with page_number and page_size filled in, calls the generated list method through ErrorMapping.call, and returns the response object. Pages stop when the server returns fewer rows than requested — the platform’s standard last-page signal across every offset-paginated list endpoint. Returns the concatenated response.data rows.
Class Method Summary collapse
Class Method Details
.collect(page_size: RUNTIME_PAGE_SIZE) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/smplkit/api_support.rb', line 56 def collect(page_size: RUNTIME_PAGE_SIZE) rows = [] page_number = 1 loop do opts = { page_number: page_number, page_size: page_size } response = ErrorMapping.call { yield(opts) } page = response.data || [] rows.concat(page) break if page.length < page_size page_number += 1 end rows end |