PluginProbe
Packeta / 2.0.9
Packeta v2.0.9
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.0.9, at src/Packetery/Core/Entity/Order.php

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