commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
InventoryEntryDraftModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
31 protected $sku;
32
37 protected $key;
38
43 protected $supplyChannel;
44
50
56
62
68
74
80
85 protected $stockLevels;
86
91 protected $custom;
92
93
97 public function __construct(
98 ?string $sku = null,
99 ?string $key = null,
101 ?int $quantityOnStock = null,
102 ?int $minCartQuantity = null,
103 ?int $maxCartQuantity = null,
104 ?int $restockableInDays = null,
105 ?DateTimeImmutable $expectedDelivery = null,
109 ) {
110 $this->sku = $sku;
111 $this->key = $key;
112 $this->supplyChannel = $supplyChannel;
113 $this->quantityOnStock = $quantityOnStock;
114 $this->minCartQuantity = $minCartQuantity;
115 $this->maxCartQuantity = $maxCartQuantity;
116 $this->restockableInDays = $restockableInDays;
117 $this->expectedDelivery = $expectedDelivery;
118 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
119 $this->stockLevels = $stockLevels;
120 $this->custom = $custom;
121 }
122
129 public function getSku()
130 {
131 if (is_null($this->sku)) {
133 $data = $this->raw(self::FIELD_SKU);
134 if (is_null($data)) {
135 return null;
136 }
137 $this->sku = (string) $data;
138 }
139
140 return $this->sku;
141 }
142
150 public function getKey()
151 {
152 if (is_null($this->key)) {
154 $data = $this->raw(self::FIELD_KEY);
155 if (is_null($data)) {
156 return null;
157 }
158 $this->key = (string) $data;
159 }
160
161 return $this->key;
162 }
163
170 public function getSupplyChannel()
171 {
172 if (is_null($this->supplyChannel)) {
174 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
175 if (is_null($data)) {
176 return null;
177 }
178
179 $this->supplyChannel = ChannelResourceIdentifierModel::of($data);
180 }
181
183 }
184
191 public function getQuantityOnStock()
192 {
193 if (is_null($this->quantityOnStock)) {
195 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
196 if (is_null($data)) {
197 return null;
198 }
199 $this->quantityOnStock = (int) $data;
200 }
201
203 }
204
211 public function getMinCartQuantity()
212 {
213 if (is_null($this->minCartQuantity)) {
215 $data = $this->raw(self::FIELD_MIN_CART_QUANTITY);
216 if (is_null($data)) {
217 return null;
218 }
219 $this->minCartQuantity = (int) $data;
220 }
221
223 }
224
231 public function getMaxCartQuantity()
232 {
233 if (is_null($this->maxCartQuantity)) {
235 $data = $this->raw(self::FIELD_MAX_CART_QUANTITY);
236 if (is_null($data)) {
237 return null;
238 }
239 $this->maxCartQuantity = (int) $data;
240 }
241
243 }
244
251 public function getRestockableInDays()
252 {
253 if (is_null($this->restockableInDays)) {
255 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
256 if (is_null($data)) {
257 return null;
258 }
259 $this->restockableInDays = (int) $data;
260 }
261
263 }
264
271 public function getExpectedDelivery()
272 {
273 if (is_null($this->expectedDelivery)) {
275 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
276 if (is_null($data)) {
277 return null;
278 }
279 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
280 if (false === $data) {
281 return null;
282 }
283 $this->expectedDelivery = $data;
284 }
285
287 }
288
300 {
301 if (is_null($this->reservationExpirationInMinutes)) {
303 $data = $this->raw(self::FIELD_RESERVATION_EXPIRATION_IN_MINUTES);
304 if (is_null($data)) {
305 return null;
306 }
307 $this->reservationExpirationInMinutes = (int) $data;
308 }
309
311 }
312
319 public function getStockLevels()
320 {
321 if (is_null($this->stockLevels)) {
323 $data = $this->raw(self::FIELD_STOCK_LEVELS);
324 if (is_null($data)) {
325 return null;
326 }
327
328 $this->stockLevels = InventoryEntryStockLevelsModel::of($data);
329 }
330
331 return $this->stockLevels;
332 }
333
340 public function getCustom()
341 {
342 if (is_null($this->custom)) {
344 $data = $this->raw(self::FIELD_CUSTOM);
345 if (is_null($data)) {
346 return null;
347 }
348
349 $this->custom = CustomFieldsDraftModel::of($data);
350 }
351
352 return $this->custom;
353 }
354
355
359 public function setSku(?string $sku): void
360 {
361 $this->sku = $sku;
362 }
363
367 public function setKey(?string $key): void
368 {
369 $this->key = $key;
370 }
371
376 {
377 $this->supplyChannel = $supplyChannel;
378 }
379
383 public function setQuantityOnStock(?int $quantityOnStock): void
384 {
385 $this->quantityOnStock = $quantityOnStock;
386 }
387
391 public function setMinCartQuantity(?int $minCartQuantity): void
392 {
393 $this->minCartQuantity = $minCartQuantity;
394 }
395
399 public function setMaxCartQuantity(?int $maxCartQuantity): void
400 {
401 $this->maxCartQuantity = $maxCartQuantity;
402 }
403
407 public function setRestockableInDays(?int $restockableInDays): void
408 {
409 $this->restockableInDays = $restockableInDays;
410 }
411
415 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
416 {
417 $this->expectedDelivery = $expectedDelivery;
418 }
419
424 {
425 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
426 }
427
432 {
433 $this->stockLevels = $stockLevels;
434 }
435
439 public function setCustom(?CustomFieldsDraft $custom): void
440 {
441 $this->custom = $custom;
442 }
443
444
445 #[\ReturnTypeWillChange]
446 public function jsonSerialize()
447 {
448 $data = $this->toArray();
449 if (isset($data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
450 $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
451 }
452 return (object) $data;
453 }
454}
setQuantityOnStock(?int $quantityOnStock)
setSku(?string $sku)
$supplyChannel
$quantityOnStock
$reservationExpirationInMinutes
$minCartQuantity
$maxCartQuantity
setSupplyChannel(?ChannelResourceIdentifier $supplyChannel)
getRestockableInDays()
getKey()
setStockLevels(?InventoryEntryStockLevels $stockLevels)
$key
setKey(?string $key)
getReservationExpirationInMinutes()
jsonSerialize()
getMaxCartQuantity()
getQuantityOnStock()
setMinCartQuantity(?int $minCartQuantity)
$restockableInDays
getCustom()
$expectedDelivery
getExpectedDelivery()
getStockLevels()
getMinCartQuantity()
setRestockableInDays(?int $restockableInDays)
$stockLevels
setMaxCartQuantity(?int $maxCartQuantity)
$custom
getSupplyChannel()
setCustom(?CustomFieldsDraft $custom)
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
getSku()
__construct(?string $sku=null, ?string $key=null, ?ChannelResourceIdentifier $supplyChannel=null, ?int $quantityOnStock=null, ?int $minCartQuantity=null, ?int $maxCartQuantity=null, ?int $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?int $reservationExpirationInMinutes=null, ?InventoryEntryStockLevels $stockLevels=null, ?CustomFieldsDraft $custom=null)
setReservationExpirationInMinutes(?int $reservationExpirationInMinutes)
$sku
const FIELD_EXPECTED_DELIVERY