commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
InventoryImportModel.php
1<?php
2
3declare(strict_types=1);
10
21use DateTimeImmutable;
22use stdClass;
23
28{
33 protected $key;
34
39 protected $sku;
40
46
52
58
64
69 protected $supplyChannel;
70
75 protected $custom;
76
77
81 public function __construct(
82 ?string $key = null,
83 ?string $sku = null,
84 ?int $quantityOnStock = null,
85 ?int $restockableInDays = null,
86 ?DateTimeImmutable $expectedDelivery = null,
89 ?Custom $custom = null
90 ) {
91 $this->key = $key;
92 $this->sku = $sku;
93 $this->quantityOnStock = $quantityOnStock;
94 $this->restockableInDays = $restockableInDays;
95 $this->expectedDelivery = $expectedDelivery;
96 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
97 $this->supplyChannel = $supplyChannel;
98 $this->custom = $custom;
99 }
100
107 public function getKey()
108 {
109 if (is_null($this->key)) {
111 $data = $this->raw(self::FIELD_KEY);
112 if (is_null($data)) {
113 return null;
114 }
115 $this->key = (string) $data;
116 }
117
118 return $this->key;
119 }
120
127 public function getSku()
128 {
129 if (is_null($this->sku)) {
131 $data = $this->raw(self::FIELD_SKU);
132 if (is_null($data)) {
133 return null;
134 }
135 $this->sku = (string) $data;
136 }
137
138 return $this->sku;
139 }
140
147 public function getQuantityOnStock()
148 {
149 if (is_null($this->quantityOnStock)) {
151 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
152 if (is_null($data)) {
153 return null;
154 }
155 $this->quantityOnStock = (int) $data;
156 }
157
159 }
160
167 public function getRestockableInDays()
168 {
169 if (is_null($this->restockableInDays)) {
171 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
172 if (is_null($data)) {
173 return null;
174 }
175 $this->restockableInDays = (int) $data;
176 }
177
179 }
180
187 public function getExpectedDelivery()
188 {
189 if (is_null($this->expectedDelivery)) {
191 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
192 if (is_null($data)) {
193 return null;
194 }
195 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
196 if (false === $data) {
197 return null;
198 }
199 $this->expectedDelivery = $data;
200 }
201
203 }
204
212 {
213 if (is_null($this->reservationExpirationInMinutes)) {
215 $data = $this->raw(self::FIELD_RESERVATION_EXPIRATION_IN_MINUTES);
216 if (is_null($data)) {
217 return null;
218 }
219 $this->reservationExpirationInMinutes = (int) $data;
220 }
221
223 }
224
231 public function getSupplyChannel()
232 {
233 if (is_null($this->supplyChannel)) {
235 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
236 if (is_null($data)) {
237 return null;
238 }
239
240 $this->supplyChannel = ChannelKeyReferenceModel::of($data);
241 }
242
244 }
245
252 public function getCustom()
253 {
254 if (is_null($this->custom)) {
256 $data = $this->raw(self::FIELD_CUSTOM);
257 if (is_null($data)) {
258 return null;
259 }
260
261 $this->custom = CustomModel::of($data);
262 }
263
264 return $this->custom;
265 }
266
267
271 public function setKey(?string $key): void
272 {
273 $this->key = $key;
274 }
275
279 public function setSku(?string $sku): void
280 {
281 $this->sku = $sku;
282 }
283
287 public function setQuantityOnStock(?int $quantityOnStock): void
288 {
289 $this->quantityOnStock = $quantityOnStock;
290 }
291
295 public function setRestockableInDays(?int $restockableInDays): void
296 {
297 $this->restockableInDays = $restockableInDays;
298 }
299
303 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
304 {
305 $this->expectedDelivery = $expectedDelivery;
306 }
307
312 {
313 $this->reservationExpirationInMinutes = $reservationExpirationInMinutes;
314 }
315
320 {
321 $this->supplyChannel = $supplyChannel;
322 }
323
327 public function setCustom(?Custom $custom): void
328 {
329 $this->custom = $custom;
330 }
331
332
333 #[\ReturnTypeWillChange]
334 public function jsonSerialize()
335 {
336 $data = $this->toArray();
337 if (isset($data[InventoryImport::FIELD_EXPECTED_DELIVERY]) && $data[InventoryImport::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
338 $data[InventoryImport::FIELD_EXPECTED_DELIVERY] = $data[InventoryImport::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
339 }
340 return (object) $data;
341 }
342}
setReservationExpirationInMinutes(?int $reservationExpirationInMinutes)
__construct(?string $key=null, ?string $sku=null, ?int $quantityOnStock=null, ?int $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?int $reservationExpirationInMinutes=null, ?ChannelKeyReference $supplyChannel=null, ?Custom $custom=null)