<?php
declare(strict_types=1);
namespace App\Model;
use App\Validator as AppAssert;
use OpenApi\Annotations as OA;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @OA\Schema(
* schema="Email",
* required={"templatePath", "to"}
* )
*/
class Email
{
public const DEFAULT_FROM = 'console';
public const DEFAULT_FROM_NAME = 'HiPay';
/**
* @OA\Property(
* type="string",
* description="The path of a template that you would like to use.",
* example="account-api/hello"
* )
*
* @var string
* @AppAssert\TemplatePath()
*/
#[Assert\NotBlank]
private $templatePath;
/**
* @OA\Property(
* type="object",
* description="Template variables, expecting : {""firstname"": ""John"", ""lastname"": ""Doe""}",
* @OA\Property(property="key", type="string", example="value")
* )
*
* @AppAssert\TemplateData()
*
* @var array
*/
private $templateData = [];
/**
* @OA\Property(
* type="string",
* description="The subject of your email"
* )
*
* @var string
*/
#[Assert\Type('string')]
#[Assert\Length(min: 1, max: 255)]
private $subject;
/**
* @OA\Property(
* type="string",
* description="The email local-part",
* example="console"
* )
*
* @var string
*/
#[Assert\NotBlank]
#[Assert\Type('string')]
#[Assert\Regex('/^[0-9A-Za-z-+.]+$/', message: 'Invalid email local-part, provide a value without @domain.tld')]
private $from = self::DEFAULT_FROM;
/**
* @OA\Property(
* type="string",
* description="The email display name",
* example="HiPay"
* )
*
* @var string
*/
#[Assert\NotBlank]
#[Assert\Type('string')]
private $fromName = self::DEFAULT_FROM_NAME;
/**
* @OA\Property(
* type="array",
* description="An array of repliers, ex: [""[email protected]"", ""Jane Doe <[email protected]>""]",
* @OA\Items(type="string", example="[email protected]")
* )
* @var array
*/
#[Assert\Type('array')]
#[Assert\Count(max: 1000, maxMessage: 'You cannot specify more than {{ limit }} emails')]
#[Assert\All([new Assert\NotBlank(), new Assert\Type('string'), new AppAssert\EmailAddress()])]
private $reply = [];
/**
* @OA\Property(
* type="array",
* description="An array of recipients, ex: [""[email protected]"", ""Jane Doe <[email protected]>""]",
* @OA\Items(type="string", example="[email protected]")
* )
* @var array
*/
#[Assert\NotBlank]
#[Assert\Type('array')]
#[Assert\Count(min: 1, max: 1000, minMessage: 'You must specify at least one email', maxMessage: 'You cannot specify more than {{ limit }} emails')]
#[Assert\All([new Assert\NotBlank(), new Assert\Type('string'), new AppAssert\EmailAddress()])]
private $to = [];
/**
* @OA\Property(
* type="array",
* description="An array of recipients, ex: [""[email protected]"", ""Jane Doe <[email protected]>""]",
* @OA\Items(type="string", example="[email protected]")
* )
* @var array
*/
#[Assert\Type('array')]
#[Assert\Count(max: 1000, maxMessage: 'You cannot specify more than {{ limit }} emails')]
#[Assert\All([new Assert\NotBlank(), new Assert\Type('string'), new AppAssert\EmailAddress()])]
private $cc = [];
/**
* @OA\Property(
* type="array",
* description="An array of recipients, ex: [""[email protected]"", ""Jane Doe <[email protected]>""]",
* @OA\Items(type="string", example="[email protected]")
* )
* @var array
*/
#[Assert\Type('array')]
#[Assert\Count(max: 1000, maxMessage: 'You cannot specify more than {{ limit }} emails')]
#[Assert\All([new Assert\NotBlank(), new Assert\Type('string'), new AppAssert\EmailAddress()])]
private $bcc = [];
/**
* @OA\Property(
* type="array",
* description="An array of objects in which you can specify any attachments you want to include.",
* @OA\Items(
* required={"filename", "contentType", "content"},
* @OA\Property(
* property="filename",
* type="string",
* description="The filename of the attachment.",
* example="filename.pdf",
* ),
* @OA\Property(
* property="contentType",
* type="string",
* description="The content type of the attachment (ex: image/jpeg).",
* ),
* @OA\Property(
* property="content",
* type="string",
* description="The Base64 encoded content of the attachment.",
* )
* ),
* ),
*
* @var array
*/
#[Assert\All([new Assert\Collection(fields: ['filename' => [new Assert\NotBlank(), new Assert\Type('string')], 'contentType' => [new Assert\NotBlank(), new Assert\Type('string')], 'content' => [new Assert\NotBlank(), new Assert\Type('string')]], allowMissingFields: false, allowExtraFields: false)])]
private $attachments;
/**
* @OA\Property(
* type="string",
* description="Set the locale for the email template",
* example="fr_FR"
* )
*
* @var string
*/
#[Assert\Locale]
private $locale;
/**
* @OA\Property(
* type="boolean",
* description="Prevent sending the mail and view debug info",
* example=true
* )
*
* @var bool
*/
#[Assert\Type('boolean')]
private $debug = false;
/**
* @return array
*/
public function getTo(): array
{
return $this->to;
}
/**
* @param array $to
*/
public function setTo(array $to): void
{
$this->to = $to;
}
/**
* @return string
*/
public function getTemplatePath(): string
{
return $this->templatePath;
}
/**
* @param string $templatePath
*/
public function setTemplatePath(string $templatePath): void
{
$this->templatePath = $templatePath;
}
/**
* @return array
*/
public function getTemplateData(): array
{
return $this->templateData;
}
/**
* @param array $templateData
*/
public function setTemplateData(array $templateData): void
{
$this->templateData = $templateData;
}
/**
* @return string
*/
public function getSubject(): ?string
{
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject(string $subject): void
{
$this->subject = $subject;
}
/**
* @return string
*/
public function getFrom(): string
{
return $this->from;
}
/**
* @param string $from
*/
public function setFrom(string $from): void
{
$this->from = $from;
}
/**
* @return string
*/
public function getFromName(): string
{
return $this->fromName;
}
/**
* @param string $fromName
*/
public function setFromName(string $fromName): void
{
$this->fromName = $fromName;
}
/**
* @return array
*/
public function getReply(): array
{
return $this->reply;
}
/**
* @param array $reply
*/
public function setReply(array $reply): void
{
$this->reply = $reply;
}
/**
* @return array
*/
public function getCc(): array
{
return $this->cc;
}
/**
* @param array $cc
*/
public function setCc(array $cc): void
{
$this->cc = $cc;
}
/**
* @return array
*/
public function getBcc(): array
{
return $this->bcc;
}
/**
* @param array $bcc
*/
public function setBcc(array $bcc): void
{
$this->bcc = $bcc;
}
/**
* @return array
*/
public function getAttachments(): ?array
{
return $this->attachments;
}
/**
* @param array $attachments
*/
public function setAttachments(array $attachments): void
{
$this->attachments = $attachments;
}
/**
* @return string
*/
public function getLocale(): ?string
{
return $this->locale;
}
/**
* @param string $locale
*/
public function setLocale(string $locale): void
{
$this->locale = $locale;
}
/**
* @return bool
*/
public function isDebug(): bool
{
return $this->debug;
}
/**
* @param bool $debug
*/
public function setDebug(bool $debug): void
{
$this->debug = $debug;
}
}