python-amcards 1.3.3__py3-none-any.whl → 1.3.4__py3-none-any.whl

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.
amcards/__helpers.py CHANGED
@@ -78,13 +78,27 @@ def get_missing_required_shipping_address_fields(shipping_address: dict) -> list
78
78
  return missings
79
79
 
80
80
  def is_valid_date(date: str) -> bool:
81
- if not isinstance(date, str): return False
82
- if len(date) != 10: return False
83
- if date.count('-') != 2 or date[4] != '-' or date[7] != '-': return False
84
- for part in date.split('-'):
85
- if not part.isdigit():
86
- return False
87
- return True
81
+ if not isinstance(date, str):
82
+ return False
83
+ try:
84
+ datetime.datetime.strptime(date, '%Y-%m-%d')
85
+ return True
86
+ except:
87
+ return False
88
+
89
+ def is_valid_birthdate(date: str) -> bool:
90
+ if not isinstance(date, str):
91
+ return False
92
+ try:
93
+ datetime.datetime.strptime(date, '%Y-%m-%d')
94
+ return True
95
+ except:
96
+ pass
97
+ try:
98
+ datetime.datetime.strptime(date, '%m-%d')
99
+ return True
100
+ except:
101
+ return False
88
102
 
89
103
  def is_valid_phone(phone: str) -> bool:
90
104
  if not isinstance(phone, str): return False
amcards/amcards.py CHANGED
@@ -855,7 +855,7 @@ class AMcardsClient:
855
855
  return_address = {f'return_{key}': value for key, value in return_address.items()}
856
856
 
857
857
  # Validate birth_date
858
- if 'birth_date' in shipping_address and not helpers.is_valid_date(shipping_address['birth_date']):
858
+ if 'birth_date' in shipping_address and not helpers.is_valid_birthdate(shipping_address['birth_date']):
859
859
  error_message = 'Invalid birth_date format, please specify date as "YYYY-MM-DD", or omit it'
860
860
  raise exceptions.DateFormatError(error_message)
861
861
  # Validate anniversary_date
@@ -1010,7 +1010,7 @@ class AMcardsClient:
1010
1010
  return_address = {f'return_{key}': value for key, value in return_address.items()}
1011
1011
 
1012
1012
  # Validate birth_date
1013
- if 'birth_date' in shipping_address and not helpers.is_valid_date(shipping_address['birth_date']):
1013
+ if 'birth_date' in shipping_address and not helpers.is_valid_birthdate(shipping_address['birth_date']):
1014
1014
  error_message = 'Invalid birth_date format, please specify date as "YYYY-MM-DD", or omit it'
1015
1015
  raise exceptions.DateFormatError(error_message)
1016
1016
  # Validate anniversary_date
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-amcards
3
- Version: 1.3.3
3
+ Version: 1.3.4
4
4
  Summary: A wrapper for the AMcards API.
5
5
  Home-page: https://github.com/simonesestili/python-amcards
6
6
  Author: Simone Sestili
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Description-Content-Type: text/x-rst
15
15
  License-File: LICENSE
16
- Requires-Dist: requests >=2
16
+ Requires-Dist: requests>=2
17
17
 
18
18
  Getting Started | See the full docs at `Read the Docs <https://python-amcards.readthedocs.io/en/latest/>`_
19
19
  ==========================================================================================================
@@ -0,0 +1,10 @@
1
+ amcards/__helpers.py,sha256=ECj3f2eg6jj5MolS9uY01do9-y4PImu9sfsXwqSUIHU,5687
2
+ amcards/__init__.py,sha256=nl-oq4BKdYSQZPNbtraEMHFf_8MU8gSOlJZIYxKudcM,34
3
+ amcards/amcards.py,sha256=NPNbscI4MawIWW0ZlfDCB7xtiwqSfUi1R-WF98pSEwk,63028
4
+ amcards/exceptions.py,sha256=wPu5lipT4oTJ2h-NY82jO_AjG68flmbFpcA-0xy0t_w,1978
5
+ amcards/models.py,sha256=ZuO5268HrIdYjhnzrDk1B0tDeMuQ2GekKkonOqttwEI,30973
6
+ python_amcards-1.3.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
+ python_amcards-1.3.4.dist-info/METADATA,sha256=qbNK62qLsJmrta99oK3cPAeZZAAQtL2WiH78-8pMgdA,3076
8
+ python_amcards-1.3.4.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
9
+ python_amcards-1.3.4.dist-info/top_level.txt,sha256=xst-AU0pzvWXz3DQR-QICIruzgcf4Bkt6FF_GldcIck,8
10
+ python_amcards-1.3.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- amcards/__helpers.py,sha256=iQ3L-79XyDBoE8ZsenCac7xii-1LN86Go3w_yu95VaE,5466
2
- amcards/__init__.py,sha256=nl-oq4BKdYSQZPNbtraEMHFf_8MU8gSOlJZIYxKudcM,34
3
- amcards/amcards.py,sha256=FyFOS_LGp676qRL8DVXWyYP7zrMJO79a0WjRNF38Vbo,63018
4
- amcards/exceptions.py,sha256=wPu5lipT4oTJ2h-NY82jO_AjG68flmbFpcA-0xy0t_w,1978
5
- amcards/models.py,sha256=ZuO5268HrIdYjhnzrDk1B0tDeMuQ2GekKkonOqttwEI,30973
6
- python_amcards-1.3.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
- python_amcards-1.3.3.dist-info/METADATA,sha256=MIisp55rILg9GwyvEDpi4Ere_kQy8lavHeGxuBfJV84,3077
8
- python_amcards-1.3.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
9
- python_amcards-1.3.3.dist-info/top_level.txt,sha256=xst-AU0pzvWXz3DQR-QICIruzgcf4Bkt6FF_GldcIck,8
10
- python_amcards-1.3.3.dist-info/RECORD,,