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
115 protected $custom;
116
117
121 public function __construct(
122 ?string $id = null,
123 ?int $version = null,
124 ?DateTimeImmutable $createdAt = null,
125 ?DateTimeImmutable $lastModifiedAt = null,
127 ?CreatedBy $createdBy = null,
128 ?string $key = null,
129 ?string $sku = null,
131 ?int $quantityOnStock = null,
132 ?int $availableQuantity = null,
133 ?int $restockableInDays = null,
134 ?DateTimeImmutable $expectedDelivery = null,
135 ?CustomFields $custom = null
136 ) {
137 $this->id = $id;
138 $this->version = $version;
139 $this->createdAt = $createdAt;
140 $this->lastModifiedAt = $lastModifiedAt;
141 $this->lastModifiedBy = $lastModifiedBy;
142 $this->createdBy = $createdBy;
143 $this->key = $key;
144 $this->sku = $sku;
145 $this->supplyChannel = $supplyChannel;
146 $this->quantityOnStock = $quantityOnStock;
147 $this->availableQuantity = $availableQuantity;
148 $this->restockableInDays = $restockableInDays;
149 $this->expectedDelivery = $expectedDelivery;
150 $this->custom = $custom;
151 }
152
159 public function getId()
160 {
161 if (is_null($this->id)) {
163 $data = $this->raw(self::FIELD_ID);
164 if (is_null($data)) {
165 return null;
166 }
167 $this->id = (string) $data;
168 }
169
170 return $this->id;
171 }
172
179 public function getVersion()
180 {
181 if (is_null($this->version)) {
183 $data = $this->raw(self::FIELD_VERSION);
184 if (is_null($data)) {
185 return null;
186 }
187 $this->version = (int) $data;
188 }
189
190 return $this->version;
191 }
192
199 public function getCreatedAt()
200 {
201 if (is_null($this->createdAt)) {
203 $data = $this->raw(self::FIELD_CREATED_AT);
204 if (is_null($data)) {
205 return null;
206 }
207 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
208 if (false === $data) {
209 return null;
210 }
211 $this->createdAt = $data;
212 }
213
214 return $this->createdAt;
215 }
216
223 public function getLastModifiedAt()
224 {
225 if (is_null($this->lastModifiedAt)) {
227 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
228 if (is_null($data)) {
229 return null;
230 }
231 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
232 if (false === $data) {
233 return null;
234 }
235 $this->lastModifiedAt = $data;
236 }
237
239 }
240
247 public function getLastModifiedBy()
248 {
249 if (is_null($this->lastModifiedBy)) {
251 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
252 if (is_null($data)) {
253 return null;
254 }
255
256 $this->lastModifiedBy = LastModifiedByModel::of($data);
257 }
258
260 }
261
268 public function getCreatedBy()
269 {
270 if (is_null($this->createdBy)) {
272 $data = $this->raw(self::FIELD_CREATED_BY);
273 if (is_null($data)) {
274 return null;
275 }
276
277 $this->createdBy = CreatedByModel::of($data);
278 }
279
280 return $this->createdBy;
281 }
282
289 public function getKey()
290 {
291 if (is_null($this->key)) {
293 $data = $this->raw(self::FIELD_KEY);
294 if (is_null($data)) {
295 return null;
296 }
297 $this->key = (string) $data;
298 }
299
300 return $this->key;
301 }
302
309 public function getSku()
310 {
311 if (is_null($this->sku)) {
313 $data = $this->raw(self::FIELD_SKU);
314 if (is_null($data)) {
315 return null;
316 }
317 $this->sku = (string) $data;
318 }
319
320 return $this->sku;
321 }
322
329 public function getSupplyChannel()
330 {
331 if (is_null($this->supplyChannel)) {
333 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
334 if (is_null($data)) {
335 return null;
336 }
337
338 $this->supplyChannel = ChannelReferenceModel::of($data);
339 }
340
342 }
343
350 public function getQuantityOnStock()
351 {
352 if (is_null($this->quantityOnStock)) {
354 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
355 if (is_null($data)) {
356 return null;
357 }
358 $this->quantityOnStock = (int) $data;
359 }
360
362 }
363
370 public function getAvailableQuantity()
371 {
372 if (is_null($this->availableQuantity)) {
374 $data = $this->raw(self::FIELD_AVAILABLE_QUANTITY);
375 if (is_null($data)) {
376 return null;
377 }
378 $this->availableQuantity = (int) $data;
379 }
380
382 }
383
390 public function getRestockableInDays()
391 {
392 if (is_null($this->restockableInDays)) {
394 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
395 if (is_null($data)) {
396 return null;
397 }
398 $this->restockableInDays = (int) $data;
399 }
400
402 }
403
410 public function getExpectedDelivery()
411 {
412 if (is_null($this->expectedDelivery)) {
414 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
415 if (is_null($data)) {
416 return null;
417 }
418 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
419 if (false === $data) {
420 return null;
421 }
422 $this->expectedDelivery = $data;
423 }
424
426 }
427
434 public function getCustom()
435 {
436 if (is_null($this->custom)) {
438 $data = $this->raw(self::FIELD_CUSTOM);
439 if (is_null($data)) {
440 return null;
441 }
442
443 $this->custom = CustomFieldsModel::of($data);
444 }
445
446 return $this->custom;
447 }
448
449
453 public function setId(?string $id): void
454 {
455 $this->id = $id;
456 }
457
461 public function setVersion(?int $version): void
462 {
463 $this->version = $version;
464 }
465
469 public function setCreatedAt(?DateTimeImmutable $createdAt): void
470 {
471 $this->createdAt = $createdAt;
472 }
473
477 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
478 {
479 $this->lastModifiedAt = $lastModifiedAt;
480 }
481
486 {
487 $this->lastModifiedBy = $lastModifiedBy;
488 }
489
493 public function setCreatedBy(?CreatedBy $createdBy): void
494 {
495 $this->createdBy = $createdBy;
496 }
497
501 public function setKey(?string $key): void
502 {
503 $this->key = $key;
504 }
505
509 public function setSku(?string $sku): void
510 {
511 $this->sku = $sku;
512 }
513
518 {
519 $this->supplyChannel = $supplyChannel;
520 }
521
525 public function setQuantityOnStock(?int $quantityOnStock): void
526 {
527 $this->quantityOnStock = $quantityOnStock;
528 }
529
533 public function setAvailableQuantity(?int $availableQuantity): void
534 {
535 $this->availableQuantity = $availableQuantity;
536 }
537
541 public function setRestockableInDays(?int $restockableInDays): void
542 {
543 $this->restockableInDays = $restockableInDays;
544 }
545
549 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
550 {
551 $this->expectedDelivery = $expectedDelivery;
552 }
553
557 public function setCustom(?CustomFields $custom): void
558 {
559 $this->custom = $custom;
560 }
561
562
563 #[\ReturnTypeWillChange]
564 public function jsonSerialize()
565 {
566 $data = $this->toArray();
567 if (isset($data[InventoryEntry::FIELD_CREATED_AT]) && $data[InventoryEntry::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
568 $data[InventoryEntry::FIELD_CREATED_AT] = $data[InventoryEntry::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
569 }
570
571 if (isset($data[InventoryEntry::FIELD_LAST_MODIFIED_AT]) && $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
572 $data[InventoryEntry::FIELD_LAST_MODIFIED_AT] = $data[InventoryEntry::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
573 }
574
575 if (isset($data[InventoryEntry::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
576 $data[InventoryEntry::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntry::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
577 }
578 return (object) $data;
579 }
580}
$key
$supplyChannel
getVersion()
$createdBy
$lastModifiedBy
setCreatedAt(?DateTimeImmutable $createdAt)
jsonSerialize()
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
getLastModifiedAt()
getSupplyChannel()
$lastModifiedAt
getSku()
getKey()
setKey(?string $key)
getAvailableQuantity()
getLastModifiedBy()
getCreatedAt()
getCreatedBy()
$restockableInDays
$version
getRestockableInDays()
setSku(?string $sku)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
$custom
setQuantityOnStock(?int $quantityOnStock)
$quantityOnStock
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
$availableQuantity
$sku
setCustom(?CustomFields $custom)
setCreatedBy(?CreatedBy $createdBy)
setId(?string $id)
$expectedDelivery
getExpectedDelivery()
setSupplyChannel(?ChannelReference $supplyChannel)
setVersion(?int $version)
$id
setRestockableInDays(?int $restockableInDays)
getId()
getCustom()
$createdAt
setAvailableQuantity(?int $availableQuantity)
__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 $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?CustomFields $custom=null)
getQuantityOnStock()
const FIELD_EXPECTED_DELIVERY