# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_page.ipynb.

# %% auto 0
__all__ = ['paged', 'pages']

# %% ../nbs/02_page.ipynb 2
from fastcore.all import *
from .core import *

# %% ../nbs/02_page.ipynb 8
def paged(oper, *args, **kwargs):
    """Iterate through all pages of a Stripe API operation."""
    page = oper(*args, **kwargs)
    yield page
    while page.has_more:
        last_id = page.data[-1].id
        page = oper(*args, starting_after=last_id, **kwargs)
        yield page

# %% ../nbs/02_page.ipynb 11
def pages(oper, *args, **kwargs):
    """Retrieve all items from all pages of a Stripe API operation."""
    return L(p for page in paged(oper, *args, **kwargs) for p in page.data)
