Skip to content

Commit 08ade4f

Browse files
committed
[UC-25] Add payload to user events
1 parent a943e80 commit 08ade4f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/Updater/CustomerWithKeyUpdater.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ private function updateForUserWithoutEmail(
133133
;
134134

135135
$id = $customerFoundByEmailId ?? $userFromUserKey['id'];
136+
$payload = $this->buildPayload($email, $customer, $address);
136137

137138
$user = $this->userApi->updateUser(
138139
$apiAwareResource,
139140
$id,
140-
$this->buildPayload($email, $customer, $address),
141+
$payload,
141142
);
142143

143144
if (is_array($customerFoundByEmail) &&
@@ -147,7 +148,7 @@ private function updateForUserWithoutEmail(
147148
$this->userApi->mergeUsers($apiAwareResource, $customerFoundByEmail['id'], [$userFromUserKey['id']]);
148149
}
149150

150-
$this->sendEvent($apiAwareResource, $email, $eventName);
151+
$this->sendEvent($apiAwareResource, $email, $eventName, $payload);
151152

152153
return $user;
153154
}

src/Updater/CustomerWithoutKeyUpdater.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function updateWithoutUserKey(
6363
if (false === is_array($user) || false === array_key_exists('id', $user)) {
6464
throw new \RuntimeException('User was not created or updated.');
6565
}
66-
$this->sendEvent($userApiAwareResource, $user['email'], $eventName);
66+
$this->sendEvent($userApiAwareResource, $user['email'], $eventName, $payload);
6767

6868
return $user;
6969
}
@@ -76,13 +76,14 @@ protected function buildPayload(
7676
return $this->customerPayloadBuilder->build($email, $customer, $address);
7777
}
7878

79-
protected function sendEvent(UserComApiAwareInterface $resource, string $userCustomId, string $event): void
79+
protected function sendEvent(UserComApiAwareInterface $resource, string $userCustomId, string $event, ?array $payload = null): void
8080
{
8181
$this->userApi->createEventForUser(
8282
$resource,
8383
$userCustomId,
8484
[
8585
'name' => $event,
86+
'data' => $payload,
8687
],
8788
);
8889
}

0 commit comments

Comments
 (0)