Skip to content

Example code for pagination results in unhandled exception #681

@brianz

Description

@brianz

Describe the bug

The documentation shows code examples on how to iterate around a paginated list of accounts/pages:

https://recurly-client-python.readthedocs.io/en/latest/#pagination

per-page

pages = client.list_accounts(limit=200).pages()
for page in pages:
    for account in page:
        print(account.code)

per-item

accounts = client.list_accounts(limit=200).items()
for account in accounts:
    print(account.code)

Both of these code examples fail:

Traceback (most recent call last):
  File "test-recurly.py", line 13, in <module>
    for page in pages:
  File "recurly/pager.py", line 40, in __next__
    page = self.__client._make_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "recurly/base_client.py", line 51, in _make_request
    self._validate_options(options)
  File "recurly/base_client.py", line 103, in _validate_options
    raise ApiError(error, None)
recurly.base_errors.ApiError: Invalid options: limit. Allowed options: body, params, headers

To Reproduce

  • Create a valid recurly client with a valid API key according to the documentation.
  • Copy and paste the code examples mentioned above
  • Note that running it results in an exception with the error: Invalid options: limit. Allowed options: body, params, headers

Expected behavior

The code should run without errors

Your Environment

  • recurly==4.45.0
  • Python 3.12
  • MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions