-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: be defensive about pulling external_id from braze export
- Loading branch information
1 parent
9e7a0d9
commit 5a1f485
Showing
3 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Python client for interacting with Braze APIs. | ||
""" | ||
|
||
__version__ = '0.2.0' | ||
__version__ = '0.2.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,7 @@ def get_braze_external_id(self, email): | |
} | ||
response = self._make_request(payload, BrazeAPIEndpoints.EXPORT_IDS, REQUEST_TYPE_POST) | ||
if response['users'] and 'external_id' in response['users'][0]: | ||
return response['users'][0]['external_id'] | ||
return response['users'][0].get('external_id') | ||
|
||
return None | ||
|
||
|
@@ -147,7 +147,10 @@ def get_braze_external_id_batch(self, emails, alias_label): | |
https://www.braze.com/docs/api/endpoints/export/user_data/post_users_identifier/ | ||
"Up to 50 external_ids or user_aliases can be included in a single request. | ||
Should you want to specify device_id or email_address | ||
only one of either identifier can be included per request." | ||
only one of either identifier can be included per request. | ||
[...] | ||
if a field is missing from the object it should be assumed to be null, false, or empty | ||
" | ||
Arguments: | ||
emails (list(str)): e.g. ['[email protected]', '[email protected]'] | ||
|
@@ -174,7 +177,7 @@ def get_braze_external_id_batch(self, emails, alias_label): | |
response = self._make_request(payload, BrazeAPIEndpoints.EXPORT_IDS, REQUEST_TYPE_POST) | ||
|
||
for identified_user in response['users']: | ||
external_ids_by_email[identified_user['email']] = identified_user['external_id'] | ||
external_ids_by_email[identified_user['email']] = identified_user.get('external_id') | ||
|
||
logger.info(f'external ids from batch identify braze users response: {external_ids_by_email}') | ||
return external_ids_by_email | ||
|