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
127 protected $custom;
128
129
133 public function __construct(
134 ?string $id = null,
135 ?int $version = null,
136 ?DateTimeImmutable $createdAt = null,
137 ?DateTimeImmutable $lastModifiedAt = null,
139 ?CreatedBy $createdBy = null,
140 ?string $key = null,
141 ?string $sku = null,
143 ?int $quantityOnStock = null,
144 ?int $availableQuantity = null,
145 ?int $minCartQuantity = null,
146 ?int $maxCartQuantity = null,
147 ?int $restockableInDays = null,
148 ?DateTimeImmutable $expectedDelivery = null,
149 ?CustomFields $custom = null
150 ) {
151 $this->id = $id;
152 $this->version = $version;
153 $this->createdAt = $createdAt;
154 $this->lastModifiedAt = $lastModifiedAt;
155 $this->lastModifiedBy = $lastModifiedBy;
156 $this->createdBy = $createdBy;
157 $this->key = $key;
158 $this->sku = $sku;
159 $this->supplyChannel = $supplyChannel;
160 $this->quantityOnStock = $quantityOnStock;
161 $this->availableQuantity = $availableQuantity;
162 $this->minCartQuantity = $minCartQuantity;
163 $this->maxCartQuantity = $maxCartQuantity;
164 $this->restockableInDays = $restockableInDays;
165 $this->expectedDelivery = $expectedDelivery;
166 $this->custom = $custom;
167 }
168
175 public function getId()
176 {
177 if (is_null($this->id)) {
179 $data = $this->raw(self::FIELD_ID);
180 if (is_null($data)) {
181 return null;
182 }
183 $this->id = (string) $data;
184 }
185
186 return $this->id;
187 }
188
195 public function getVersion()
196 {
197 if (is_null($this->version)) {
199 $data = $this->raw(self::FIELD_VERSION);
200 if (is_null($data)) {
201 return null;
202 }
203 $this->version = (int) $data;
204 }
205
206 return $this->version;
207 }
208
215 public function getCreatedAt()
216 {
217 if (is_null($this->createdAt)) {
219 $data = $this->raw(self::FIELD_CREATED_AT);
220 if (is_null($data)) {
221 return null;
222 }
223 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
224 if (false === $data) {
225 return null;
226 }
227 $this->createdAt = $data;
228 }
229
230 return $this->createdAt;
231 }
232
239 public function getLastModifiedAt()
240 {
241 if (is_null($this->lastModifiedAt)) {
243 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
244 if (is_null($data)) {
245 return null;
246 }
247 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
248 if (false === $data) {
249 return null;
250 }
251 $this->lastModifiedAt = $data;
252 }
253
255 }
256
263 public function getLastModifiedBy()
264 {
265 if (is_null($this->lastModifiedBy)) {
267 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
268 if (is_null($data)) {
269 return null;
270 }
271
272 $this->lastModifiedBy = LastModifiedByModel::of($data);
273 }
274
276 }
277
284 public function getCreatedBy()
285 {
286 if (is_null($this->createdBy)) {
288 $data = $this->raw(self::FIELD_CREATED_BY);
289 if (is_null($data)) {
290 return null;
291 }
292
293 $this->createdBy = CreatedByModel::of($data);
294 }
295
296 return $this->createdBy;
297 }
298
305 public function getKey()
306 {
307 if (is_null($this->key)) {
309 $data = $this->raw(self::FIELD_KEY);
310 if (is_null($data)) {
311 return null;
312 }
313 $this->key = (string) $data;
314 }
315
316 return $this->key;
317 }
318
325 public function getSku()
326 {
327 if (is_null($this->sku)) {
329 $data = $this->raw(self::FIELD_SKU);
330 if (is_null($data)) {
331 return null;
332 }
333 $this->sku = (string) $data;
334 }
335
336 return $this->sku;
337 }
338
345 public function getSupplyChannel()
346 {
347 if (is_null($this->supplyChannel)) {
349 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
350 if (is_null($data)) {
351 return null;
352 }
353
354 $this->supplyChannel = ChannelReferenceModel::of($data);
355 }
356
358 }
359
366 public function getQuantityOnStock()
367 {
368 if (is_null($this->quantityOnStock)) {
370 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
371 if (is_null($data)) {
372 return null;
373 }
374 $this->quantityOnStock = (int) $data;
375 }
376
378 }
379
386 public function getAvailableQuantity()
387 {
388 if (is_null($this->availableQuantity)) {
390 $data = $this->raw(self::FIELD_AVAILABLE_QUANTITY);
391 if (is_null($data)) {
392 return null;
393 }
394 $this->availableQuantity = (int) $data;
395 }
396
398 }
399
406 public function getMinCartQuantity()
407 {
408 if (is_null($this->minCartQuantity)) {
410 $data = $this->raw(self::FIELD_MIN_CART_QUANTITY);
411 if (is_null($data)) {
412 return null;
413 }
414 $this->minCartQuantity = (int) $data;
415 }
416
418 }
419
426 public function getMaxCartQuantity()
427 {
428 if (is_null($this->maxCartQuantity)) {
430 $data = $this->raw(self::FIELD_MAX_CART_QUANTITY);
431 if (is_null($data)) {
432 return null;
433 }
434 $this->maxCartQuantity = (int) $data;
435 }
436
438 }
439
446 public function getRestockableInDays()
447 {
448 if (is_null($this->restockableInDays)) {
450 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
451 if (is_null($data)) {
452 return null;
453 }
454 $this->restockableInDays = (int) $data;
455 }
456
458 }
459
466 public function getExpectedDelivery()
467 {
468 if (is_null($this->expectedDelivery)) {
470 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
471 if (is_null($data)) {
472 return null;
473 }
474 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
475 if (false === $data) {
476 return null;
477 }
478 $this->expectedDelivery = $data;
479 }
480
482 }
483
490 public function getCustom()
491 {
492 if (is_null($this->custom)) {
494 $data = $this->raw(self::FIELD_CUSTOM);
495 if (is_null($data)) {
496 return null;
497 }
498
499 $this->custom = CustomFieldsModel::of($data);
500 }
501
502 return $this->custom;
503 }
504
505
509 public function setId(?string $id): void
510 {
511 $this->id = $id;
512 }
513
517 public function setVersion(?int $version): void
518 {
519 $this->version = $version;
520 }
521
525 public function setCreatedAt(?DateTimeImmutable $createdAt): void
526 {
527 $this->createdAt = $createdAt;
528 }
529
533 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
534 {
535 $this->lastModifiedAt = $lastModifiedAt;
536 }
537
542 {
543 $this->lastModifiedBy = $lastModifiedBy;
544 }
545
549 public function setCreatedBy(?CreatedBy $createdBy): void
550 {
551 $this->createdBy = $createdBy;
552 }
553
557 public function setKey(?string $key): void
558 {
559 $this->key = $key;
560 }
561
565 public function setSku(?string $sku): void
566 {
567 $this->sku = $sku;
568 }
569
574 {
575 $this->supplyChannel = $supplyChannel;
576 }
577
581 public function setQuantityOnStock(?int $quantityOnStock): void
582 {
583 $this->quantityOnStock = $quantityOnStock;
584 }
585
589 public function setAvailableQuantity(?int $availableQuantity): void
590 {
591 $this->availableQuantity = $availableQuantity;
592 }
593
597 public function setMinCartQuantity(?int $minCartQuantity): void
598 {
599 $this->minCartQuantity = $minCartQuantity;
600 }
601
605 public function setMaxCartQuantity(?int $maxCartQuantity): void
606 {
607 $this->maxCartQuantity = $maxCartQuantity;
608 }
609
613 public function setRestockableInDays(?int $restockableInDays): void
614 {
615 $this->restockableInDays = $restockableInDays;
616 }
617
621 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
622 {
623 $this->expectedDelivery = $expectedDelivery;
624 }
625
629 public function setCustom(?CustomFields $custom): void
630 {
631 $this->custom = $custom;
632 }
633
634
635 #[\ReturnTypeWillChange]
636 public function jsonSerialize()
637 {
638 $data = $this->toArray();
639 if (isset($data[InventoryEntry::FIELD_CREATED_AT]) && $data[InventoryEntry::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
640 $data[InventoryEntry::FIELD_CREATED_AT] = $data[InventoryEntry::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
641 }
642
643 if (isset($data[InventoryEntry::FIELD_LAST_MODIFIED_AT]) && $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
644 $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] = $data[InventoryEntry::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
645 }
646
647 if (isset($data[InventoryEntry::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
648 $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntry::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
649 }
650 return (object) $data;
651 }
652}
$key
$supplyChannel
getVersion()
$minCartQuantity
$createdBy
$lastModifiedBy
setCreatedAt(?DateTimeImmutable $createdAt)
jsonSerialize()
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
getLastModifiedAt()
getMaxCartQuantity()
getSupplyChannel()
$lastModifiedAt
getMinCartQuantity()
getSku()
getKey()
__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, ?CustomFields $custom=null)
setKey(?string $key)
getAvailableQuantity()
getLastModifiedBy()
getCreatedAt()
getCreatedBy()
$restockableInDays
$version
getRestockableInDays()
setSku(?string $sku)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
$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)
setMinCartQuantity(?int $minCartQuantity)
getQuantityOnStock()
const FIELD_EXPECTED_DELIVERY