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
67 protected $custom;
68
69
73 public function __construct(
74 ?string $sku = null,
75 ?string $key = null,
77 ?int $quantityOnStock = null,
78 ?int $restockableInDays = null,
79 ?DateTimeImmutable $expectedDelivery = null,
81 ) {
82 $this->sku = $sku;
83 $this->key = $key;
84 $this->supplyChannel = $supplyChannel;
85 $this->quantityOnStock = $quantityOnStock;
86 $this->restockableInDays = $restockableInDays;
87 $this->expectedDelivery = $expectedDelivery;
88 $this->custom = $custom;
89 }
90
97 public function getSku()
98 {
99 if (is_null($this->sku)) {
101 $data = $this->raw(self::FIELD_SKU);
102 if (is_null($data)) {
103 return null;
104 }
105 $this->sku = (string) $data;
106 }
107
108 return $this->sku;
109 }
110
118 public function getKey()
119 {
120 if (is_null($this->key)) {
122 $data = $this->raw(self::FIELD_KEY);
123 if (is_null($data)) {
124 return null;
125 }
126 $this->key = (string) $data;
127 }
128
129 return $this->key;
130 }
131
138 public function getSupplyChannel()
139 {
140 if (is_null($this->supplyChannel)) {
142 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
143 if (is_null($data)) {
144 return null;
145 }
146
147 $this->supplyChannel = ChannelResourceIdentifierModel::of($data);
148 }
149
151 }
152
159 public function getQuantityOnStock()
160 {
161 if (is_null($this->quantityOnStock)) {
163 $data = $this->raw(self::FIELD_QUANTITY_ON_STOCK);
164 if (is_null($data)) {
165 return null;
166 }
167 $this->quantityOnStock = (int) $data;
168 }
169
171 }
172
179 public function getRestockableInDays()
180 {
181 if (is_null($this->restockableInDays)) {
183 $data = $this->raw(self::FIELD_RESTOCKABLE_IN_DAYS);
184 if (is_null($data)) {
185 return null;
186 }
187 $this->restockableInDays = (int) $data;
188 }
189
191 }
192
199 public function getExpectedDelivery()
200 {
201 if (is_null($this->expectedDelivery)) {
203 $data = $this->raw(self::FIELD_EXPECTED_DELIVERY);
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->expectedDelivery = $data;
212 }
213
215 }
216
223 public function getCustom()
224 {
225 if (is_null($this->custom)) {
227 $data = $this->raw(self::FIELD_CUSTOM);
228 if (is_null($data)) {
229 return null;
230 }
231
232 $this->custom = CustomFieldsDraftModel::of($data);
233 }
234
235 return $this->custom;
236 }
237
238
242 public function setSku(?string $sku): void
243 {
244 $this->sku = $sku;
245 }
246
250 public function setKey(?string $key): void
251 {
252 $this->key = $key;
253 }
254
259 {
260 $this->supplyChannel = $supplyChannel;
261 }
262
266 public function setQuantityOnStock(?int $quantityOnStock): void
267 {
268 $this->quantityOnStock = $quantityOnStock;
269 }
270
274 public function setRestockableInDays(?int $restockableInDays): void
275 {
276 $this->restockableInDays = $restockableInDays;
277 }
278
282 public function setExpectedDelivery(?DateTimeImmutable $expectedDelivery): void
283 {
284 $this->expectedDelivery = $expectedDelivery;
285 }
286
290 public function setCustom(?CustomFieldsDraft $custom): void
291 {
292 $this->custom = $custom;
293 }
294
295
296 #[\ReturnTypeWillChange]
297 public function jsonSerialize()
298 {
299 $data = $this->toArray();
300 if (isset($data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]) && $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] instanceof \DateTimeImmutable) {
301 $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY] = $data[InventoryEntryDraft::FIELD_EXPECTED_DELIVERY]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
302 }
303 return (object) $data;
304 }
305}
setQuantityOnStock(?int $quantityOnStock)
setSku(?string $sku)
$supplyChannel
$quantityOnStock
setSupplyChannel(?ChannelResourceIdentifier $supplyChannel)
getRestockableInDays()
getKey()
$key
setKey(?string $key)
jsonSerialize()
getQuantityOnStock()
$restockableInDays
getCustom()
$expectedDelivery
getExpectedDelivery()
setRestockableInDays(?int $restockableInDays)
$custom
getSupplyChannel()
setCustom(?CustomFieldsDraft $custom)
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
getSku()
__construct(?string $sku=null, ?string $key=null, ?ChannelResourceIdentifier $supplyChannel=null, ?int $quantityOnStock=null, ?int $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?CustomFieldsDraft $custom=null)
$sku
const FIELD_EXPECTED_DELIVERY