To modify data sent for occurences related to one of resources, you can adjust classes responsible for payload building.
These classes are located under src/Builder/Payload directory and have meaningful names corresponding to data that will be provided, e.g. CustomerPayloadBuilderor OrderPayloadBuilder.
Requests send on endpoint designed by User.com are handled by \BitBag\SyliusUserComPlugin\Controller\UserComAgreementsController.
You can adjust this controller to handle requests in a way that suits your needs.
There is designated validator to check if request payload contains required fields.
If there will be any field added by User.com, you can adjust this validator to check if this field is present in request payload.
Also, in BitBag\SyliusUserComPlugin\Assigner\AgreementsAssigner you can adjust existing logic to assign agreements to customer in a way that suits your needs.
The endpoint is exposed in Swagger under UserComAgreements, making it easy to test and explore directly from the API documentation.
If you use several channels, remember to select one of the available channels using the get method and parameters before using the API:
?_channel_code=CHANNEL_CODE
public function assign(CustomerInterface $customer, array $agreements): void
{
foreach ($agreements as $key => $value) {
match ($key) {
'email_agreement' => $customer->setSubscribedToNewsletter($value),
default => $this->logger->error(
sprintf(
'Agreement not found. Key = %s, Value = %s, CustomerId = %s',
$key,
$value,
$customer->getId(),
),
),
};
}
}
}