commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
QuoteModel.php
1<?php
2
3declare(strict_types=1);
10
53use DateTimeImmutable;
54use stdClass;
55
59final class QuoteModel extends JsonObjectModel implements Quote
60{
65 protected $id;
66
71 protected $version;
72
77 protected $createdAt;
78
83 protected $lastModifiedAt;
84
89 protected $key;
90
95 protected $lastModifiedBy;
96
101 protected $createdBy;
102
107 protected $quoteRequest;
108
113 protected $stagedQuote;
114
119 protected $customer;
120
125 protected $customerGroup;
126
131 protected $validTo;
132
137 protected $sellerComment;
138
143 protected $buyerComment;
144
149 protected $store;
150
155 protected $lineItems;
156
162
167 protected $totalPrice;
168
173 protected $taxedPrice;
174
180
186
191 protected $inventoryMode;
192
197 protected $taxMode;
198
204
210
215 protected $country;
216
221 protected $shippingInfo;
222
227 protected $paymentInfo;
228
234
240
246
251 protected $custom;
252
257 protected $quoteState;
258
263 protected $state;
264
270
275 protected $businessUnit;
276
277
281 public function __construct(
282 ?string $id = null,
283 ?int $version = null,
284 ?DateTimeImmutable $createdAt = null,
285 ?DateTimeImmutable $lastModifiedAt = null,
286 ?string $key = null,
288 ?CreatedBy $createdBy = null,
293 ?DateTimeImmutable $validTo = null,
294 ?string $sellerComment = null,
295 ?string $buyerComment = null,
299 ?TypedMoney $totalPrice = null,
300 ?TaxedPrice $taxedPrice = null,
302 ?Address $billingAddress = null,
303 ?string $inventoryMode = null,
304 ?string $taxMode = null,
305 ?string $taxRoundingMode = null,
306 ?string $taxCalculationMode = null,
307 ?string $country = null,
313 ?CustomFields $custom = null,
314 ?string $quoteState = null,
315 ?StateReference $state = null,
316 ?string $purchaseOrderNumber = null,
318 ) {
319 $this->id = $id;
320 $this->version = $version;
321 $this->createdAt = $createdAt;
322 $this->lastModifiedAt = $lastModifiedAt;
323 $this->key = $key;
324 $this->lastModifiedBy = $lastModifiedBy;
325 $this->createdBy = $createdBy;
326 $this->quoteRequest = $quoteRequest;
327 $this->stagedQuote = $stagedQuote;
328 $this->customer = $customer;
329 $this->customerGroup = $customerGroup;
330 $this->validTo = $validTo;
331 $this->sellerComment = $sellerComment;
332 $this->buyerComment = $buyerComment;
333 $this->store = $store;
334 $this->lineItems = $lineItems;
335 $this->customLineItems = $customLineItems;
336 $this->totalPrice = $totalPrice;
337 $this->taxedPrice = $taxedPrice;
338 $this->shippingAddress = $shippingAddress;
339 $this->billingAddress = $billingAddress;
340 $this->inventoryMode = $inventoryMode;
341 $this->taxMode = $taxMode;
342 $this->taxRoundingMode = $taxRoundingMode;
343 $this->taxCalculationMode = $taxCalculationMode;
344 $this->country = $country;
345 $this->shippingInfo = $shippingInfo;
346 $this->paymentInfo = $paymentInfo;
347 $this->shippingRateInput = $shippingRateInput;
348 $this->itemShippingAddresses = $itemShippingAddresses;
349 $this->directDiscounts = $directDiscounts;
350 $this->custom = $custom;
351 $this->quoteState = $quoteState;
352 $this->state = $state;
353 $this->purchaseOrderNumber = $purchaseOrderNumber;
354 $this->businessUnit = $businessUnit;
355 }
356
363 public function getId()
364 {
365 if (is_null($this->id)) {
367 $data = $this->raw(self::FIELD_ID);
368 if (is_null($data)) {
369 return null;
370 }
371 $this->id = (string) $data;
372 }
373
374 return $this->id;
375 }
376
383 public function getVersion()
384 {
385 if (is_null($this->version)) {
387 $data = $this->raw(self::FIELD_VERSION);
388 if (is_null($data)) {
389 return null;
390 }
391 $this->version = (int) $data;
392 }
393
394 return $this->version;
395 }
396
403 public function getCreatedAt()
404 {
405 if (is_null($this->createdAt)) {
407 $data = $this->raw(self::FIELD_CREATED_AT);
408 if (is_null($data)) {
409 return null;
410 }
411 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
412 if (false === $data) {
413 return null;
414 }
415 $this->createdAt = $data;
416 }
417
418 return $this->createdAt;
419 }
420
427 public function getLastModifiedAt()
428 {
429 if (is_null($this->lastModifiedAt)) {
431 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
432 if (is_null($data)) {
433 return null;
434 }
435 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
436 if (false === $data) {
437 return null;
438 }
439 $this->lastModifiedAt = $data;
440 }
441
443 }
444
451 public function getKey()
452 {
453 if (is_null($this->key)) {
455 $data = $this->raw(self::FIELD_KEY);
456 if (is_null($data)) {
457 return null;
458 }
459 $this->key = (string) $data;
460 }
461
462 return $this->key;
463 }
464
471 public function getLastModifiedBy()
472 {
473 if (is_null($this->lastModifiedBy)) {
475 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
476 if (is_null($data)) {
477 return null;
478 }
479
480 $this->lastModifiedBy = LastModifiedByModel::of($data);
481 }
482
484 }
485
492 public function getCreatedBy()
493 {
494 if (is_null($this->createdBy)) {
496 $data = $this->raw(self::FIELD_CREATED_BY);
497 if (is_null($data)) {
498 return null;
499 }
500
501 $this->createdBy = CreatedByModel::of($data);
502 }
503
504 return $this->createdBy;
505 }
506
513 public function getQuoteRequest()
514 {
515 if (is_null($this->quoteRequest)) {
517 $data = $this->raw(self::FIELD_QUOTE_REQUEST);
518 if (is_null($data)) {
519 return null;
520 }
521
522 $this->quoteRequest = QuoteRequestReferenceModel::of($data);
523 }
524
525 return $this->quoteRequest;
526 }
527
534 public function getStagedQuote()
535 {
536 if (is_null($this->stagedQuote)) {
538 $data = $this->raw(self::FIELD_STAGED_QUOTE);
539 if (is_null($data)) {
540 return null;
541 }
542
543 $this->stagedQuote = StagedQuoteReferenceModel::of($data);
544 }
545
546 return $this->stagedQuote;
547 }
548
555 public function getCustomer()
556 {
557 if (is_null($this->customer)) {
559 $data = $this->raw(self::FIELD_CUSTOMER);
560 if (is_null($data)) {
561 return null;
562 }
563
564 $this->customer = CustomerReferenceModel::of($data);
565 }
566
567 return $this->customer;
568 }
569
578 public function getCustomerGroup()
579 {
580 if (is_null($this->customerGroup)) {
582 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
583 if (is_null($data)) {
584 return null;
585 }
586
587 $this->customerGroup = CustomerGroupReferenceModel::of($data);
588 }
589
591 }
592
599 public function getValidTo()
600 {
601 if (is_null($this->validTo)) {
603 $data = $this->raw(self::FIELD_VALID_TO);
604 if (is_null($data)) {
605 return null;
606 }
607 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
608 if (false === $data) {
609 return null;
610 }
611 $this->validTo = $data;
612 }
613
614 return $this->validTo;
615 }
616
623 public function getSellerComment()
624 {
625 if (is_null($this->sellerComment)) {
627 $data = $this->raw(self::FIELD_SELLER_COMMENT);
628 if (is_null($data)) {
629 return null;
630 }
631 $this->sellerComment = (string) $data;
632 }
633
635 }
636
643 public function getBuyerComment()
644 {
645 if (is_null($this->buyerComment)) {
647 $data = $this->raw(self::FIELD_BUYER_COMMENT);
648 if (is_null($data)) {
649 return null;
650 }
651 $this->buyerComment = (string) $data;
652 }
653
654 return $this->buyerComment;
655 }
656
663 public function getStore()
664 {
665 if (is_null($this->store)) {
667 $data = $this->raw(self::FIELD_STORE);
668 if (is_null($data)) {
669 return null;
670 }
671
672 $this->store = StoreKeyReferenceModel::of($data);
673 }
674
675 return $this->store;
676 }
677
684 public function getLineItems()
685 {
686 if (is_null($this->lineItems)) {
688 $data = $this->raw(self::FIELD_LINE_ITEMS);
689 if (is_null($data)) {
690 return null;
691 }
692 $this->lineItems = LineItemCollection::fromArray($data);
693 }
694
695 return $this->lineItems;
696 }
697
704 public function getCustomLineItems()
705 {
706 if (is_null($this->customLineItems)) {
708 $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEMS);
709 if (is_null($data)) {
710 return null;
711 }
712 $this->customLineItems = CustomLineItemCollection::fromArray($data);
713 }
714
716 }
717
725 public function getTotalPrice()
726 {
727 if (is_null($this->totalPrice)) {
729 $data = $this->raw(self::FIELD_TOTAL_PRICE);
730 if (is_null($data)) {
731 return null;
732 }
733 $className = TypedMoneyModel::resolveDiscriminatorClass($data);
734 $this->totalPrice = $className::of($data);
735 }
736
737 return $this->totalPrice;
738 }
739
748 public function getTaxedPrice()
749 {
750 if (is_null($this->taxedPrice)) {
752 $data = $this->raw(self::FIELD_TAXED_PRICE);
753 if (is_null($data)) {
754 return null;
755 }
756
757 $this->taxedPrice = TaxedPriceModel::of($data);
758 }
759
760 return $this->taxedPrice;
761 }
762
770 public function getShippingAddress()
771 {
772 if (is_null($this->shippingAddress)) {
774 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS);
775 if (is_null($data)) {
776 return null;
777 }
778
779 $this->shippingAddress = AddressModel::of($data);
780 }
781
783 }
784
791 public function getBillingAddress()
792 {
793 if (is_null($this->billingAddress)) {
795 $data = $this->raw(self::FIELD_BILLING_ADDRESS);
796 if (is_null($data)) {
797 return null;
798 }
799
800 $this->billingAddress = AddressModel::of($data);
801 }
802
804 }
805
812 public function getInventoryMode()
813 {
814 if (is_null($this->inventoryMode)) {
816 $data = $this->raw(self::FIELD_INVENTORY_MODE);
817 if (is_null($data)) {
818 return null;
819 }
820 $this->inventoryMode = (string) $data;
821 }
822
824 }
825
832 public function getTaxMode()
833 {
834 if (is_null($this->taxMode)) {
836 $data = $this->raw(self::FIELD_TAX_MODE);
837 if (is_null($data)) {
838 return null;
839 }
840 $this->taxMode = (string) $data;
841 }
842
843 return $this->taxMode;
844 }
845
852 public function getTaxRoundingMode()
853 {
854 if (is_null($this->taxRoundingMode)) {
856 $data = $this->raw(self::FIELD_TAX_ROUNDING_MODE);
857 if (is_null($data)) {
858 return null;
859 }
860 $this->taxRoundingMode = (string) $data;
861 }
862
864 }
865
872 public function getTaxCalculationMode()
873 {
874 if (is_null($this->taxCalculationMode)) {
876 $data = $this->raw(self::FIELD_TAX_CALCULATION_MODE);
877 if (is_null($data)) {
878 return null;
879 }
880 $this->taxCalculationMode = (string) $data;
881 }
882
884 }
885
892 public function getCountry()
893 {
894 if (is_null($this->country)) {
896 $data = $this->raw(self::FIELD_COUNTRY);
897 if (is_null($data)) {
898 return null;
899 }
900 $this->country = (string) $data;
901 }
902
903 return $this->country;
904 }
905
912 public function getShippingInfo()
913 {
914 if (is_null($this->shippingInfo)) {
916 $data = $this->raw(self::FIELD_SHIPPING_INFO);
917 if (is_null($data)) {
918 return null;
919 }
920
921 $this->shippingInfo = ShippingInfoModel::of($data);
922 }
923
924 return $this->shippingInfo;
925 }
926
933 public function getPaymentInfo()
934 {
935 if (is_null($this->paymentInfo)) {
937 $data = $this->raw(self::FIELD_PAYMENT_INFO);
938 if (is_null($data)) {
939 return null;
940 }
941
942 $this->paymentInfo = PaymentInfoModel::of($data);
943 }
944
945 return $this->paymentInfo;
946 }
947
954 public function getShippingRateInput()
955 {
956 if (is_null($this->shippingRateInput)) {
958 $data = $this->raw(self::FIELD_SHIPPING_RATE_INPUT);
959 if (is_null($data)) {
960 return null;
961 }
962 $className = ShippingRateInputModel::resolveDiscriminatorClass($data);
963 $this->shippingRateInput = $className::of($data);
964 }
965
967 }
968
978 public function getItemShippingAddresses()
979 {
980 if (is_null($this->itemShippingAddresses)) {
982 $data = $this->raw(self::FIELD_ITEM_SHIPPING_ADDRESSES);
983 if (is_null($data)) {
984 return null;
985 }
986 $this->itemShippingAddresses = AddressCollection::fromArray($data);
987 }
988
990 }
991
998 public function getDirectDiscounts()
999 {
1000 if (is_null($this->directDiscounts)) {
1002 $data = $this->raw(self::FIELD_DIRECT_DISCOUNTS);
1003 if (is_null($data)) {
1004 return null;
1005 }
1006 $this->directDiscounts = DirectDiscountCollection::fromArray($data);
1007 }
1008
1010 }
1011
1018 public function getCustom()
1019 {
1020 if (is_null($this->custom)) {
1022 $data = $this->raw(self::FIELD_CUSTOM);
1023 if (is_null($data)) {
1024 return null;
1025 }
1026
1027 $this->custom = CustomFieldsModel::of($data);
1028 }
1029
1030 return $this->custom;
1031 }
1032
1039 public function getQuoteState()
1040 {
1041 if (is_null($this->quoteState)) {
1043 $data = $this->raw(self::FIELD_QUOTE_STATE);
1044 if (is_null($data)) {
1045 return null;
1046 }
1047 $this->quoteState = (string) $data;
1048 }
1049
1050 return $this->quoteState;
1051 }
1052
1060 public function getState()
1061 {
1062 if (is_null($this->state)) {
1064 $data = $this->raw(self::FIELD_STATE);
1065 if (is_null($data)) {
1066 return null;
1067 }
1068
1069 $this->state = StateReferenceModel::of($data);
1070 }
1071
1072 return $this->state;
1073 }
1074
1082 public function getPurchaseOrderNumber()
1083 {
1084 if (is_null($this->purchaseOrderNumber)) {
1086 $data = $this->raw(self::FIELD_PURCHASE_ORDER_NUMBER);
1087 if (is_null($data)) {
1088 return null;
1089 }
1090 $this->purchaseOrderNumber = (string) $data;
1091 }
1092
1094 }
1095
1102 public function getBusinessUnit()
1103 {
1104 if (is_null($this->businessUnit)) {
1106 $data = $this->raw(self::FIELD_BUSINESS_UNIT);
1107 if (is_null($data)) {
1108 return null;
1109 }
1110
1111 $this->businessUnit = BusinessUnitKeyReferenceModel::of($data);
1112 }
1113
1114 return $this->businessUnit;
1115 }
1116
1117
1121 public function setId(?string $id): void
1122 {
1123 $this->id = $id;
1124 }
1125
1129 public function setVersion(?int $version): void
1130 {
1131 $this->version = $version;
1132 }
1133
1137 public function setCreatedAt(?DateTimeImmutable $createdAt): void
1138 {
1139 $this->createdAt = $createdAt;
1140 }
1141
1145 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
1146 {
1147 $this->lastModifiedAt = $lastModifiedAt;
1148 }
1149
1153 public function setKey(?string $key): void
1154 {
1155 $this->key = $key;
1156 }
1157
1162 {
1163 $this->lastModifiedBy = $lastModifiedBy;
1164 }
1165
1169 public function setCreatedBy(?CreatedBy $createdBy): void
1170 {
1171 $this->createdBy = $createdBy;
1172 }
1173
1178 {
1179 $this->quoteRequest = $quoteRequest;
1180 }
1181
1186 {
1187 $this->stagedQuote = $stagedQuote;
1188 }
1189
1194 {
1195 $this->customer = $customer;
1196 }
1197
1202 {
1203 $this->customerGroup = $customerGroup;
1204 }
1205
1209 public function setValidTo(?DateTimeImmutable $validTo): void
1210 {
1211 $this->validTo = $validTo;
1212 }
1213
1217 public function setSellerComment(?string $sellerComment): void
1218 {
1219 $this->sellerComment = $sellerComment;
1220 }
1221
1225 public function setBuyerComment(?string $buyerComment): void
1226 {
1227 $this->buyerComment = $buyerComment;
1228 }
1229
1233 public function setStore(?StoreKeyReference $store): void
1234 {
1235 $this->store = $store;
1236 }
1237
1242 {
1243 $this->lineItems = $lineItems;
1244 }
1245
1250 {
1251 $this->customLineItems = $customLineItems;
1252 }
1253
1257 public function setTotalPrice(?TypedMoney $totalPrice): void
1258 {
1259 $this->totalPrice = $totalPrice;
1260 }
1261
1265 public function setTaxedPrice(?TaxedPrice $taxedPrice): void
1266 {
1267 $this->taxedPrice = $taxedPrice;
1268 }
1269
1274 {
1275 $this->shippingAddress = $shippingAddress;
1276 }
1277
1282 {
1283 $this->billingAddress = $billingAddress;
1284 }
1285
1289 public function setInventoryMode(?string $inventoryMode): void
1290 {
1291 $this->inventoryMode = $inventoryMode;
1292 }
1293
1297 public function setTaxMode(?string $taxMode): void
1298 {
1299 $this->taxMode = $taxMode;
1300 }
1301
1305 public function setTaxRoundingMode(?string $taxRoundingMode): void
1306 {
1307 $this->taxRoundingMode = $taxRoundingMode;
1308 }
1309
1313 public function setTaxCalculationMode(?string $taxCalculationMode): void
1314 {
1315 $this->taxCalculationMode = $taxCalculationMode;
1316 }
1317
1321 public function setCountry(?string $country): void
1322 {
1323 $this->country = $country;
1324 }
1325
1330 {
1331 $this->shippingInfo = $shippingInfo;
1332 }
1333
1338 {
1339 $this->paymentInfo = $paymentInfo;
1340 }
1341
1346 {
1347 $this->shippingRateInput = $shippingRateInput;
1348 }
1349
1354 {
1355 $this->itemShippingAddresses = $itemShippingAddresses;
1356 }
1357
1362 {
1363 $this->directDiscounts = $directDiscounts;
1364 }
1365
1369 public function setCustom(?CustomFields $custom): void
1370 {
1371 $this->custom = $custom;
1372 }
1373
1377 public function setQuoteState(?string $quoteState): void
1378 {
1379 $this->quoteState = $quoteState;
1380 }
1381
1385 public function setState(?StateReference $state): void
1386 {
1387 $this->state = $state;
1388 }
1389
1393 public function setPurchaseOrderNumber(?string $purchaseOrderNumber): void
1394 {
1395 $this->purchaseOrderNumber = $purchaseOrderNumber;
1396 }
1397
1402 {
1403 $this->businessUnit = $businessUnit;
1404 }
1405
1406
1407 #[\ReturnTypeWillChange]
1408 public function jsonSerialize()
1409 {
1410 $data = $this->toArray();
1411 if (isset($data[Quote::FIELD_CREATED_AT]) && $data[Quote::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1412 $data[Quote::FIELD_CREATED_AT] = $data[Quote::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1413 }
1414
1415 if (isset($data[Quote::FIELD_LAST_MODIFIED_AT]) && $data[Quote::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1416 $data[Quote::FIELD_LAST_MODIFIED_AT] = $data[Quote::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1417 }
1418
1419 if (isset($data[Quote::FIELD_VALID_TO]) && $data[Quote::FIELD_VALID_TO] instanceof \DateTimeImmutable) {
1420 $data[Quote::FIELD_VALID_TO] = $data[Quote::FIELD_VALID_TO]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1421 }
1422 return (object) $data;
1423 }
1424}
setTaxRoundingMode(?string $taxRoundingMode)
setStore(?StoreKeyReference $store)
setPaymentInfo(?PaymentInfo $paymentInfo)
setBillingAddress(?Address $billingAddress)
setTaxCalculationMode(?string $taxCalculationMode)
setCustomer(?CustomerReference $customer)
setShippingRateInput(?ShippingRateInput $shippingRateInput)
setCustomLineItems(?CustomLineItemCollection $customLineItems)
setDirectDiscounts(?DirectDiscountCollection $directDiscounts)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setCreatedAt(?DateTimeImmutable $createdAt)
setLineItems(?LineItemCollection $lineItems)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?QuoteRequestReference $quoteRequest=null, ?StagedQuoteReference $stagedQuote=null, ?CustomerReference $customer=null, ?CustomerGroupReference $customerGroup=null, ?DateTimeImmutable $validTo=null, ?string $sellerComment=null, ?string $buyerComment=null, ?StoreKeyReference $store=null, ?LineItemCollection $lineItems=null, ?CustomLineItemCollection $customLineItems=null, ?TypedMoney $totalPrice=null, ?TaxedPrice $taxedPrice=null, ?Address $shippingAddress=null, ?Address $billingAddress=null, ?string $inventoryMode=null, ?string $taxMode=null, ?string $taxRoundingMode=null, ?string $taxCalculationMode=null, ?string $country=null, ?ShippingInfo $shippingInfo=null, ?PaymentInfo $paymentInfo=null, ?ShippingRateInput $shippingRateInput=null, ?AddressCollection $itemShippingAddresses=null, ?DirectDiscountCollection $directDiscounts=null, ?CustomFields $custom=null, ?string $quoteState=null, ?StateReference $state=null, ?string $purchaseOrderNumber=null, ?BusinessUnitKeyReference $businessUnit=null)
setCustomerGroup(?CustomerGroupReference $customerGroup)
setStagedQuote(?StagedQuoteReference $stagedQuote)
setValidTo(?DateTimeImmutable $validTo)
setBusinessUnit(?BusinessUnitKeyReference $businessUnit)
setShippingAddress(?Address $shippingAddress)
setShippingInfo(?ShippingInfo $shippingInfo)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setPurchaseOrderNumber(?string $purchaseOrderNumber)
setQuoteRequest(?QuoteRequestReference $quoteRequest)
setItemShippingAddresses(?AddressCollection $itemShippingAddresses)