Skip to content

Commit

Permalink
Add pagination attributes for accounts (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
tk26 authored Jul 31, 2023
1 parent 61dd7e8 commit 18e7fcb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]

## [v4.7.0] - 2023-07-31

Add pagination attributes for accounts API

## [v4.6.0] - 2023-07-24

Adds support for Accounts API
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="trycourier",
version="4.6.0",
version="4.7.0",
author="Courier",
author_email="support@courier.com",
description="A Python Package for communicating with the Courier REST API.",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_success_get_accounts():
'https://api.courier.com/accounts',
status=200,
content_type='application/json',
body='{"items":[{"id":"ACME", "name":"ACME Inc", "properties":{}, "default_preferences":{}, "user_profile":{}}], "has_more": false}'
body='{"items":[{"id":"ACME", "name":"ACME Inc", "properties":{}, "default_preferences":{}, "user_profile":{}}], "has_more": false, "next_url": null, "url": "/accounts"}'
)

c = Courier(auth_token='123456789ABCDF')
Expand All @@ -49,7 +49,9 @@ def test_success_get_accounts():
"default_preferences":{},
"user_profile":{}
}],
"has_more": False
"has_more": False,
"next_url": None,
"url": "/accounts",
}

@responses.activate
Expand Down
8 changes: 4 additions & 4 deletions trycourier/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def get_account(self, account_id):

return resp.json()

def get_accounts(self, limit=None, starting_after=None):
def get_accounts(self, limit=None, cursor=None):
"""
Lists accounts
Args:
limit: The number of accounts to return (default 20, max 100)
starting_after: Value of next_page from previous response
cursor: Value of next_page from previous response
Raises:
CourierAPIException: Any error returned by the Courier API
Expand All @@ -53,8 +53,8 @@ def get_accounts(self, limit=None, starting_after=None):
if limit:
params['limit'] = limit

if starting_after:
params['starting_after'] = starting_after
if cursor:
params['cursor'] = cursor

resp = self.session.get(self.uri, params=params)

Expand Down
2 changes: 1 addition & 1 deletion trycourier/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .notifications import Notifications
from .profiles import Profiles

__version__ = '4.6.0'
__version__ = '4.7.0'


class Courier(object):
Expand Down

0 comments on commit 18e7fcb

Please sign in to comment.