commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
lib
commercetools-api
src
Models
Inventory
InventoryEntryDraftModel.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Api\Models\Inventory
;
10
11
use
Commercetools\Api\Models\Channel\ChannelResourceIdentifier
;
12
use
Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel
;
13
use
Commercetools\Api\Models\Type\CustomFieldsDraft
;
14
use
Commercetools\Api\Models\Type\CustomFieldsDraftModel
;
15
use
Commercetools\Base\DateTimeImmutableCollection
;
16
use
Commercetools\Base\JsonObject
;
17
use
Commercetools\Base\JsonObjectModel
;
18
use
Commercetools\Base\MapperFactory
;
19
use DateTimeImmutable;
20
use stdClass;
21
25
final
class
InventoryEntryDraftModel
extends
JsonObjectModel
implements
InventoryEntryDraft
26
{
31
protected
$sku
;
32
37
protected
$key
;
38
43
protected
$supplyChannel
;
44
49
protected
$quantityOnStock
;
50
55
protected
$restockableInDays
;
56
61
protected
$expectedDelivery
;
62
67
protected
$custom
;
68
69
73
public
function
__construct
(
74
?
string
$sku
=
null
,
75
?
string
$key
=
null
,
76
?
ChannelResourceIdentifier
$supplyChannel
=
null
,
77
?
int
$quantityOnStock
=
null
,
78
?
int
$restockableInDays
=
null
,
79
?DateTimeImmutable
$expectedDelivery
=
null
,
80
?
CustomFieldsDraft
$custom
=
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
150
return
$this->supplyChannel
;
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
170
return
$this->quantityOnStock
;
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
190
return
$this->restockableInDays
;
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
214
return
$this->expectedDelivery
;
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
258
public
function
setSupplyChannel
(?
ChannelResourceIdentifier
$supplyChannel
): void
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
}
Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel
Definition
ChannelResourceIdentifierModel.php:23
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel
Definition
InventoryEntryDraftModel.php:26
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setQuantityOnStock
setQuantityOnStock(?int $quantityOnStock)
Definition
InventoryEntryDraftModel.php:266
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setSku
setSku(?string $sku)
Definition
InventoryEntryDraftModel.php:242
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$supplyChannel
$supplyChannel
Definition
InventoryEntryDraftModel.php:43
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$quantityOnStock
$quantityOnStock
Definition
InventoryEntryDraftModel.php:49
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setSupplyChannel
setSupplyChannel(?ChannelResourceIdentifier $supplyChannel)
Definition
InventoryEntryDraftModel.php:258
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getRestockableInDays
getRestockableInDays()
Definition
InventoryEntryDraftModel.php:179
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getKey
getKey()
Definition
InventoryEntryDraftModel.php:118
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$key
$key
Definition
InventoryEntryDraftModel.php:37
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setKey
setKey(?string $key)
Definition
InventoryEntryDraftModel.php:250
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\jsonSerialize
jsonSerialize()
Definition
InventoryEntryDraftModel.php:297
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getQuantityOnStock
getQuantityOnStock()
Definition
InventoryEntryDraftModel.php:159
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$restockableInDays
$restockableInDays
Definition
InventoryEntryDraftModel.php:55
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getCustom
getCustom()
Definition
InventoryEntryDraftModel.php:223
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$expectedDelivery
$expectedDelivery
Definition
InventoryEntryDraftModel.php:61
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getExpectedDelivery
getExpectedDelivery()
Definition
InventoryEntryDraftModel.php:199
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setRestockableInDays
setRestockableInDays(?int $restockableInDays)
Definition
InventoryEntryDraftModel.php:274
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$custom
$custom
Definition
InventoryEntryDraftModel.php:67
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getSupplyChannel
getSupplyChannel()
Definition
InventoryEntryDraftModel.php:138
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setCustom
setCustom(?CustomFieldsDraft $custom)
Definition
InventoryEntryDraftModel.php:290
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\setExpectedDelivery
setExpectedDelivery(?DateTimeImmutable $expectedDelivery)
Definition
InventoryEntryDraftModel.php:282
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\getSku
getSku()
Definition
InventoryEntryDraftModel.php:97
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\__construct
__construct(?string $sku=null, ?string $key=null, ?ChannelResourceIdentifier $supplyChannel=null, ?int $quantityOnStock=null, ?int $restockableInDays=null, ?DateTimeImmutable $expectedDelivery=null, ?CustomFieldsDraft $custom=null)
Definition
InventoryEntryDraftModel.php:73
Commercetools\Api\Models\Inventory\InventoryEntryDraftModel\$sku
$sku
Definition
InventoryEntryDraftModel.php:31
Commercetools\Api\Models\Type\CustomFieldsDraftModel
Definition
CustomFieldsDraftModel.php:21
Commercetools\Base\BaseJsonObject\raw
raw(string $field)
Definition
BaseJsonObject.php:57
Commercetools\Base\DateTimeImmutableCollection
Definition
DateTimeImmutableCollection.php:21
Commercetools\Base\JsonObjectModel
Definition
JsonObjectModel.php:15
Commercetools\Base\JsonObjectModel\toArray
toArray()
Definition
JsonObjectModel.php:32
Commercetools\Base\MapperFactory
Definition
MapperFactory.php:16
Commercetools\Api\Models\Channel\ChannelResourceIdentifier
Definition
ChannelResourceIdentifier.php:16
Commercetools\Api\Models\Inventory\InventoryEntryDraft
Definition
InventoryEntryDraft.php:18
Commercetools\Api\Models\Inventory\InventoryEntryDraft\FIELD_EXPECTED_DELIVERY
const FIELD_EXPECTED_DELIVERY
Definition
InventoryEntryDraft.php:24
Commercetools\Api\Models\Type\CustomFieldsDraft
Definition
CustomFieldsDraft.php:15
Commercetools\Base\JsonObject
Definition
JsonObject.php:15
Commercetools\Api\Models\Inventory
Definition
InventoryEntry.php:9
Generated by
1.9.8