python-amcards 1.2.31__tar.gz → 1.2.33__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.33
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
 
@@ -288,6 +288,11 @@ class Campaign:
288
288
  """Drip campaign's name."""
289
289
  return self._name
290
290
 
291
+ @property
292
+ def drip_count(self) -> int:
293
+ """Drip campaign's drip count."""
294
+ return self._drip_count
295
+
291
296
  @property
292
297
  def send_if_duplicate(self) -> bool:
293
298
  """If True, AMcards will not attempt to detect and prevent duplicates. Otherwise, if this campaign has been previously sent to a contact, further campaign send attempts to the same contact will be prevented."""
@@ -308,6 +313,7 @@ class Campaign:
308
313
  return cls(
309
314
  id=json['id'],
310
315
  name=json['title'],
316
+ drip_count=json['drip_count'],
311
317
  send_if_duplicate=json['send_even_if_duplicate'],
312
318
  has_anniversary_drip=json['has_anniversary_drip'],
313
319
  has_birthday_drip=json['has_birthday_drip'],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-amcards
3
- Version: 1.2.31
3
+ Version: 1.2.33
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.33',
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