commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
OrderImportModel.php
1<?php
2
3declare(strict_types=1);
10
30use DateTimeImmutable;
31use stdClass;
32
36final class OrderImportModel extends JsonObjectModel implements OrderImport
37{
42 protected $orderNumber;
43
48 protected $customer;
49
54 protected $customerEmail;
55
60 protected $lineItems;
61
67
72 protected $totalPrice;
73
78 protected $taxedPrice;
79
85
90 protected $billingAddress;
91
96 protected $customerGroup;
97
102 protected $country;
103
108 protected $orderState;
109
114 protected $shipmentState;
115
120 protected $paymentState;
121
126 protected $shippingInfo;
127
132 protected $completedAt;
133
138 protected $custom;
139
144 protected $inventoryMode;
145
151
157
162 protected $origin;
163
169
174 protected $store;
175
180 protected $state;
181
182
186 public function __construct(
187 ?string $orderNumber = null,
189 ?string $customerEmail = null,
192 ?TypedMoney $totalPrice = null,
193 ?TaxedPrice $taxedPrice = null,
195 ?Address $billingAddress = null,
197 ?string $country = null,
198 ?string $orderState = null,
199 ?string $shipmentState = null,
200 ?string $paymentState = null,
202 ?DateTimeImmutable $completedAt = null,
203 ?Custom $custom = null,
204 ?string $inventoryMode = null,
205 ?string $taxRoundingMode = null,
206 ?string $taxCalculationMode = null,
207 ?string $origin = null,
211 ) {
212 $this->orderNumber = $orderNumber;
213 $this->customer = $customer;
214 $this->customerEmail = $customerEmail;
215 $this->lineItems = $lineItems;
216 $this->customLineItems = $customLineItems;
217 $this->totalPrice = $totalPrice;
218 $this->taxedPrice = $taxedPrice;
219 $this->shippingAddress = $shippingAddress;
220 $this->billingAddress = $billingAddress;
221 $this->customerGroup = $customerGroup;
222 $this->country = $country;
223 $this->orderState = $orderState;
224 $this->shipmentState = $shipmentState;
225 $this->paymentState = $paymentState;
226 $this->shippingInfo = $shippingInfo;
227 $this->completedAt = $completedAt;
228 $this->custom = $custom;
229 $this->inventoryMode = $inventoryMode;
230 $this->taxRoundingMode = $taxRoundingMode;
231 $this->taxCalculationMode = $taxCalculationMode;
232 $this->origin = $origin;
233 $this->itemShippingAddresses = $itemShippingAddresses;
234 $this->store = $store;
235 $this->state = $state;
236 }
237
244 public function getOrderNumber()
245 {
246 if (is_null($this->orderNumber)) {
248 $data = $this->raw(self::FIELD_ORDER_NUMBER);
249 if (is_null($data)) {
250 return null;
251 }
252 $this->orderNumber = (string) $data;
253 }
254
255 return $this->orderNumber;
256 }
257
264 public function getCustomer()
265 {
266 if (is_null($this->customer)) {
268 $data = $this->raw(self::FIELD_CUSTOMER);
269 if (is_null($data)) {
270 return null;
271 }
272
273 $this->customer = CustomerKeyReferenceModel::of($data);
274 }
275
276 return $this->customer;
277 }
278
285 public function getCustomerEmail()
286 {
287 if (is_null($this->customerEmail)) {
289 $data = $this->raw(self::FIELD_CUSTOMER_EMAIL);
290 if (is_null($data)) {
291 return null;
292 }
293 $this->customerEmail = (string) $data;
294 }
295
297 }
298
305 public function getLineItems()
306 {
307 if (is_null($this->lineItems)) {
309 $data = $this->raw(self::FIELD_LINE_ITEMS);
310 if (is_null($data)) {
311 return null;
312 }
313 $this->lineItems = LineItemImportDraftCollection::fromArray($data);
314 }
315
316 return $this->lineItems;
317 }
318
325 public function getCustomLineItems()
326 {
327 if (is_null($this->customLineItems)) {
329 $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEMS);
330 if (is_null($data)) {
331 return null;
332 }
333 $this->customLineItems = CustomLineItemDraftCollection::fromArray($data);
334 }
335
337 }
338
345 public function getTotalPrice()
346 {
347 if (is_null($this->totalPrice)) {
349 $data = $this->raw(self::FIELD_TOTAL_PRICE);
350 if (is_null($data)) {
351 return null;
352 }
353 $className = TypedMoneyModel::resolveDiscriminatorClass($data);
354 $this->totalPrice = $className::of($data);
355 }
356
357 return $this->totalPrice;
358 }
359
366 public function getTaxedPrice()
367 {
368 if (is_null($this->taxedPrice)) {
370 $data = $this->raw(self::FIELD_TAXED_PRICE);
371 if (is_null($data)) {
372 return null;
373 }
374
375 $this->taxedPrice = TaxedPriceModel::of($data);
376 }
377
378 return $this->taxedPrice;
379 }
380
387 public function getShippingAddress()
388 {
389 if (is_null($this->shippingAddress)) {
391 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS);
392 if (is_null($data)) {
393 return null;
394 }
395
396 $this->shippingAddress = AddressModel::of($data);
397 }
398
400 }
401
408 public function getBillingAddress()
409 {
410 if (is_null($this->billingAddress)) {
412 $data = $this->raw(self::FIELD_BILLING_ADDRESS);
413 if (is_null($data)) {
414 return null;
415 }
416
417 $this->billingAddress = AddressModel::of($data);
418 }
419
421 }
422
429 public function getCustomerGroup()
430 {
431 if (is_null($this->customerGroup)) {
433 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
434 if (is_null($data)) {
435 return null;
436 }
437
438 $this->customerGroup = CustomerGroupKeyReferenceModel::of($data);
439 }
440
442 }
443
450 public function getCountry()
451 {
452 if (is_null($this->country)) {
454 $data = $this->raw(self::FIELD_COUNTRY);
455 if (is_null($data)) {
456 return null;
457 }
458 $this->country = (string) $data;
459 }
460
461 return $this->country;
462 }
463
470 public function getOrderState()
471 {
472 if (is_null($this->orderState)) {
474 $data = $this->raw(self::FIELD_ORDER_STATE);
475 if (is_null($data)) {
476 return null;
477 }
478 $this->orderState = (string) $data;
479 }
480
481 return $this->orderState;
482 }
483
490 public function getShipmentState()
491 {
492 if (is_null($this->shipmentState)) {
494 $data = $this->raw(self::FIELD_SHIPMENT_STATE);
495 if (is_null($data)) {
496 return null;
497 }
498 $this->shipmentState = (string) $data;
499 }
500
502 }
503
510 public function getPaymentState()
511 {
512 if (is_null($this->paymentState)) {
514 $data = $this->raw(self::FIELD_PAYMENT_STATE);
515 if (is_null($data)) {
516 return null;
517 }
518 $this->paymentState = (string) $data;
519 }
520
521 return $this->paymentState;
522 }
523
530 public function getShippingInfo()
531 {
532 if (is_null($this->shippingInfo)) {
534 $data = $this->raw(self::FIELD_SHIPPING_INFO);
535 if (is_null($data)) {
536 return null;
537 }
538
539 $this->shippingInfo = ShippingInfoImportDraftModel::of($data);
540 }
541
542 return $this->shippingInfo;
543 }
544
551 public function getCompletedAt()
552 {
553 if (is_null($this->completedAt)) {
555 $data = $this->raw(self::FIELD_COMPLETED_AT);
556 if (is_null($data)) {
557 return null;
558 }
559 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
560 if (false === $data) {
561 return null;
562 }
563 $this->completedAt = $data;
564 }
565
566 return $this->completedAt;
567 }
568
575 public function getCustom()
576 {
577 if (is_null($this->custom)) {
579 $data = $this->raw(self::FIELD_CUSTOM);
580 if (is_null($data)) {
581 return null;
582 }
583
584 $this->custom = CustomModel::of($data);
585 }
586
587 return $this->custom;
588 }
589
596 public function getInventoryMode()
597 {
598 if (is_null($this->inventoryMode)) {
600 $data = $this->raw(self::FIELD_INVENTORY_MODE);
601 if (is_null($data)) {
602 return null;
603 }
604 $this->inventoryMode = (string) $data;
605 }
606
608 }
609
616 public function getTaxRoundingMode()
617 {
618 if (is_null($this->taxRoundingMode)) {
620 $data = $this->raw(self::FIELD_TAX_ROUNDING_MODE);
621 if (is_null($data)) {
622 return null;
623 }
624 $this->taxRoundingMode = (string) $data;
625 }
626
628 }
629
636 public function getTaxCalculationMode()
637 {
638 if (is_null($this->taxCalculationMode)) {
640 $data = $this->raw(self::FIELD_TAX_CALCULATION_MODE);
641 if (is_null($data)) {
642 return null;
643 }
644 $this->taxCalculationMode = (string) $data;
645 }
646
648 }
649
656 public function getOrigin()
657 {
658 if (is_null($this->origin)) {
660 $data = $this->raw(self::FIELD_ORIGIN);
661 if (is_null($data)) {
662 return null;
663 }
664 $this->origin = (string) $data;
665 }
666
667 return $this->origin;
668 }
669
676 public function getItemShippingAddresses()
677 {
678 if (is_null($this->itemShippingAddresses)) {
680 $data = $this->raw(self::FIELD_ITEM_SHIPPING_ADDRESSES);
681 if (is_null($data)) {
682 return null;
683 }
684 $this->itemShippingAddresses = AddressCollection::fromArray($data);
685 }
686
688 }
689
696 public function getStore()
697 {
698 if (is_null($this->store)) {
700 $data = $this->raw(self::FIELD_STORE);
701 if (is_null($data)) {
702 return null;
703 }
704
705 $this->store = StoreKeyReferenceModel::of($data);
706 }
707
708 return $this->store;
709 }
710
717 public function getState()
718 {
719 if (is_null($this->state)) {
721 $data = $this->raw(self::FIELD_STATE);
722 if (is_null($data)) {
723 return null;
724 }
725
726 $this->state = StateKeyReferenceModel::of($data);
727 }
728
729 return $this->state;
730 }
731
732
736 public function setOrderNumber(?string $orderNumber): void
737 {
738 $this->orderNumber = $orderNumber;
739 }
740
745 {
746 $this->customer = $customer;
747 }
748
752 public function setCustomerEmail(?string $customerEmail): void
753 {
754 $this->customerEmail = $customerEmail;
755 }
756
761 {
762 $this->lineItems = $lineItems;
763 }
764
769 {
770 $this->customLineItems = $customLineItems;
771 }
772
776 public function setTotalPrice(?TypedMoney $totalPrice): void
777 {
778 $this->totalPrice = $totalPrice;
779 }
780
784 public function setTaxedPrice(?TaxedPrice $taxedPrice): void
785 {
786 $this->taxedPrice = $taxedPrice;
787 }
788
793 {
794 $this->shippingAddress = $shippingAddress;
795 }
796
801 {
802 $this->billingAddress = $billingAddress;
803 }
804
809 {
810 $this->customerGroup = $customerGroup;
811 }
812
816 public function setCountry(?string $country): void
817 {
818 $this->country = $country;
819 }
820
824 public function setOrderState(?string $orderState): void
825 {
826 $this->orderState = $orderState;
827 }
828
832 public function setShipmentState(?string $shipmentState): void
833 {
834 $this->shipmentState = $shipmentState;
835 }
836
840 public function setPaymentState(?string $paymentState): void
841 {
842 $this->paymentState = $paymentState;
843 }
844
849 {
850 $this->shippingInfo = $shippingInfo;
851 }
852
856 public function setCompletedAt(?DateTimeImmutable $completedAt): void
857 {
858 $this->completedAt = $completedAt;
859 }
860
864 public function setCustom(?Custom $custom): void
865 {
866 $this->custom = $custom;
867 }
868
872 public function setInventoryMode(?string $inventoryMode): void
873 {
874 $this->inventoryMode = $inventoryMode;
875 }
876
880 public function setTaxRoundingMode(?string $taxRoundingMode): void
881 {
882 $this->taxRoundingMode = $taxRoundingMode;
883 }
884
888 public function setTaxCalculationMode(?string $taxCalculationMode): void
889 {
890 $this->taxCalculationMode = $taxCalculationMode;
891 }
892
896 public function setOrigin(?string $origin): void
897 {
898 $this->origin = $origin;
899 }
900
905 {
906 $this->itemShippingAddresses = $itemShippingAddresses;
907 }
908
912 public function setStore(?StoreKeyReference $store): void
913 {
914 $this->store = $store;
915 }
916
920 public function setState(?StateKeyReference $state): void
921 {
922 $this->state = $state;
923 }
924
925
926 #[\ReturnTypeWillChange]
927 public function jsonSerialize()
928 {
929 $data = $this->toArray();
930 if (isset($data[OrderImport::FIELD_COMPLETED_AT]) && $data[OrderImport::FIELD_COMPLETED_AT] instanceof \DateTimeImmutable) {
931 $data[OrderImport::FIELD_COMPLETED_AT] = $data[OrderImport::FIELD_COMPLETED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
932 }
933 return (object) $data;
934 }
935}
setShippingInfo(?ShippingInfoImportDraft $shippingInfo)
setCustomerGroup(?CustomerGroupKeyReference $customerGroup)
setLineItems(?LineItemImportDraftCollection $lineItems)
setCustomLineItems(?CustomLineItemDraftCollection $customLineItems)
__construct(?string $orderNumber=null, ?CustomerKeyReference $customer=null, ?string $customerEmail=null, ?LineItemImportDraftCollection $lineItems=null, ?CustomLineItemDraftCollection $customLineItems=null, ?TypedMoney $totalPrice=null, ?TaxedPrice $taxedPrice=null, ?Address $shippingAddress=null, ?Address $billingAddress=null, ?CustomerGroupKeyReference $customerGroup=null, ?string $country=null, ?string $orderState=null, ?string $shipmentState=null, ?string $paymentState=null, ?ShippingInfoImportDraft $shippingInfo=null, ?DateTimeImmutable $completedAt=null, ?Custom $custom=null, ?string $inventoryMode=null, ?string $taxRoundingMode=null, ?string $taxCalculationMode=null, ?string $origin=null, ?AddressCollection $itemShippingAddresses=null, ?StoreKeyReference $store=null, ?StateKeyReference $state=null)
setItemShippingAddresses(?AddressCollection $itemShippingAddresses)
static fromArray(array $data)