Class: Pluggy::Lists::OffsetList
Overview
The page, total, totalPages envelope.
Used by /accounts, /bills, /loans, /connectors, /accounts/id/statements
and /transactions (v1) -- but only /transactions and /connectors actually
accept page/pageSize. The rest return a paged envelope with no
documented way to ask for page 2, so services pass paginated: false and
more? stays false. auto_paging_each then yields the single page and
stops, rather than issuing a request that would return the same rows.
Constant Summary
collapse
- DEFAULT_PAGE_SIZE =
Prose-only default in the spec (no JSON-Schema default exists
anywhere), so the SDK has to supply it.
500
- MAX_PAGE_SIZE =
500
Instance Attribute Summary
Attributes inherited from BaseList
#filters, #path, #raw, #results
Instance Method Summary
collapse
Methods inherited from BaseList
#auto_paging_each, #auto_paging_to_a, #each, #empty?, #inspect, #length
Constructor Details
#initialize(payload, paginated: false, **kwargs) ⇒ OffsetList
19
20
21
22
|
# File 'lib/pluggy/lists/offset_list.rb', line 19
def initialize(payload, paginated: false, **kwargs)
@paginated = paginated
super(payload, **kwargs)
end
|
Instance Method Details
#more? ⇒ Boolean
29
30
31
|
# File 'lib/pluggy/lists/offset_list.rb', line 29
def more?
@paginated && !empty? && page < total_pages
end
|
#next_page ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/pluggy/lists/offset_list.rb', line 33
def next_page
return nil unless more?
@requestor.list(
@path,
params: @filters.merge(page: page + 1),
klass: @klass,
client: @client,
paginated: true
)
end
|
#page ⇒ Object
24
|
# File 'lib/pluggy/lists/offset_list.rb', line 24
def page = @raw.is_a?(Hash) ? (@raw["page"]&.to_i || 1) : 1
|
#paginated? ⇒ Boolean
27
|
# File 'lib/pluggy/lists/offset_list.rb', line 27
def paginated? = @paginated
|
#total ⇒ Object
25
|
# File 'lib/pluggy/lists/offset_list.rb', line 25
def total = @raw.is_a?(Hash) ? @raw["total"]&.to_i : nil
|
#total_pages ⇒ Object
26
|
# File 'lib/pluggy/lists/offset_list.rb', line 26
def total_pages = @raw.is_a?(Hash) ? (@raw["totalPages"]&.to_i || 1) : 1
|