From 80f22b7cd07d564a50926329d78cdec9b8e1bb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 7 Jan 2026 14:44:53 +0100 Subject: [PATCH] fix: don't include default date of birth in contact form submissions --- src/BusProNet/ApiClient.php | 2 +- src/BusProNet/Model/PersonalData.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/BusProNet/ApiClient.php b/src/BusProNet/ApiClient.php index b83f9df..761fac8 100644 --- a/src/BusProNet/ApiClient.php +++ b/src/BusProNet/ApiClient.php @@ -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', ]; diff --git a/src/BusProNet/Model/PersonalData.php b/src/BusProNet/Model/PersonalData.php index df0b06b..3e5a1bf 100644 --- a/src/BusProNet/Model/PersonalData.php +++ b/src/BusProNet/Model/PersonalData.php @@ -71,17 +71,11 @@ class PersonalData * * @return array 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