Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix du nom et prénom dans la synchronisation des contacts avec Brevo #1311

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lemarche/utils/apis/api_brevo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def create_contact(user, list_id: int):
email=user.email,
list_ids=[list_id],
attributes={
"NOM": user.first_name,
"PRENOM": user.last_name,
"NOM": user.last_name,
"PRENOM": user.first_name,
"DATE_INSCRIPTION": user.created_at,
"TYPE_ORGANISATION": user.buyer_kind_detail,
"NOM_ENTREPRISE": user.company_name,
Expand All @@ -62,6 +62,17 @@ def create_contact(user, list_id: int):
logger.error(f"Exception when calling Brevo->ContactsApi->create_contact: {e}")


def update_contact(user_identifier: str, attributes_to_update: dict):
api_client = get_api_client()
api_instance = sib_api_v3_sdk.ContactsApi(api_client)
update_contact = sib_api_v3_sdk.UpdateContact(attributes=attributes_to_update)
try:
api_response = api_instance.update_contact(identifier=user_identifier, update_contact=update_contact)
logger.info(f"Success Brevo->ContactsApi->update_contact: {api_response}")
except ApiException as e:
logger.error(f"Exception when calling Brevo->ContactsApi->update_contact: {e}")


def remove_contact_from_list(user, list_id: int):
api_client = get_api_client()
api_instance = sib_api_v3_sdk.ContactsApi(api_client)
Expand Down
Loading