fix: don't include default date of birth in contact form submissions
This commit is contained in:
@@ -151,7 +151,7 @@ class ApiClient
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_CUSTOMER_DATA),
|
||||
'satz' => ['@typ' => static::TYPE_CUSTOMER_DATA],
|
||||
'art' => 'Adresse_Neu',
|
||||
'adressdaten' => $personalData->toPayload(),
|
||||
'adressdaten' => $personalData->toPayload(false),
|
||||
'ohnemailversand' => 'True',
|
||||
];
|
||||
|
||||
|
||||
@@ -71,17 +71,11 @@ class PersonalData
|
||||
*
|
||||
* @return array<string, mixed> The payload array for API transmission
|
||||
*/
|
||||
public function toPayload(): array
|
||||
public function toPayload(bool $includeDateOfBirth = true): array
|
||||
{
|
||||
// Ensure date of birth is populated
|
||||
if (null === $dob = $this->dateOfBirth) {
|
||||
$dob = new \DateTimeImmutable(self::DEFAULT_AGE_YEARS.' years ago');
|
||||
}
|
||||
|
||||
return [
|
||||
$payload = [
|
||||
'idadresse' => $this->addressId,
|
||||
'idadresseperson' => $this->personId,
|
||||
'geburtsdatum' => $dob->format('d.m.Y'),
|
||||
'anrede' => $this->salutation,
|
||||
'geschlecht' => $this->gender,
|
||||
'nationalitaet' => $this->nationality,
|
||||
@@ -95,6 +89,13 @@ class PersonalData
|
||||
'sonstiges3' => $this->shoeSize,
|
||||
'bemerkung' => $this->remarks,
|
||||
];
|
||||
|
||||
if (true === $includeDateOfBirth) {
|
||||
$dob = $this->dateOfBirth ?? new \DateTimeImmutable(self::DEFAULT_AGE_YEARS . ' years ago');
|
||||
$payload['geburtsdatum'] = $dob->format('d.m.Y');
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
public static function fromContactFormSubmission(ContactFormSubmission $dto): self
|
||||
|
||||
Reference in New Issue
Block a user