Notification.php
404 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Entity\Notification; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Collection\Collection; |
| 6 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 7 | use AmeliaBooking\Domain\ValueObjects\DateTime\TimeOfDay; |
| 8 | use AmeliaBooking\Domain\ValueObjects\Duration; |
| 9 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 10 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 11 | use AmeliaBooking\Domain\ValueObjects\String\BookingType; |
| 12 | use AmeliaBooking\Domain\ValueObjects\String\Html; |
| 13 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo; |
| 15 | use AmeliaBooking\Domain\ValueObjects\String\NotificationStatus; |
| 16 | use AmeliaBooking\Domain\ValueObjects\String\NotificationType; |
| 17 | |
| 18 | /** |
| 19 | * Class Notification |
| 20 | * |
| 21 | * @package AmeliaBooking\Domain\Entity\Notification |
| 22 | */ |
| 23 | class Notification |
| 24 | { |
| 25 | /** @var Id */ |
| 26 | private $id; |
| 27 | |
| 28 | /** @var Name */ |
| 29 | private $name; |
| 30 | |
| 31 | /** @var string */ |
| 32 | private $customName; |
| 33 | |
| 34 | /** @var NotificationStatus */ |
| 35 | private $status; |
| 36 | |
| 37 | /** @var TimeOfDay */ |
| 38 | private $time; |
| 39 | |
| 40 | /** @var Duration */ |
| 41 | private $timeBefore; |
| 42 | |
| 43 | /** @var Duration */ |
| 44 | private $timeAfter; |
| 45 | |
| 46 | /** @var NotificationType */ |
| 47 | private $type; |
| 48 | |
| 49 | /** @var NotificationSendTo */ |
| 50 | private $sendTo; |
| 51 | |
| 52 | /** @var Name */ |
| 53 | private $subject; |
| 54 | |
| 55 | /** @var Html */ |
| 56 | private $content; |
| 57 | |
| 58 | /** @var BookingType */ |
| 59 | private $entity; |
| 60 | |
| 61 | /** @var Json */ |
| 62 | private $translations; |
| 63 | |
| 64 | /** @var array */ |
| 65 | private $entityIds; |
| 66 | |
| 67 | /** @var BooleanValueObject */ |
| 68 | private $sendOnlyMe; |
| 69 | |
| 70 | /** @var Json */ |
| 71 | private $minimumTimeBeforeBooking; |
| 72 | |
| 73 | /** @var string */ |
| 74 | private $whatsAppTemplate; |
| 75 | |
| 76 | /** |
| 77 | * Notification constructor. |
| 78 | * |
| 79 | * @param Name $name |
| 80 | * @param NotificationStatus $status |
| 81 | * @param NotificationType $type |
| 82 | * @param BookingType $entity |
| 83 | * @param NotificationSendTo $sendTo |
| 84 | * @param Name $subject |
| 85 | * @param Html $content |
| 86 | */ |
| 87 | public function __construct( |
| 88 | Name $name, |
| 89 | NotificationStatus $status, |
| 90 | NotificationType $type, |
| 91 | BookingType $entity, |
| 92 | NotificationSendTo $sendTo, |
| 93 | Name $subject, |
| 94 | Html $content |
| 95 | ) { |
| 96 | $this->name = $name; |
| 97 | $this->status = $status; |
| 98 | $this->type = $type; |
| 99 | $this->entity = $entity; |
| 100 | $this->sendTo = $sendTo; |
| 101 | $this->subject = $subject; |
| 102 | $this->content = $content; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @return Id |
| 107 | */ |
| 108 | public function getId() |
| 109 | { |
| 110 | return $this->id; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @param Id $id |
| 115 | */ |
| 116 | public function setId(Id $id) |
| 117 | { |
| 118 | $this->id = $id; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @return Name |
| 123 | */ |
| 124 | public function getName() |
| 125 | { |
| 126 | return $this->name; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @param Name $name |
| 131 | */ |
| 132 | public function setName(Name $name) |
| 133 | { |
| 134 | $this->name = $name; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @return string |
| 139 | */ |
| 140 | public function getCustomName() |
| 141 | { |
| 142 | return $this->customName; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @param string $customName |
| 147 | */ |
| 148 | public function setCustomName($customName) |
| 149 | { |
| 150 | $this->customName = $customName; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @return NotificationStatus |
| 155 | */ |
| 156 | public function getStatus() |
| 157 | { |
| 158 | return $this->status; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @param NotificationStatus $status |
| 163 | */ |
| 164 | public function setStatus(NotificationStatus $status) |
| 165 | { |
| 166 | $this->status = $status; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @return NotificationType |
| 171 | */ |
| 172 | public function getType() |
| 173 | { |
| 174 | return $this->type; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @param NotificationType $type |
| 179 | */ |
| 180 | public function setType(NotificationType $type) |
| 181 | { |
| 182 | $this->type = $type; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * @return BookingType |
| 187 | */ |
| 188 | public function getEntity() |
| 189 | { |
| 190 | return $this->entity; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @param BookingType $entity |
| 195 | */ |
| 196 | public function setEntity(BookingType $entity) |
| 197 | { |
| 198 | $this->entity = $entity; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * @return TimeOfDay |
| 203 | */ |
| 204 | public function getTime() |
| 205 | { |
| 206 | return $this->time; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * @param TimeOfDay $time |
| 211 | */ |
| 212 | public function setTime($time) |
| 213 | { |
| 214 | $this->time = $time; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * @return Duration |
| 219 | */ |
| 220 | public function getTimeBefore() |
| 221 | { |
| 222 | return $this->timeBefore; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @param Duration $timeBefore |
| 227 | */ |
| 228 | public function setTimeBefore($timeBefore) |
| 229 | { |
| 230 | $this->timeBefore = $timeBefore; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * @return Duration |
| 235 | */ |
| 236 | public function getTimeAfter() |
| 237 | { |
| 238 | return $this->timeAfter; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * @param Duration $timeAfter |
| 243 | */ |
| 244 | public function setTimeAfter($timeAfter) |
| 245 | { |
| 246 | $this->timeAfter = $timeAfter; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * @return NotificationSendTo |
| 251 | */ |
| 252 | public function getSendTo() |
| 253 | { |
| 254 | return $this->sendTo; |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * @param NotificationSendTo $sendTo |
| 259 | */ |
| 260 | public function setSendTo(NotificationSendTo $sendTo) |
| 261 | { |
| 262 | $this->sendTo = $sendTo; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * @return Name |
| 267 | */ |
| 268 | public function getSubject() |
| 269 | { |
| 270 | return $this->subject; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * @param Name $subject |
| 275 | */ |
| 276 | public function setSubject(Name $subject) |
| 277 | { |
| 278 | $this->subject = $subject; |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * @return Html |
| 283 | */ |
| 284 | public function getContent() |
| 285 | { |
| 286 | return $this->content; |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * @param Html $content |
| 291 | */ |
| 292 | public function setContent(Html $content) |
| 293 | { |
| 294 | $this->content = $content; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * @return Json |
| 299 | */ |
| 300 | public function getTranslations() |
| 301 | { |
| 302 | return $this->translations; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * @param Json $translations |
| 307 | */ |
| 308 | public function setTranslations(Json $translations) |
| 309 | { |
| 310 | $this->translations = $translations; |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * @return array |
| 315 | */ |
| 316 | public function getEntityIds() |
| 317 | { |
| 318 | return $this->entityIds; |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * @param array $entityIds |
| 323 | */ |
| 324 | public function setEntityIds($entityIds) |
| 325 | { |
| 326 | $this->entityIds = $entityIds; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * @return BooleanValueObject |
| 331 | */ |
| 332 | public function getSendOnlyMe() |
| 333 | { |
| 334 | return $this->sendOnlyMe; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * @param BooleanValueObject $sendOnlyMe |
| 339 | */ |
| 340 | public function setSendOnlyMe($sendOnlyMe) |
| 341 | { |
| 342 | $this->sendOnlyMe = $sendOnlyMe; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * @return string |
| 347 | */ |
| 348 | public function getWhatsAppTemplate() |
| 349 | { |
| 350 | return $this->whatsAppTemplate; |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * @param string $whatsAppTemplate |
| 355 | */ |
| 356 | public function setWhatsAppTemplate($whatsAppTemplate) |
| 357 | { |
| 358 | $this->whatsAppTemplate = $whatsAppTemplate; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * @return Json |
| 363 | */ |
| 364 | public function getMinimumTimeBeforeBooking() |
| 365 | { |
| 366 | return $this->minimumTimeBeforeBooking; |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * @param Json $minimumTimeBeforeBooking |
| 371 | */ |
| 372 | public function setMinimumTimeBeforeBooking($minimumTimeBeforeBooking) |
| 373 | { |
| 374 | $this->minimumTimeBeforeBooking = $minimumTimeBeforeBooking; |
| 375 | } |
| 376 | |
| 377 | |
| 378 | /** |
| 379 | * @return array |
| 380 | */ |
| 381 | public function toArray() |
| 382 | { |
| 383 | return [ |
| 384 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 385 | 'name' => $this->getName()->getValue(), |
| 386 | 'customName' => $this->getCustomName(), |
| 387 | 'status' => $this->getStatus()->getValue(), |
| 388 | 'type' => $this->getType()->getValue(), |
| 389 | 'entity' => $this->getEntity()->getValue(), |
| 390 | 'time' => null !== $this->getTime() ? $this->getTime()->getValue() : null, |
| 391 | 'timeBefore' => null !== $this->getTimeBefore() ? $this->getTimeBefore()->getValue() : null, |
| 392 | 'timeAfter' => null !== $this->getTimeAfter() ? $this->getTimeAfter()->getValue() : null, |
| 393 | 'sendTo' => $this->getSendTo()->getValue(), |
| 394 | 'subject' => $this->getSubject()->getValue(), |
| 395 | 'content' => $this->getContent()->getValue(), |
| 396 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 397 | 'entityIds' => $this->getEntityIds(), |
| 398 | 'sendOnlyMe' => $this->getSendOnlyMe() ? $this->getSendOnlyMe()->getValue() : null, |
| 399 | 'whatsAppTemplate' => $this->getWhatsAppTemplate() ?: null, |
| 400 | 'minimumTimeBeforeBooking' => $this->getMinimumTimeBeforeBooking() ? $this->getMinimumTimeBeforeBooking()->getValue() : null |
| 401 | ]; |
| 402 | } |
| 403 | } |
| 404 |