python-amcards 1.2.31__tar.gz → 1.2.32__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-amcards
3
- Version: 1.2.31
3
+ Version: 1.2.32
4
4
  Summary: A wrapper for the AMcards API.
5
5
  Home-page: https://github.com/simonesestili/python-amcards
6
6
  Author: Simone Sestili
@@ -265,6 +265,29 @@ class AMcardsClient:
265
265
  card_json = res.json()
266
266
  return Card._from_json(card_json)
267
267
 
268
+ def card_count(self, filters: dict = None) -> int:
269
+ """Fetches count of client's AMcards cards.
270
+
271
+ :param Optional[dict] filters: Defaults to ``None``. Filters to be applied when counting cards.
272
+
273
+ A common use case is to use ``filter = {'third_party_contact_id': 'some_target_id'}``, this will fetch all cards that were shipped to a recipient with a ``third_party_contact_id == 'some_target_id'``.
274
+
275
+ :return: The count of client's cards.
276
+ :rtype: int
277
+
278
+ :raises AuthenticationError: When the client's ``access_token`` is invalid.
279
+
280
+ """
281
+ params = {
282
+ 'limit': 1,
283
+ } | (filters or {})
284
+
285
+ res = requests.get(url=f'{DOMAIN}/.api/v1/card/', headers=self._HEADERS, params=params)
286
+ if not res.ok:
287
+ raise exceptions.AuthenticationError('Access token provided to client is unauthorized')
288
+
289
+ return res.json()['meta']['total_count']
290
+
268
291
  def mailing(self, id: str | int) -> Mailing:
269
292
  """Fetches client's AMcards mailing with a specified id.
270
293
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-amcards
3
- Version: 1.2.31
3
+ Version: 1.2.32
4
4
  Summary: A wrapper for the AMcards API.
5
5
  Home-page: https://github.com/simonesestili/python-amcards
6
6
  Author: Simone Sestili
@@ -7,7 +7,7 @@ def README():
7
7
 
8
8
  setup(
9
9
  name='python-amcards',
10
- version='1.2.31',
10
+ version='1.2.32',
11
11
  description='A wrapper for the AMcards API.',
12
12
  long_description=README(),
13
13
  long_description_content_type='text/x-rst',
File without changes