Skip to content

Commit

Permalink
Synchronize publicId with Mailchimp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi authored and Rémi committed Feb 27, 2025
1 parent 5dbbb08 commit f7006a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Mailchimp/Synchronisation/Request/MemberRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MemberRequest implements MemberRequestInterface
{
public const DATE_FORMAT = 'Y-m-d';

public const MERGE_FIELD_PUBLIC_ID = 'PUBLIC_ID';
public const MERGE_FIELD_FIRST_NAME = 'FNAME';
public const MERGE_FIELD_LAST_NAME = 'LNAME';
public const MERGE_FIELD_CITY = 'CITY';
Expand Down
13 changes: 13 additions & 0 deletions src/Mailchimp/Synchronisation/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RequestBuilder implements LoggerAwareInterface
{
use LoggerAwareTrait;

private $publicId;
private $email;
private $gender;
private $firstName;
Expand Down Expand Up @@ -92,6 +93,7 @@ public function createReplaceEmailRequest(string $oldEmail, string $newEmail): M
public function updateFromAdherent(Adherent $adherent): self
{
return $this
->setPublicId($adherent->getPublicId())
->setEmail($adherent->getEmailAddress())
->setGender($adherent->getGender())
->setFirstName($adherent->getFirstName())
Expand Down Expand Up @@ -150,6 +152,13 @@ public function updateFromDataSurvey(JemarcheDataSurvey $dataSurvey, array $zone
return $this;
}

public function setPublicId(string $publicId): self
{
$this->publicId = $publicId;

return $this;
}

public function setEmail(string $email): self
{
$this->email = $email;
Expand Down Expand Up @@ -455,6 +464,10 @@ private function buildMergeFields(): array
{
$mergeFields = [];

if ($this->publicId) {
$mergeFields[MemberRequest::MERGE_FIELD_PUBLIC_ID] = $this->publicId;
}

if ($this->gender) {
$mergeFields[MemberRequest::MERGE_FIELD_GENDER] = $this->gender;
}
Expand Down

0 comments on commit f7006a2

Please sign in to comment.