python-amcards 1.2.30__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.
- {python-amcards-1.2.30 → python_amcards-1.2.32}/PKG-INFO +1 -1
- {python-amcards-1.2.30 → python_amcards-1.2.32}/amcards/amcards.py +27 -2
- {python-amcards-1.2.30 → python_amcards-1.2.32}/amcards/models.py +13 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/PKG-INFO +1 -1
- {python-amcards-1.2.30 → python_amcards-1.2.32}/setup.py +1 -1
- {python-amcards-1.2.30 → python_amcards-1.2.32}/LICENSE +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/README.rst +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/amcards/__helpers.py +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/amcards/__init__.py +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/amcards/exceptions.py +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/SOURCES.txt +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/dependency_links.txt +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/requires.txt +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/top_level.txt +0 -0
- {python-amcards-1.2.30 → python_amcards-1.2.32}/setup.cfg +0 -0
|
@@ -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
|
|
|
@@ -579,7 +602,8 @@ class AMcardsClient:
|
|
|
579
602
|
'postal_code': '48075',
|
|
580
603
|
'country': 'US',
|
|
581
604
|
'organization': 'Google', # OPTIONAL
|
|
582
|
-
'third_party_contact_id': 'crmid1453131'
|
|
605
|
+
'third_party_contact_id': 'crmid1453131',# OPTIONAL
|
|
606
|
+
'address_line_2': 'Apt 2' # OPTIONAL
|
|
583
607
|
}
|
|
584
608
|
|
|
585
609
|
:param Optional[dict] return_address: Dict of return details that will override the client's AMcards user default return details. Here's an example how the dict might look, all of the keys are optional:
|
|
@@ -863,7 +887,8 @@ class AMcardsClient:
|
|
|
863
887
|
'phone_number': '15556667777', # OPTIONAL
|
|
864
888
|
'birth_date': '2003-12-25', # OPTIONAL
|
|
865
889
|
'anniversary_date': '2022-10-31', # OPTIONAL
|
|
866
|
-
'third_party_contact_id': 'crmid1453131'
|
|
890
|
+
'third_party_contact_id': 'crmid1453131',# OPTIONAL
|
|
891
|
+
'address_line_2': 'Apt 2' # OPTIONAL
|
|
867
892
|
}
|
|
868
893
|
|
|
869
894
|
:param Optional[dict] return_address: Dict of return details that will override the client's AMcards user default return details. Here's an example how the dict might look, all of the keys are optional:
|
|
@@ -344,6 +344,7 @@ class Card:
|
|
|
344
344
|
campaign_id: Optional[int],
|
|
345
345
|
shipping_address: dict,
|
|
346
346
|
return_address: dict,
|
|
347
|
+
gifts: List[Gift],
|
|
347
348
|
) -> None:
|
|
348
349
|
self._id = id
|
|
349
350
|
self._amount_charged = amount_charged
|
|
@@ -359,6 +360,7 @@ class Card:
|
|
|
359
360
|
self._campaign_id = campaign_id
|
|
360
361
|
self._shipping_address = shipping_address
|
|
361
362
|
self._return_address = return_address
|
|
363
|
+
self._gifts = gifts
|
|
362
364
|
|
|
363
365
|
__repr__ = helpers.repr
|
|
364
366
|
|
|
@@ -474,6 +476,11 @@ class Card:
|
|
|
474
476
|
"""
|
|
475
477
|
return self._return_address
|
|
476
478
|
|
|
479
|
+
@property
|
|
480
|
+
def gifts(self) -> List[Gift]:
|
|
481
|
+
"""Gifts attached to this card."""
|
|
482
|
+
return self._gifts
|
|
483
|
+
|
|
477
484
|
@classmethod
|
|
478
485
|
def _from_json(cls, json: dict):
|
|
479
486
|
return cls(
|
|
@@ -491,6 +498,12 @@ class Card:
|
|
|
491
498
|
campaign_id=json['campaign_pk'],
|
|
492
499
|
shipping_address=helpers.parse_shipping_address(json),
|
|
493
500
|
return_address=helpers.parse_return_address(json),
|
|
501
|
+
gifts=[Gift(
|
|
502
|
+
name=gift['name'],
|
|
503
|
+
thumbnail='',
|
|
504
|
+
base_cost=gift['price'],
|
|
505
|
+
shipping_and_handling_cost=gift['shipping_and_handling'],
|
|
506
|
+
) for gift in json['gifts']],
|
|
494
507
|
)
|
|
495
508
|
|
|
496
509
|
class MailingStatus(Enum):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python-amcards-1.2.30 → python_amcards-1.2.32}/python_amcards.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|