python-amcards 1.6.2__tar.gz → 1.7.1__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.6.2 → python_amcards-1.7.1}/PKG-INFO +1 -1
- {python_amcards-1.6.2 → python_amcards-1.7.1}/amcards/amcards.py +18 -17
- {python_amcards-1.6.2 → python_amcards-1.7.1}/python_amcards.egg-info/PKG-INFO +1 -1
- {python_amcards-1.6.2 → python_amcards-1.7.1}/setup.py +1 -1
- {python_amcards-1.6.2 → python_amcards-1.7.1}/LICENSE +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/README.rst +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/amcards/__helpers.py +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/amcards/__init__.py +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/amcards/exceptions.py +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/amcards/models.py +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/python_amcards.egg-info/SOURCES.txt +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/python_amcards.egg-info/dependency_links.txt +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/python_amcards.egg-info/requires.txt +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/python_amcards.egg-info/top_level.txt +0 -0
- {python_amcards-1.6.2 → python_amcards-1.7.1}/setup.cfg +0 -0
|
@@ -1124,7 +1124,7 @@ class AMcardsClient:
|
|
|
1124
1124
|
'birth_date': '2003-12-25', # OPTIONAL
|
|
1125
1125
|
'anniversary_date': '2022-10-31', # OPTIONAL
|
|
1126
1126
|
'third_party_contact_id': 'crmid1453131', # OPTIONAL
|
|
1127
|
-
'address_line_2': 'Apt 2'
|
|
1127
|
+
'address_line_2': 'Apt 2', # OPTIONAL
|
|
1128
1128
|
'extra_data': { # OPTIONAL
|
|
1129
1129
|
'carMake': 'Honda', # OPTIONAL
|
|
1130
1130
|
} # OPTIONAL
|
|
@@ -1136,43 +1136,44 @@ class AMcardsClient:
|
|
|
1136
1136
|
|
|
1137
1137
|
:raises CampaignMultiSendError: When something goes wrong when attempting to send a drip campaign.
|
|
1138
1138
|
:raises AuthenticationError: When the client's ``access_token`` is invalid.
|
|
1139
|
-
:raises ShippingAddressError: When
|
|
1140
|
-
:raises DateFormatError: When one of the dates provided is not in ``"YYYY-MM-DD"`` format.
|
|
1141
|
-
:raises PhoneFormatError: When the ``phone_number`` is not a digit string of length 10.
|
|
1139
|
+
:raises ShippingAddressError: When none of the provided contacts are valid after validation. Contacts missing required fields or with invalid optional fields are skipped.
|
|
1142
1140
|
:raises InsufficientCreditsError: When the client's user has insufficient credits in their balance.
|
|
1143
1141
|
|
|
1144
1142
|
"""
|
|
1143
|
+
contacts_to_send = []
|
|
1144
|
+
|
|
1145
1145
|
# Validate contacts
|
|
1146
|
-
for
|
|
1146
|
+
for contact in contacts:
|
|
1147
1147
|
missings = helpers.get_missing_required_shipping_address_fields(contact)
|
|
1148
|
-
if missings:
|
|
1149
|
-
|
|
1150
|
-
raise exceptions.ShippingAddressError(error_message)
|
|
1148
|
+
if not missings:
|
|
1149
|
+
contacts_to_send.append(contact)
|
|
1151
1150
|
|
|
1152
1151
|
# Sanitize contacts
|
|
1153
|
-
|
|
1152
|
+
contacts_to_send = [helpers.sanitize_contact_for_campaign_multi_send(contact) for contact in contacts_to_send]
|
|
1154
1153
|
|
|
1155
|
-
|
|
1154
|
+
valid_contacts = []
|
|
1155
|
+
for contact in contacts_to_send:
|
|
1156
1156
|
# Validate birth_date
|
|
1157
1157
|
if 'birth_date' in contact and not helpers.is_valid_birthdate(contact['birth_date']):
|
|
1158
|
-
|
|
1159
|
-
raise exceptions.DateFormatError(error_message)
|
|
1158
|
+
continue
|
|
1160
1159
|
# Validate anniversary_date
|
|
1161
1160
|
if 'anniversary_date' in contact and not helpers.is_valid_date(contact['anniversary_date']):
|
|
1162
|
-
|
|
1163
|
-
raise exceptions.DateFormatError(error_message)
|
|
1161
|
+
continue
|
|
1164
1162
|
# Validate phone_number
|
|
1165
1163
|
if 'phone_number' in contact and not helpers.is_valid_phone(contact['phone_number']):
|
|
1166
|
-
|
|
1167
|
-
raise exceptions.PhoneFormatError(error_message)
|
|
1164
|
+
continue
|
|
1168
1165
|
if 'extra_data' in contact:
|
|
1169
1166
|
contact['extra_data'] = helpers.sanitize_extra_data(contact['extra_data'])
|
|
1167
|
+
valid_contacts.append(contact)
|
|
1168
|
+
|
|
1169
|
+
if not valid_contacts:
|
|
1170
|
+
raise exceptions.ShippingAddressError('No valid contacts to send')
|
|
1170
1171
|
|
|
1171
1172
|
# Build request json payload
|
|
1172
1173
|
body = {
|
|
1173
1174
|
'campaign_id': campaign_id,
|
|
1174
1175
|
'initiator': initiator,
|
|
1175
|
-
'contacts':
|
|
1176
|
+
'contacts': valid_contacts,
|
|
1176
1177
|
}
|
|
1177
1178
|
|
|
1178
1179
|
res = requests.post(f'{DOMAIN}/campaigns/open-campaign-multi-form/', json=body, headers=self._HEADERS)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|