commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
InventoryEntryModel.php
1<?php
2
3declare(strict_types=1);
10
25use DateTimeImmutable;
26use stdClass;
27
32{
37 protected $id;
38
43 protected $version;
44
49 protected $createdAt;
50
55 protected $lastModifiedAt;
56
61 protected $lastModifiedBy;
62
67 protected $createdBy;
68
73 protected $key;
74
79 protected $sku;
80
85 protected $supplyChannel;
86
92
98
104
110
116
122
128
133 protected $stockLevels;
134
139 protected $custom;
140
141
145 public function __construct(
146 ?string $id = null,
147 ?int $version = null,
148 ?DateTimeImmutable $createdAt = null,
149 ?DateTimeImmutable $lastModifiedAt = null,
151 ?CreatedBy $createdBy = null,
152 ?string $key = null,
153 ?string $sku = null,
155 ?int $quantityOnStock = null,
156 ?int $availableQuantity = null,
157 ?int $minCartQuantity = null,
158 ?int $maxCartQuantity = null,
159 ?int $restockableInDays = null,
160 ?DateTimeImmutable $expectedDelivery = null,
163 ?CustomFields $custom = null
164 ) {
165 $this->id = $id;
166 $this->version = $version;
167 $this->createdAt = $createdAt;
168 $this->lastModifiedAt = $lastModifiedAt;
169 $this->lastModifiedBy = $lastModifiedBy;
170 $this->createdBy = $createdBy;
171 $this->key = $key;
172 $this->sku = $sku;
173 $this->supplyChannel = $supplyChannel;
174 $this->quantityOnStock = $quantityOnStock;
175 $this->availableQuantity = $availableQuantity;
176 $this->minCartQuantity = $minCartQuantity;
177 $this->maxCartQuantity = $maxCartQuantity;
178 $this->restockableInDays = $restockableInDays;
179 $this->expectedDelivery = $expectedDelivery;
180 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
181 $this->stockLevels = $stockLevels;
182 $this->custom = $custom;
183 }
184
191 public function getId()
192 {
193 if (is_null($this->id)) {
195 $data = $this->raw(self::FIELD_ID);
196 if (is_null($data)) {
197 return null;
198 }
199 $this->id = (string) $data;
200 }
201
202 return $this->id;
203 }
204
211 public function getVersion()
212 {
213 if (is_null($this->version)) {
215 $data = $this->raw(self::FIELD_VERSION);
216 if (is_null($data)) {
217 return null;
218 }
219 $this->version = (int) $data;
220 }
221
222 return $this->version;
223 }
224
231 public function getCreatedAt()
232 {
233 if (is_null($this->createdAt)) {
235 $data = $this->raw(self::FIELD_CREATED_AT);
236 if (is_null($data)) {
237 return null;
238 }
239 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
240 if (false === $data) {
241 return null;
242 }
243 $this->createdAt = $data;
244 }
245
246 return $this->createdAt;
247 }
248
255 public function getLastModifiedAt()
256 {
257 if (is_null($this->lastModifiedAt)) {
259 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
260 if (is_null($data)) {
261 return null;
262 }
263 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
264 if (false === $data) {
265 return null;
266 }
267 $this->lastModifiedAt = $data;
268 }
269
271 }
272
279 public function getLastModifiedBy()
280 {
281 if (is_null($this->lastModifiedBy)) {
283 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
284 if (is_null($data)) {
285 return null;
286 }
287
288 $this->lastModifiedBy = LastModifiedByModel::of($data);
289 }
290
292 }
293
300 public function getCreatedBy()
301 {
302 if (is_null($this->createdBy)) {
304 $data = $this->raw(self::FIELD_CREATED_BY);
305 if (is_null($data)) {
306 return null;
307 }
308
309 $this->createdBy = CreatedByModel::of($data);
310 }
311
312 return $this->createdBy;
313 }
314
321 public function getKey()
322 {
323 if (is_null($this->key)) {
325 $data = $this->raw(self::FIELD_KEY);
326 if (is_null($data)) {
327 return null;
328 }
329 $this->key = (string) $data;
330 }
331
332 return $this->key;
333 }
334
341 public function getSku()
342 {
343 if (is_null($this->sku)) {
345 $data = $this->raw(self::FIELD_SKU);
346 if (is_null($data)) {
347 return null;
348 }
349 $this->sku = (string) $data;
350 }
351
352 return $this->sku;
353 }
354
361 public function getSupplyChannel()
362 {
363 if (is_null($this->supplyChannel)) {
365 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
366 if (is_null($data)) {
367 return null;
368 }
369
370 $this->supplyChannel = ChannelReferenceModel::of($data);
371 }
372
374 }
375
382 public function getQuantityOnStock()
383 {
384 if (is_null($this->quantityOnStock)) {
386 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
387 if (is_null($data)) {
388 return null;
389 }
390 $this->quantityOnStock = (int) $data;
391 }
392
394 }
395
402 public function getAvailableQuantity()
403 {
404 if (is_null($this->availableQuantity)) {
406 $data = $this->raw(self::FIELD_AVAILABLE_QUANTITY);
407 if (is_null($data)) {
408 return null;
409 }
410 $this->availableQuantity = (int) $data;
411 }
412
414 }
415
422 public function getMinCartQuantity()
423 {
424 if (is_null($this->minCartQuantity)) {
426 $data = $this->raw(self::FIELD_MIN_CART_QUANTITY);
427 if (is_null($data)) {
428 return null;
429 }
430 $this->minCartQuantity = (int) $data;
431 }
432
434 }
435
442 public function getMaxCartQuantity()
443 {
444 if (is_null($this->maxCartQuantity)) {
446 $data = $this->raw(self::FIELD_MAX_CART_QUANTITY);
447 if (is_null($data)) {
448 return null;
449 }
450 $this->maxCartQuantity = (int) $data;
451 }
452
454 }
455
462 public function getRestockableInDays()
463 {
464 if (is_null($this->restockableInDays)) {
466 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
467 if (is_null($data)) {
468 return null;
469 }
470 $this->restockableInDays = (int) $data;
471 }
472
474 }
475
482 public function getExpectedDelivery()
483 {
484 if (is_null($this->expectedDelivery)) {
486 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
487 if (is_null($data)) {
488 return null;
489 }
490 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
491 if (false === $data) {
492 return null;
493 }
494 $this->expectedDelivery = $data;
495 }
496
498 }
499
511 {
512 if (is_null($this->reservationExpirationInMinutes)) {
514 $data = $this->raw(self::FIELD_RESERVATION_EXPIRATION_IN_MINUTES);
515 if (is_null($data)) {
516 return null;
517 }
518 $this->reservationExpirationInMinutes = (int) $data;
519 }
520
522 }
523
530 public function getStockLevels()
531 {
532 if (is_null($this->stockLevels)) {
534 $data = $this->raw(self::FIELD_STOCK_LEVELS);
535 if (is_null($data)) {
536 return null;
537 }
538
539 $this->stockLevels = InventoryEntryStockLevelsModel::of($data);
540 }
541
542 return $this->stockLevels;
543 }
544
551 public function getCustom()
552 {
553 if (is_null($this->custom)) {
555 $data = $this->raw(self::FIELD_CUSTOM);
556 if (is_null($data)) {
557 return null;
558 }
559
560 $this->custom = CustomFieldsModel::of($data);
561 }
562
563 return $this->custom;
564 }
565
566
570 public function setId(?string $id): void
571 {
572 $this->id = $id;
573 }
574
578 public function setVersion(?int $version): void
579 {
580 $this->version = $version;
581 }
582
586 public function setCreatedAt(?DateTimeImmutable $createdAt): void
587 {
588 $this->createdAt = $createdAt;
589 }
590
594 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
595 {
596 $this->lastModifiedAt = $lastModifiedAt;
597 }
598
603 {
604 $this->lastModifiedBy = $lastModifiedBy;
605 }
606
610 public function setCreatedBy(?CreatedBy $createdBy): void
611 {
612 $this->createdBy = $createdBy;
613 }
614
618 public function setKey(?string $key): void
619 {
620 $this->key = $key;
621 }
622
626 public function setSku(?string $sku): void
627 {
628 $this->sku = $sku;
629 }
630
635 {
636 $this->supplyChannel = $supplyChannel;
637 }
638
642 public function setQuantityOnStock(?int $quantityOnStock): void
643 {
644 $this->quantityOnStock = $quantityOnStock;
645 }
646
650 public function setAvailableQuantity(?int $availableQuantity): void
651 {
652 $this->availableQuantity = $availableQuantity;
653 }
654
658 public function setMinCartQuantity(?int $minCartQuantity): void
659 {
660 $this->minCartQuantity = $minCartQuantity;
661 }
662
666 public function setMaxCartQuantity(?int $maxCartQuantity): void
667 {
668 $this->maxCartQuantity = $maxCartQuantity;
669 }
670
674 public function setRestockableInDays(?int $restockableInDays): void
675 {
676 $this->restockableInDays = $restockableInDays;
677 }
678
682 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
683 {
684 $this->expectedDelivery = $expectedDelivery;
685 }
686
691 {
692 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
693 }
694
699 {
700 $this->stockLevels = $stockLevels;
701 }
702
706 public function setCustom(?CustomFields $custom): void
707 {
708 $this->custom = $custom;
709 }
710
711
712 #[\ReturnTypeWillChange]
713 public function jsonSerialize()
714 {
715 $data = $this->toArray();
716 if (isset($data[InventoryEntry::FIELD_CREATED_AT]) && $data[InventoryEntry::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
717 $data[InventoryEntry::FIELD_CREATED_AT] = $data[InventoryEntry::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
718 }
719
720 if (isset($data[InventoryEntry::FIELD_LAST_MODIFIED_AT]) && $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
721 $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] = $data[InventoryEntry::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
722 }
723
724 if (isset($data[InventoryEntry::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
725 $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntry::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
726 }
727 return (object) $data;
728 }
729}
getReservationExpirationInMinutes()
$key
$supplyChannel
getVersion()
$minCartQuantity
$createdBy
$lastModifiedBy
setCreatedAt(?DateTimeImmutable $createdAt)
jsonSerialize()
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
getLastModifiedAt()
getMaxCartQuantity()
getSupplyChannel()
$lastModifiedAt
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?string $sku=null, ?ChannelReference $supplyChannel=null, ?int $quantityOnStock=null, ?int $availableQuantity=null, ?int $minCartQuantity=null, ?int $maxCartQuantity=null, ?int $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?int $reservationExpirationInMinutes=null, ?InventoryEntryStockLevels $stockLevels=null, ?CustomFields $custom=null)
getMinCartQuantity()
getSku()
getKey()
setKey(?string $key)
setStockLevels(?InventoryEntryStockLevels $stockLevels)
getAvailableQuantity()
getLastModifiedBy()
getCreatedAt()
getCreatedBy()
$restockableInDays
$version
getRestockableInDays()
setSku(?string $sku)
$reservationExpirationInMinutes
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setReservationExpirationInMinutes(?int $reservationExpirationInMinutes)
$custom
setQuantityOnStock(?int $quantityOnStock)
$quantityOnStock
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setMaxCartQuantity(?int $maxCartQuantity)
$availableQuantity
$sku
setCustom(?CustomFields $custom)
setCreatedBy(?CreatedBy $createdBy)
$maxCartQuantity
setId(?string $id)
$expectedDelivery
getExpectedDelivery()
setSupplyChannel(?ChannelReference $supplyChannel)
setVersion(?int $version)
$id
setRestockableInDays(?int $restockableInDays)
getId()
getCustom()
$createdAt
setAvailableQuantity(?int $availableQuantity)
$stockLevels
setMinCartQuantity(?int $minCartQuantity)
getStockLevels()
getQuantityOnStock()
const FIELD_EXPECTED_DELIVERY