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
79 protected $custom;
80
81
85 public function __construct(
86 ?string $sku = null,
87 ?string $key = null,
89 ?int $quantityOnStock = null,
90 ?int $minCartQuantity = null,
91 ?int $maxCartQuantity = null,
92 ?int $restockableInDays = null,
93 ?DateTimeImmutable $expectedDelivery = null,
95 ) {
96 $this->sku = $sku;
97 $this->key = $key;
98 $this->supplyChannel = $supplyChannel;
99 $this->quantityOnStock = $quantityOnStock;
100 $this->minCartQuantity = $minCartQuantity;
101 $this->maxCartQuantity = $maxCartQuantity;
102 $this->restockableInDays = $restockableInDays;
103 $this->expectedDelivery = $expectedDelivery;
104 $this->custom = $custom;
105 }
106
113 public function getSku()
114 {
115 if (is_null($this->sku)) {
117 $data = $this->raw(self::FIELD_SKU);
118 if (is_null($data)) {
119 return null;
120 }
121 $this->sku = (string) $data;
122 }
123
124 return $this->sku;
125 }
126
134 public function getKey()
135 {
136 if (is_null($this->key)) {
138 $data = $this->raw(self::FIELD_KEY);
139 if (is_null($data)) {
140 return null;
141 }
142 $this->key = (string) $data;
143 }
144
145 return $this->key;
146 }
147
154 public function getSupplyChannel()
155 {
156 if (is_null($this->supplyChannel)) {
158 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
159 if (is_null($data)) {
160 return null;
161 }
162
163 $this->supplyChannel = ChannelResourceIdentifierModel::of($data);
164 }
165
167 }
168
175 public function getQuantityOnStock()
176 {
177 if (is_null($this->quantityOnStock)) {
179 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
180 if (is_null($data)) {
181 return null;
182 }
183 $this->quantityOnStock = (int) $data;
184 }
185
187 }
188
195 public function getMinCartQuantity()
196 {
197 if (is_null($this->minCartQuantity)) {
199 $data = $this->raw(self::FIELD_MIN_CART_QUANTITY);
200 if (is_null($data)) {
201 return null;
202 }
203 $this->minCartQuantity = (int) $data;
204 }
205
207 }
208
215 public function getMaxCartQuantity()
216 {
217 if (is_null($this->maxCartQuantity)) {
219 $data = $this->raw(self::FIELD_MAX_CART_QUANTITY);
220 if (is_null($data)) {
221 return null;
222 }
223 $this->maxCartQuantity = (int) $data;
224 }
225
227 }
228
235 public function getRestockableInDays()
236 {
237 if (is_null($this->restockableInDays)) {
239 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
240 if (is_null($data)) {
241 return null;
242 }
243 $this->restockableInDays = (int) $data;
244 }
245
247 }
248
255 public function getExpectedDelivery()
256 {
257 if (is_null($this->expectedDelivery)) {
259 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
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->expectedDelivery = $data;
268 }
269
271 }
272
279 public function getCustom()
280 {
281 if (is_null($this->custom)) {
283 $data = $this->raw(self::FIELD_CUSTOM);
284 if (is_null($data)) {
285 return null;
286 }
287
288 $this->custom = CustomFieldsDraftModel::of($data);
289 }
290
291 return $this->custom;
292 }
293
294
298 public function setSku(?string $sku): void
299 {
300 $this->sku = $sku;
301 }
302
306 public function setKey(?string $key): void
307 {
308 $this->key = $key;
309 }
310
315 {
316 $this->supplyChannel = $supplyChannel;
317 }
318
322 public function setQuantityOnStock(?int $quantityOnStock): void
323 {
324 $this->quantityOnStock = $quantityOnStock;
325 }
326
330 public function setMinCartQuantity(?int $minCartQuantity): void
331 {
332 $this->minCartQuantity = $minCartQuantity;
333 }
334
338 public function setMaxCartQuantity(?int $maxCartQuantity): void
339 {
340 $this->maxCartQuantity = $maxCartQuantity;
341 }
342
346 public function setRestockableInDays(?int $restockableInDays): void
347 {
348 $this->restockableInDays = $restockableInDays;
349 }
350
354 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
355 {
356 $this->expectedDelivery = $expectedDelivery;
357 }
358
362 public function setCustom(?CustomFieldsDraft $custom): void
363 {
364 $this->custom = $custom;
365 }
366
367
368 #[\ReturnTypeWillChange]
369 public function jsonSerialize()
370 {
371 $data = $this->toArray();
372 if (isset($data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
373 $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
374 }
375 return (object) $data;
376 }
377}
setQuantityOnStock(?int $quantityOnStock)
setSku(?string $sku)
$supplyChannel
$quantityOnStock
$minCartQuantity
$maxCartQuantity
setSupplyChannel(?ChannelResourceIdentifier $supplyChannel)
getRestockableInDays()
getKey()
$key
setKey(?string $key)
jsonSerialize()
getMaxCartQuantity()
getQuantityOnStock()
setMinCartQuantity(?int $minCartQuantity)
$restockableInDays
getCustom()
$expectedDelivery
getExpectedDelivery()
getMinCartQuantity()
setRestockableInDays(?int $restockableInDays)
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, ?CustomFieldsDraft $custom=null)
$sku
const FIELD_EXPECTED_DELIVERY