commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
OrderImportModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
30 use DateTimeImmutable;
31 use stdClass;
32 
36 final class OrderImportModel extends JsonObjectModel implements OrderImport
37 {
42  protected $orderNumber;
43 
48  protected $customer;
49 
54  protected $customerEmail;
55 
60  protected $lineItems;
61 
66  protected $customLineItems;
67 
72  protected $totalPrice;
73 
78  protected $taxedPrice;
79 
84  protected $shippingAddress;
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 
150  protected $taxRoundingMode;
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,
194  ?Address $shippingAddress = 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,
209  ?StoreKeyReference $store = null,
210  ?StateKeyReference $state = 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 
262  public function getCustomer()
263  {
264  if (is_null($this->customer)) {
266  $data = $this->raw(self::FIELD_CUSTOMER);
267  if (is_null($data)) {
268  return null;
269  }
270 
271  $this->customer = CustomerKeyReferenceModel::of($data);
272  }
273 
274  return $this->customer;
275  }
276 
283  public function getCustomerEmail()
284  {
285  if (is_null($this->customerEmail)) {
287  $data = $this->raw(self::FIELD_CUSTOMER_EMAIL);
288  if (is_null($data)) {
289  return null;
290  }
291  $this->customerEmail = (string) $data;
292  }
293 
294  return $this->customerEmail;
295  }
296 
303  public function getLineItems()
304  {
305  if (is_null($this->lineItems)) {
307  $data = $this->raw(self::FIELD_LINE_ITEMS);
308  if (is_null($data)) {
309  return null;
310  }
311  $this->lineItems = LineItemImportDraftCollection::fromArray($data);
312  }
313 
314  return $this->lineItems;
315  }
316 
323  public function getCustomLineItems()
324  {
325  if (is_null($this->customLineItems)) {
327  $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEMS);
328  if (is_null($data)) {
329  return null;
330  }
331  $this->customLineItems = CustomLineItemDraftCollection::fromArray($data);
332  }
333 
334  return $this->customLineItems;
335  }
336 
343  public function getTotalPrice()
344  {
345  if (is_null($this->totalPrice)) {
347  $data = $this->raw(self::FIELD_TOTAL_PRICE);
348  if (is_null($data)) {
349  return null;
350  }
351  $className = TypedMoneyModel::resolveDiscriminatorClass($data);
352  $this->totalPrice = $className::of($data);
353  }
354 
355  return $this->totalPrice;
356  }
357 
364  public function getTaxedPrice()
365  {
366  if (is_null($this->taxedPrice)) {
368  $data = $this->raw(self::FIELD_TAXED_PRICE);
369  if (is_null($data)) {
370  return null;
371  }
372 
373  $this->taxedPrice = TaxedPriceModel::of($data);
374  }
375 
376  return $this->taxedPrice;
377  }
378 
385  public function getShippingAddress()
386  {
387  if (is_null($this->shippingAddress)) {
389  $data = $this->raw(self::FIELD_SHIPPING_ADDRESS);
390  if (is_null($data)) {
391  return null;
392  }
393 
394  $this->shippingAddress = AddressModel::of($data);
395  }
396 
397  return $this->shippingAddress;
398  }
399 
406  public function getBillingAddress()
407  {
408  if (is_null($this->billingAddress)) {
410  $data = $this->raw(self::FIELD_BILLING_ADDRESS);
411  if (is_null($data)) {
412  return null;
413  }
414 
415  $this->billingAddress = AddressModel::of($data);
416  }
417 
418  return $this->billingAddress;
419  }
420 
427  public function getCustomerGroup()
428  {
429  if (is_null($this->customerGroup)) {
431  $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
432  if (is_null($data)) {
433  return null;
434  }
435 
436  $this->customerGroup = CustomerGroupKeyReferenceModel::of($data);
437  }
438 
439  return $this->customerGroup;
440  }
441 
448  public function getCountry()
449  {
450  if (is_null($this->country)) {
452  $data = $this->raw(self::FIELD_COUNTRY);
453  if (is_null($data)) {
454  return null;
455  }
456  $this->country = (string) $data;
457  }
458 
459  return $this->country;
460  }
461 
468  public function getOrderState()
469  {
470  if (is_null($this->orderState)) {
472  $data = $this->raw(self::FIELD_ORDER_STATE);
473  if (is_null($data)) {
474  return null;
475  }
476  $this->orderState = (string) $data;
477  }
478 
479  return $this->orderState;
480  }
481 
488  public function getShipmentState()
489  {
490  if (is_null($this->shipmentState)) {
492  $data = $this->raw(self::FIELD_SHIPMENT_STATE);
493  if (is_null($data)) {
494  return null;
495  }
496  $this->shipmentState = (string) $data;
497  }
498 
499  return $this->shipmentState;
500  }
501 
508  public function getPaymentState()
509  {
510  if (is_null($this->paymentState)) {
512  $data = $this->raw(self::FIELD_PAYMENT_STATE);
513  if (is_null($data)) {
514  return null;
515  }
516  $this->paymentState = (string) $data;
517  }
518 
519  return $this->paymentState;
520  }
521 
528  public function getShippingInfo()
529  {
530  if (is_null($this->shippingInfo)) {
532  $data = $this->raw(self::FIELD_SHIPPING_INFO);
533  if (is_null($data)) {
534  return null;
535  }
536 
537  $this->shippingInfo = ShippingInfoImportDraftModel::of($data);
538  }
539 
540  return $this->shippingInfo;
541  }
542 
549  public function getCompletedAt()
550  {
551  if (is_null($this->completedAt)) {
553  $data = $this->raw(self::FIELD_COMPLETED_AT);
554  if (is_null($data)) {
555  return null;
556  }
557  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
558  if (false === $data) {
559  return null;
560  }
561  $this->completedAt = $data;
562  }
563 
564  return $this->completedAt;
565  }
566 
573  public function getCustom()
574  {
575  if (is_null($this->custom)) {
577  $data = $this->raw(self::FIELD_CUSTOM);
578  if (is_null($data)) {
579  return null;
580  }
581 
582  $this->custom = CustomModel::of($data);
583  }
584 
585  return $this->custom;
586  }
587 
594  public function getInventoryMode()
595  {
596  if (is_null($this->inventoryMode)) {
598  $data = $this->raw(self::FIELD_INVENTORY_MODE);
599  if (is_null($data)) {
600  return null;
601  }
602  $this->inventoryMode = (string) $data;
603  }
604 
605  return $this->inventoryMode;
606  }
607 
614  public function getTaxRoundingMode()
615  {
616  if (is_null($this->taxRoundingMode)) {
618  $data = $this->raw(self::FIELD_TAX_ROUNDING_MODE);
619  if (is_null($data)) {
620  return null;
621  }
622  $this->taxRoundingMode = (string) $data;
623  }
624 
625  return $this->taxRoundingMode;
626  }
627 
634  public function getTaxCalculationMode()
635  {
636  if (is_null($this->taxCalculationMode)) {
638  $data = $this->raw(self::FIELD_TAX_CALCULATION_MODE);
639  if (is_null($data)) {
640  return null;
641  }
642  $this->taxCalculationMode = (string) $data;
643  }
644 
646  }
647 
654  public function getOrigin()
655  {
656  if (is_null($this->origin)) {
658  $data = $this->raw(self::FIELD_ORIGIN);
659  if (is_null($data)) {
660  return null;
661  }
662  $this->origin = (string) $data;
663  }
664 
665  return $this->origin;
666  }
667 
674  public function getItemShippingAddresses()
675  {
676  if (is_null($this->itemShippingAddresses)) {
678  $data = $this->raw(self::FIELD_ITEM_SHIPPING_ADDRESSES);
679  if (is_null($data)) {
680  return null;
681  }
682  $this->itemShippingAddresses = AddressCollection::fromArray($data);
683  }
684 
686  }
687 
694  public function getStore()
695  {
696  if (is_null($this->store)) {
698  $data = $this->raw(self::FIELD_STORE);
699  if (is_null($data)) {
700  return null;
701  }
702 
703  $this->store = StoreKeyReferenceModel::of($data);
704  }
705 
706  return $this->store;
707  }
708 
715  public function getState()
716  {
717  if (is_null($this->state)) {
719  $data = $this->raw(self::FIELD_STATE);
720  if (is_null($data)) {
721  return null;
722  }
723 
724  $this->state = StateKeyReferenceModel::of($data);
725  }
726 
727  return $this->state;
728  }
729 
730 
734  public function setOrderNumber(?string $orderNumber): void
735  {
736  $this->orderNumber = $orderNumber;
737  }
738 
743  {
744  $this->customer = $customer;
745  }
746 
750  public function setCustomerEmail(?string $customerEmail): void
751  {
752  $this->customerEmail = $customerEmail;
753  }
754 
759  {
760  $this->lineItems = $lineItems;
761  }
762 
767  {
768  $this->customLineItems = $customLineItems;
769  }
770 
774  public function setTotalPrice(?TypedMoney $totalPrice): void
775  {
776  $this->totalPrice = $totalPrice;
777  }
778 
782  public function setTaxedPrice(?TaxedPrice $taxedPrice): void
783  {
784  $this->taxedPrice = $taxedPrice;
785  }
786 
791  {
792  $this->shippingAddress = $shippingAddress;
793  }
794 
798  public function setBillingAddress(?Address $billingAddress): void
799  {
800  $this->billingAddress = $billingAddress;
801  }
802 
807  {
808  $this->customerGroup = $customerGroup;
809  }
810 
814  public function setCountry(?string $country): void
815  {
816  $this->country = $country;
817  }
818 
822  public function setOrderState(?string $orderState): void
823  {
824  $this->orderState = $orderState;
825  }
826 
830  public function setShipmentState(?string $shipmentState): void
831  {
832  $this->shipmentState = $shipmentState;
833  }
834 
838  public function setPaymentState(?string $paymentState): void
839  {
840  $this->paymentState = $paymentState;
841  }
842 
847  {
848  $this->shippingInfo = $shippingInfo;
849  }
850 
854  public function setCompletedAt(?DateTimeImmutable $completedAt): void
855  {
856  $this->completedAt = $completedAt;
857  }
858 
862  public function setCustom(?Custom $custom): void
863  {
864  $this->custom = $custom;
865  }
866 
870  public function setInventoryMode(?string $inventoryMode): void
871  {
872  $this->inventoryMode = $inventoryMode;
873  }
874 
878  public function setTaxRoundingMode(?string $taxRoundingMode): void
879  {
880  $this->taxRoundingMode = $taxRoundingMode;
881  }
882 
886  public function setTaxCalculationMode(?string $taxCalculationMode): void
887  {
888  $this->taxCalculationMode = $taxCalculationMode;
889  }
890 
894  public function setOrigin(?string $origin): void
895  {
896  $this->origin = $origin;
897  }
898 
903  {
904  $this->itemShippingAddresses = $itemShippingAddresses;
905  }
906 
910  public function setStore(?StoreKeyReference $store): void
911  {
912  $this->store = $store;
913  }
914 
918  public function setState(?StateKeyReference $state): void
919  {
920  $this->state = $state;
921  }
922 
923 
924  #[\ReturnTypeWillChange]
925  public function jsonSerialize()
926  {
927  $data = $this->toArray();
928  if (isset($data[OrderImport::FIELD_COMPLETED_AT]) && $data[OrderImport::FIELD_COMPLETED_AT] instanceof \DateTimeImmutable) {
929  $data[OrderImport::FIELD_COMPLETED_AT] = $data[OrderImport::FIELD_COMPLETED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
930  }
931  return (object) $data;
932  }
933 }
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)