PluginProbe
Packeta / 2.3.2
Packeta v2.3.2
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Core / Entity / Order.php

Order.php in Packeta 2.3.2, at src/Packetery/Core/Entity/Order.php

1,232 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Order
4 *
5 * @package Packetery\Order
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Core\Entity;
11
12 use DateTimeImmutable;
13 use Packetery\Core\CoreHelper;
14
15 /**
16 * Class Order
17 *
18 * @package Packetery\Order
19 */
20 class Order {
21
22 /**
23 * Order id.
24 *
25 * @var string
26 */
27 private $number;
28
29 /**
30 * Car Delivery id.
31 *
32 * @var string
33 */
34 private $carDeliveryId;
35
36 /**
37 * Custom order number.
38 *
39 * @var string|null
40 */
41 private $customNumber;
42
43 /**
44 * Order carrier object.
45 *
46 * @var Carrier
47 */
48 private $carrier;
49
50 /**
51 * Order pickup point object.
52 *
53 * @var PickupPoint|null
54 */
55 private $pickupPoint;
56
57 /**
58 * Customer name.
59 *
60 * @var string|null
61 */
62 private $name;
63
64 /**
65 * Customer surname.
66 *
67 * @var string|null
68 */
69 private $surname;
70
71 /**
72 * Customer e-mail.
73 *
74 * @var string|null
75 */
76 private $email;
77
78 /**
79 * Customer phone.
80 *
81 * @var string|null
82 */
83 private $phone;
84
85 /**
86 * @var float|null
87 */
88 private $calculatedValue;
89
90 /**
91 * @var float|null
92 */
93 private $manualValue;
94
95 /**
96 * Sender label.
97 *
98 * @var string|null
99 */
100 private $eshop;
101
102 /**
103 * Address.
104 *
105 * @var Address|null
106 */
107 private $address;
108
109 /**
110 * Size.
111 *
112 * @var Size|null
113 */
114 private $size;
115
116 /**
117 * Package weight, set or calculated.
118 *
119 * @var float|null
120 */
121 private $weight;
122
123 /**
124 * Calculated package weight.
125 *
126 * @var float|null
127 */
128 private $calculatedWeight;
129
130 /**
131 * @var float|null
132 */
133 private $calculatedCod;
134
135 /**
136 * @var float|null
137 */
138 private $manualCod;
139
140 /**
141 * Packet note.
142 *
143 * @var string|null
144 */
145 private $note;
146
147 /**
148 * Adult content presence flag.
149 *
150 * @var bool|null
151 */
152 private $adultContent;
153
154 /**
155 * Packet ID
156 *
157 * @var string|null
158 */
159 private $packetId;
160
161 /**
162 * @var string|null
163 */
164 private $packetTrackingUrl;
165
166 /**
167 * Packet ID.
168 *
169 * @var string|null
170 */
171 private $packetClaimId;
172
173 /**
174 * @var string|null
175 */
176 private $packetClaimTrackingUrl;
177
178 /**
179 * Packet password.
180 *
181 * @var string|null
182 */
183 private $packetClaimPassword;
184
185 /**
186 * Z-BOX consign password from packetInfo.
187 *
188 * @var string|null
189 */
190 private $consignPassword;
191
192 /**
193 * Packet ID
194 *
195 * @var string|null
196 */
197 private $packetStatus;
198
199 /**
200 * Tells if is packet submitted.
201 *
202 * @var bool
203 */
204 private $isExported;
205
206 /**
207 * Tells if is packet submitted.
208 *
209 * @var bool
210 */
211 private $isLabelPrinted;
212
213 /**
214 * Packet currency.
215 *
216 * @var string
217 */
218 private $currency;
219
220 /**
221 * Carrier number.
222 *
223 * @var string|null
224 */
225 private $carrierNumber;
226
227 /**
228 * Address validated.
229 *
230 * @var bool
231 */
232 private $addressValidated;
233
234 /**
235 * ISO 3166-1 alpha-2 code, lowercase.
236 *
237 * @var string|null
238 */
239 private $shippingCountry;
240
241 /**
242 * Last message built from Packeta API response.
243 *
244 * @var string|null
245 */
246 private $lastApiErrorMessage;
247
248 /**
249 * Last API error datetime.
250 *
251 * @var \DateTimeImmutable|null
252 */
253 private $lastApiErrorDateTime;
254
255 /**
256 * Deliver on
257 *
258 * @var DateTimeImmutable|null
259 */
260 private $deliverOn;
261
262 /**
263 * Customs declaration.
264 *
265 * @var CustomsDeclaration|null
266 */
267 private $customsDeclaration;
268
269 /**
270 * Stored until.
271 *
272 * @var DateTimeImmutable|null
273 */
274 private $storedUntil;
275
276 /**
277 * Order entity constructor.
278 *
279 * @param string $number Order id.
280 * @param Carrier $carrier Carrier entity.
281 */
282 public function __construct(
283 string $number,
284 Carrier $carrier
285 ) {
286 $this->number = $number;
287 $this->carrier = $carrier;
288 $this->isExported = false;
289 $this->isLabelPrinted = false;
290 $this->addressValidated = false;
291 }
292
293 /**
294 * Gets Car Delivery id.
295 *
296 * @return string
297 */
298 public function getCarDeliveryId(): ?string {
299 return $this->carDeliveryId;
300 }
301
302 /**
303 * Sets Car Delivery id.
304 *
305 * @param string $carDeliveryId Car delivery ID.
306 * @return void
307 */
308 public function setCarDeliveryId( string $carDeliveryId ): void {
309 $this->carDeliveryId = $carDeliveryId;
310 }
311
312 /**
313 * Sets custom declaration.
314 *
315 * @param CustomsDeclaration|null $customsDeclaration Customs declaration.
316 *
317 * @return void
318 */
319 public function setCustomsDeclaration( ?CustomsDeclaration $customsDeclaration ): void {
320 $this->customsDeclaration = $customsDeclaration;
321 }
322
323 /**
324 * Gets customs declaration.
325 *
326 * @return CustomsDeclaration|null
327 */
328 public function getCustomsDeclaration(): ?CustomsDeclaration {
329 return $this->customsDeclaration;
330 }
331
332 /**
333 * Has customs declaration items.
334 *
335 * @return bool
336 */
337 public function hasCustomsDeclaration(): bool {
338 return $this->customsDeclaration !== null && $this->customsDeclaration->getItems() !== [];
339 }
340
341 /**
342 * Tells if customs declaration has to be filled to submit packet.
343 *
344 * @return bool
345 */
346 public function hasToFillCustomsDeclaration(): bool {
347 return $this->carrier->requiresCustomsDeclarations() &&
348 $this->hasCustomsDeclaration() === false;
349 }
350
351 /**
352 * Gets custom number.
353 *
354 * @return string|null
355 */
356 public function getCustomNumber(): ?string {
357 return $this->customNumber;
358 }
359
360 /**
361 * Sets custom number.
362 *
363 * @param string|null $customNumber Custom number.
364 *
365 * @return void
366 */
367 public function setCustomNumber( ?string $customNumber ): void {
368 $this->customNumber = $customNumber;
369 }
370
371 /**
372 * Is address validated?
373 *
374 * @return bool
375 */
376 public function isAddressValidated(): bool {
377 return $this->addressValidated;
378 }
379
380 /**
381 * Sets address validation flag.
382 *
383 * @param bool $addressValidated Address validated.
384 *
385 * @return void
386 */
387 public function setAddressValidated( bool $addressValidated ): void {
388 $this->addressValidated = $addressValidated;
389 }
390
391 /**
392 * Checks if is home delivery. In that case pointId is not set.
393 *
394 * @return bool
395 */
396 public function isHomeDelivery(): bool {
397 return ( ! $this->carrier->hasPickupPoints() && ! $this->isCarDelivery() );
398 }
399
400 /**
401 * Checks if is home delivery. In that case pointId is not set.
402 *
403 * @return bool
404 */
405 public function isCarDelivery(): bool {
406 return $this->carrier->isCarDelivery();
407 }
408
409 /**
410 * Tells if order has to be shipped to pickup point, run by Packeta or an external carrier.
411 *
412 * @return bool
413 */
414 public function isPickupPointDelivery(): bool {
415 return $this->carrier->hasPickupPoints();
416 }
417
418 /**
419 * Checks if order uses external carrier.
420 *
421 * @return bool
422 */
423 public function isExternalCarrier(): bool {
424 return is_numeric( $this->getCarrier()->getId() );
425 }
426
427 /**
428 * Check if delivery method is internal packetery pickup point
429 *
430 * @return bool
431 */
432 public function isPacketaInternalPickupPoint(): bool {
433 return ! $this->isExternalCarrier() && $this->isPickupPointDelivery();
434 }
435
436 /**
437 * Gets pickup point/carrier id.
438 *
439 * @return int|null
440 */
441 public function getPickupPointOrCarrierId(): ?int {
442 if ( $this->isExternalCarrier() ) {
443 return (int) $this->getCarrier()->getId();
444 }
445
446 if ( $this->pickupPoint === null ) {
447 return null;
448 }
449
450 // Typing to int is safe in case of internal pickup points.
451 return (int) $this->pickupPoint->getId();
452 }
453
454 public function hasPickupPointOrCarrierId(): bool {
455 $pickupPointOrCarrierId = $this->getPickupPointOrCarrierId();
456
457 return $pickupPointOrCarrierId !== null && $pickupPointOrCarrierId !== 0;
458 }
459
460 /**
461 * Sets pickup point.
462 *
463 * @param PickupPoint $pickupPoint Pickup point.
464 */
465 public function setPickupPoint( PickupPoint $pickupPoint ): void {
466 $this->pickupPoint = $pickupPoint;
467 }
468
469 /**
470 * Sets delivery address.
471 *
472 * @param Address $address Delivery address.
473 */
474 public function setDeliveryAddress( Address $address ): void {
475 $this->address = $address;
476 }
477
478 /**
479 * Sets packet size.
480 *
481 * @param Size $size Size.
482 */
483 public function setSize( Size $size ): void {
484 $this->size = $size;
485 }
486
487 /**
488 * Sets number.
489 *
490 * @param string $number Number.
491 */
492 public function setNumber( string $number ): void {
493 $this->number = $number;
494 }
495
496 /**
497 * Sets phone.
498 *
499 * @param string $name Name.
500 */
501 public function setName( string $name ): void {
502 $this->name = $name;
503 }
504
505 /**
506 * Sets surname.
507 *
508 * @param string $surname Surname.
509 */
510 public function setSurname( string $surname ): void {
511 $this->surname = $surname;
512 }
513
514 /**
515 * Sets e-mail.
516 *
517 * @param string $email E-mail.
518 */
519 public function setEmail( string $email ): void {
520 $this->email = $email;
521 }
522
523 /**
524 * Sets eshop.
525 *
526 * @param string|null $eshop Eshop.
527 *
528 * @return void
529 */
530 public function setEshop( ?string $eshop ): void {
531 $this->eshop = $eshop;
532 }
533
534 /**
535 * Sets phone.
536 *
537 * @param string $phone Phone.
538 */
539 public function setPhone( string $phone ): void {
540 $this->phone = $phone;
541 }
542
543 public function setManualValue( ?float $value ): void {
544 $this->manualValue = $value;
545 }
546
547 public function setCalculatedValue( ?float $value ): void {
548 $this->calculatedValue = $value;
549 }
550
551 public function setManualCod( ?float $cod ): void {
552 $this->manualCod = $cod;
553 }
554
555 public function setCalculatedCod( ?float $cod ): void {
556 $this->calculatedCod = $cod;
557 }
558
559 /**
560 * Gets packet currency.
561 *
562 * @return string
563 */
564 public function getCurrency(): string {
565 return $this->currency;
566 }
567
568 /**
569 * Sets packet currency.
570 *
571 * @param string $currency Currency.
572 *
573 * @return void
574 */
575 public function setCurrency( string $currency ): void {
576 $this->currency = $currency;
577 }
578
579 /**
580 * Sets packet note.
581 *
582 * @param string $note Packet note.
583 */
584 public function setNote( string $note ): void {
585 $this->note = $note;
586 }
587
588 /**
589 * Sets adult content presence flag.
590 *
591 * @param bool|null $adultContent Adult content presence flag.
592 */
593 public function setAdultContent( ?bool $adultContent ): void {
594 $this->adultContent = $adultContent;
595 }
596
597 /**
598 * Sets packet id.
599 *
600 * @param string|null $packetId Packet id.
601 */
602 public function setPacketId( ?string $packetId ): void {
603 $this->packetId = $packetId;
604 }
605
606 public function setPacketTrackingUrl( ?string $trackingUrl ): void {
607 $this->packetTrackingUrl = $trackingUrl;
608 }
609
610 /**
611 * Sets packet claim ID.
612 *
613 * @param string|null $packetClaimId Packet claim ID.
614 *
615 * @return void
616 */
617 public function setPacketClaimId( ?string $packetClaimId ): void {
618 $this->packetClaimId = $packetClaimId;
619 }
620
621 public function setPacketClaimTrackingUrl( ?string $trackingUrl ): void {
622 $this->packetClaimTrackingUrl = $trackingUrl;
623 }
624
625 /**
626 * Packet claim password.
627 *
628 * @param string|null $packetClaimPassword Packet claim password.
629 *
630 * @return void
631 */
632 public function setPacketClaimPassword( ?string $packetClaimPassword ): void {
633 $this->packetClaimPassword = $packetClaimPassword;
634 }
635
636 /**
637 * @param string|null $consignPassword Consign password.
638 *
639 * @return void
640 */
641 public function setConsignPassword( ?string $consignPassword ): void {
642 $this->consignPassword = $consignPassword;
643 }
644
645 /**
646 * Sets packet status.
647 *
648 * @param string|null $packetStatus Packet status.
649 *
650 * @return void
651 */
652 public function setPacketStatus( ?string $packetStatus ): void {
653 $this->packetStatus = $packetStatus;
654 }
655
656 /**
657 * Sets stored until date.
658 *
659 * @param \DateTimeImmutable|null $storedUntil Stored until.
660 */
661 public function setStoredUntil( ?DateTimeImmutable $storedUntil ): void {
662 $this->storedUntil = $storedUntil;
663 }
664
665 /**
666 * Sets is exported flag.
667 *
668 * @param bool $isExported Packet id.
669 */
670 public function setIsExported( bool $isExported ): void {
671 $this->isExported = $isExported;
672 }
673
674 /**
675 * Sets flag of label print.
676 *
677 * @param bool $isLabelPrinted Is label printed.
678 *
679 * @return void
680 */
681 public function setIsLabelPrinted( bool $isLabelPrinted ): void {
682 $this->isLabelPrinted = $isLabelPrinted;
683 }
684
685 /**
686 * Sets carrier number.
687 *
688 * @param string|null $carrierNumber Carrier number.
689 *
690 * @return void
691 */
692 public function setCarrierNumber( ?string $carrierNumber ): void {
693 $this->carrierNumber = $carrierNumber;
694 }
695
696 /**
697 * Sets weight.
698 *
699 * @param float|null $weight Weight.
700 *
701 * @return void
702 */
703 public function setWeight( ?float $weight ): void {
704 $this->weight = CoreHelper::simplifyWeight( $weight );
705 }
706
707 /**
708 * Sets calculated weight.
709 *
710 * @param float|null $weight Weight.
711 *
712 * @return void
713 */
714 public function setCalculatedWeight( ?float $weight ): void {
715 $this->calculatedWeight = $weight;
716 }
717
718 /**
719 * Sets shipping country.
720 *
721 * @param string $shippingCountry ISO 3166-1 alpha-2 code, lowercase.
722 *
723 * @return void
724 */
725 public function setShippingCountry( string $shippingCountry ): void {
726 if ( $shippingCountry === '' ) {
727 $this->shippingCountry = null;
728 } else {
729 $this->shippingCountry = $shippingCountry;
730 }
731 }
732
733 /**
734 * Sets API response message.
735 *
736 * @param string|null $lastApiErrorMessage API response message.
737 *
738 * @return void
739 */
740 public function setLastApiErrorMessage( ?string $lastApiErrorMessage ): void {
741 $this->lastApiErrorMessage = $lastApiErrorMessage;
742 }
743
744 /**
745 * Sets API error date.
746 *
747 * @param \DateTimeImmutable|null $lastApiErrorDateTime API error date.
748 */
749 public function setLastApiErrorDateTime( ?\DateTimeImmutable $lastApiErrorDateTime ): void {
750 $this->lastApiErrorDateTime = $lastApiErrorDateTime;
751 }
752
753 /**
754 * Gets carrier object.
755 *
756 * @return Carrier
757 */
758 public function getCarrier(): Carrier {
759 return $this->carrier;
760 }
761
762 /**
763 * Gets pickup point object.
764 *
765 * @return PickupPoint|null
766 */
767 public function getPickupPoint(): ?PickupPoint {
768 return $this->pickupPoint;
769 }
770
771 /**
772 * Gets delivery address object.
773 *
774 * @return Address|null
775 */
776 public function getDeliveryAddress(): ?Address {
777 return $this->address;
778 }
779
780 /**
781 * Gets validated delivery address object.
782 *
783 * @return Address|null
784 */
785 public function getValidatedDeliveryAddress(): ?Address {
786 return ( $this->addressValidated ? $this->address : null );
787 }
788
789 /**
790 * Gets size object.
791 *
792 * @return Size|null
793 */
794 public function getSize(): ?Size {
795 return $this->size;
796 }
797
798 /**
799 * Packet ID
800 *
801 * @return string|null
802 */
803 public function getPacketId(): ?string {
804 return $this->packetId;
805 }
806
807 /**
808 * Packet barcode e.g Z123456789
809 *
810 * @return string|null
811 */
812 public function getPacketBarcode(): ?string {
813 return $this->packetId !== null ? 'Z' . $this->packetId : null;
814 }
815
816 /**
817 * Packet Claim barcode e.g Z123456789
818 *
819 * @return string|null
820 */
821 public function getPacketClaimBarcode(): ?string {
822 return $this->packetClaimId !== null ? 'Z' . $this->packetClaimId : null;
823 }
824
825 public function getPacketTrackingUrl(): ?string {
826 return $this->packetTrackingUrl;
827 }
828
829 public function getPacketClaimTrackingUrl(): ?string {
830 return $this->packetClaimTrackingUrl;
831 }
832
833 /**
834 * Gets packet claim ID.
835 *
836 * @return string|null
837 */
838 public function getPacketClaimId(): ?string {
839 return $this->packetClaimId;
840 }
841
842 /**
843 * Gets packet claim password.
844 *
845 * @return string|null
846 */
847 public function getPacketClaimPassword(): ?string {
848 return $this->packetClaimPassword;
849 }
850
851 /**
852 * @return string|null
853 */
854 public function getConsignPassword(): ?string {
855 return $this->consignPassword;
856 }
857
858 /**
859 * Packet status.
860 *
861 * @return string|null
862 */
863 public function getPacketStatus(): ?string {
864 return $this->packetStatus;
865 }
866
867 /**
868 * Get stored until date.
869 *
870 * @return \DateTimeImmutable|null
871 */
872 public function getStoredUntil(): ?\DateTimeImmutable {
873 return $this->storedUntil;
874 }
875
876 /**
877 * Tells it's possible to extend the package pickup date.
878 *
879 * @return bool
880 */
881 public function isPossibleExtendPacketPickUpDate(): bool {
882 return $this->packetStatus === PacketStatus::READY_FOR_PICKUP &&
883 $this->storedUntil !== null &&
884 $this->isPacketaInternalPickupPoint();
885 }
886
887 /**
888 * Tells if packet claim creation is possible.
889 *
890 * @return bool
891 */
892 public function isPacketClaimCreationPossible(): bool {
893 return $this->packetStatus === PacketStatus::DELIVERED &&
894 $this->packetClaimId === null;
895 }
896
897 /**
898 * Determines whether a packet is a claim, or otherwise.
899 *
900 * @param string $packetId Packet id.
901 *
902 * @return bool
903 */
904 public function isPacketClaim( string $packetId ): bool {
905 return $this->getPacketClaimId() === $packetId;
906 }
907
908 /**
909 * Tells if packet claim label print is possible.
910 *
911 * @return bool
912 */
913 public function isPacketClaimLabelPrintPossible(): bool {
914 return $this->packetClaimId !== null &&
915 $this->isExternalCarrier() === false &&
916 $this->pickupPoint !== null;
917 }
918
919 /**
920 * Tells if is packet submitted.
921 *
922 * @return bool
923 */
924 public function isExported(): bool {
925 return $this->isExported;
926 }
927
928 /**
929 * Gets weight.
930 *
931 * @return float|null
932 */
933 public function getWeight(): ?float {
934 return $this->weight;
935 }
936
937 /**
938 * Tells if order has manual weight set.
939 *
940 * @return bool
941 */
942 public function hasManualWeight(): bool {
943 return $this->weight !== null;
944 }
945
946 /**
947 * Gets final weight.
948 *
949 * @return float|null
950 */
951 public function getFinalWeight(): ?float {
952 return $this->weight ?? $this->calculatedWeight;
953 }
954
955 /**
956 * Gets calculated weight.
957 *
958 * @return float|null
959 */
960 public function getCalculatedWeight(): ?float {
961 return $this->calculatedWeight;
962 }
963
964 /**
965 * Gets length.
966 *
967 * @return float|null
968 */
969 public function getLength(): ?float {
970 if ( $this->size === null ) {
971 return null;
972 }
973
974 return $this->size->getLength();
975 }
976
977 /**
978 * Gets width.
979 *
980 * @return float|null
981 */
982 public function getWidth(): ?float {
983 if ( $this->size === null ) {
984 return null;
985 }
986
987 return $this->size->getWidth();
988 }
989
990 /**
991 * Gets height.
992 *
993 * @return float|null
994 */
995 public function getHeight(): ?float {
996 if ( $this->size === null ) {
997 return null;
998 }
999
1000 return $this->size->getHeight();
1001 }
1002
1003 /**
1004 * Checks adult content presence.
1005 *
1006 * @return bool|null
1007 */
1008 public function containsAdultContent(): ?bool {
1009 return $this->adultContent;
1010 }
1011
1012 /**
1013 * Gets order id.
1014 *
1015 * @return string|null
1016 */
1017 public function getNumber(): ?string {
1018 return $this->number;
1019 }
1020
1021 /**
1022 * Has order id.
1023 *
1024 * @return bool
1025 */
1026 public function hasNumber(): bool {
1027 return $this->number !== null && $this->number !== '';
1028 }
1029
1030 /**
1031 * Gets customer name.
1032 *
1033 * @return string|null
1034 */
1035 public function getName(): ?string {
1036 return $this->name;
1037 }
1038
1039 /**
1040 * Has customer name.
1041 *
1042 * @return bool
1043 */
1044 public function hasName(): bool {
1045 return $this->name !== null && $this->name !== '';
1046 }
1047
1048 /**
1049 * Gets customer surname.
1050 *
1051 * @return string|null
1052 */
1053 public function getSurname(): ?string {
1054 return $this->surname;
1055 }
1056
1057 public function getManualValue(): ?float {
1058 return $this->manualValue;
1059 }
1060
1061 public function hasManualValue(): bool {
1062 return $this->manualValue !== null;
1063 }
1064
1065 public function getCalculatedValue(): ?float {
1066 return $this->calculatedValue;
1067 }
1068
1069 public function getFinalValue(): ?float {
1070 return $this->manualValue ?? $this->calculatedValue;
1071 }
1072
1073 public function hasFinalValue(): bool {
1074 return $this->getFinalValue() !== null;
1075 }
1076
1077 public function getManualCod(): ?float {
1078 return $this->manualCod;
1079 }
1080
1081 public function hasManualCod(): bool {
1082 return $this->manualCod !== null;
1083 }
1084
1085 public function getCalculatedCod(): ?float {
1086 return $this->calculatedCod;
1087 }
1088
1089 public function getFinalCod(): ?float {
1090 return $this->manualCod ?? $this->calculatedCod;
1091 }
1092
1093 /**
1094 * Gets sender label.
1095 *
1096 * @return string|null
1097 */
1098 public function getEshop(): ?string {
1099 return $this->eshop;
1100 }
1101
1102 /**
1103 * Has sender label.
1104 *
1105 * @return bool
1106 */
1107 public function hasEshop(): bool {
1108 return $this->eshop !== null && $this->eshop !== '';
1109 }
1110
1111 /**
1112 * Gets customer e-mail.
1113 *
1114 * @return string|null
1115 */
1116 public function getEmail(): ?string {
1117 return $this->email;
1118 }
1119
1120 /**
1121 * Gets delivery note.
1122 *
1123 * @return string|null
1124 */
1125 public function getNote(): ?string {
1126 return $this->note;
1127 }
1128
1129 /**
1130 * Gets customer phone.
1131 *
1132 * @return string|null
1133 */
1134 public function getPhone(): ?string {
1135 return $this->phone;
1136 }
1137
1138 /**
1139 * Is label printed?
1140 *
1141 * @return bool
1142 */
1143 public function isLabelPrinted(): bool {
1144 return $this->isLabelPrinted;
1145 }
1146
1147 /**
1148 * Carrier number.
1149 *
1150 * @return string|null
1151 */
1152 public function getCarrierNumber(): ?string {
1153 return $this->carrierNumber;
1154 }
1155
1156 /**
1157 * Gets shipping country.
1158 *
1159 * @return string|null
1160 */
1161 public function getShippingCountry(): ?string {
1162 return $this->shippingCountry;
1163 }
1164
1165 public function hasCod(): bool {
1166 return $this->getFinalCod() !== null;
1167 }
1168
1169 /**
1170 * Allows Adult Content
1171 *
1172 * @return bool
1173 */
1174 public function allowsAdultContent(): bool {
1175 return $this->isPacketaInternalPickupPoint() || $this->getCarrier()->supportsAgeVerification();
1176 }
1177
1178 /**
1179 * Returns deliver on date
1180 *
1181 * @return DateTimeImmutable|null
1182 */
1183 public function getDeliverOn(): ?DateTimeImmutable {
1184 return $this->deliverOn;
1185 }
1186
1187 /**
1188 * Sets deliver on date
1189 *
1190 * @param DateTimeImmutable|null $deliverOn Deliver on.
1191 *
1192 * @return void
1193 */
1194 public function setDeliverOn( ?DateTimeImmutable $deliverOn ): void {
1195 $this->deliverOn = $deliverOn;
1196 }
1197
1198 /**
1199 * Formatted API error message.
1200 *
1201 * @return string|null
1202 */
1203 public function getLastApiErrorMessage(): ?string {
1204 return $this->lastApiErrorMessage;
1205 }
1206
1207 /**
1208 * Gets last API error message date.
1209 *
1210 * @return \DateTimeImmutable|null
1211 */
1212 public function getLastApiErrorDateTime(): ?\DateTimeImmutable {
1213 return $this->lastApiErrorDateTime;
1214 }
1215
1216 /**
1217 * Updates API error message and sets error message date accordingly.
1218 *
1219 * @param string|null $errorMessage Error message.
1220 *
1221 * @return void
1222 */
1223 public function updateApiErrorMessage( ?string $errorMessage ): void {
1224 $this->setLastApiErrorMessage( $errorMessage );
1225 $this->setLastApiErrorDateTime( $errorMessage !== null ? CoreHelper::now() : null );
1226 }
1227
1228 public function getCustomNumberOrNumber(): ?string {
1229 return $this->getCustomNumber() ?? $this->getNumber();
1230 }
1231 }
1232