Files
myep/src/BusProNet/Model/Communication.php
T

47 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Represents communication information including email, phone, and newsletter preferences.
*
* This class handles contact information for users and participants in the booking system.
* It provides validation constraints for required fields and methods to convert
* communication data to API payload format.
*/
class Communication
{
public ?string $phone = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public ?string $mobile = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
#[Assert\Email(message: 'Bitte eine gültige Adresse angeben', mode: 'strict', groups: ['personal_data'])]
public ?string $email = null;
public bool $newsletter = false;
/**
* Converts the communication data to API payload format.
*
* Transforms the communication object into an array structure suitable
* for API communication with the BusProNet system.
*
* @return array<string, string> The payload array for API transmission
*/
public function toPayload(): array
{
return [
'email' => $this->email,
'telefonmobil' => $this->mobile,
'telefonprivat' => $this->phone,
'newsletter' => $this->newsletter ? 'True' : 'False',
];
}
}