commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MyLineItemDraftModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
30{
35 protected $key;
36
41 protected $productId;
42
47 protected $variantId;
48
53 protected $sku;
54
59 protected $quantity;
60
65 protected $addedAt;
66
71 protected $supplyChannel;
72
78
84
89 protected $recurrenceInfo;
90
95 protected $custom;
96
97
101 public function __construct(
102 ?string $key = null,
103 ?string $productId = null,
104 ?int $variantId = null,
105 ?string $sku = null,
106 ?int $quantity = null,
107 ?DateTimeImmutable $addedAt = null,
113 ) {
114 $this->key = $key;
115 $this->productId = $productId;
116 $this->variantId = $variantId;
117 $this->sku = $sku;
118 $this->quantity = $quantity;
119 $this->addedAt = $addedAt;
120 $this->supplyChannel = $supplyChannel;
121 $this->distributionChannel = $distributionChannel;
122 $this->shippingDetails = $shippingDetails;
123 $this->recurrenceInfo = $recurrenceInfo;
124 $this->custom = $custom;
125 }
126
133 public function getKey()
134 {
135 if (is_null($this->key)) {
137 $data = $this->raw(self::FIELD_KEY);
138 if (is_null($data)) {
139 return null;
140 }
141 $this->key = (string) $data;
142 }
143
144 return $this->key;
145 }
146
153 public function getProductId()
154 {
155 if (is_null($this->productId)) {
157 $data = $this->raw(self::FIELD_PRODUCT_ID);
158 if (is_null($data)) {
159 return null;
160 }
161 $this->productId = (string) $data;
162 }
163
164 return $this->productId;
165 }
166
174 public function getVariantId()
175 {
176 if (is_null($this->variantId)) {
178 $data = $this->raw(self::FIELD_VARIANT_ID);
179 if (is_null($data)) {
180 return null;
181 }
182 $this->variantId = (int) $data;
183 }
184
185 return $this->variantId;
186 }
187
194 public function getSku()
195 {
196 if (is_null($this->sku)) {
198 $data = $this->raw(self::FIELD_SKU);
199 if (is_null($data)) {
200 return null;
201 }
202 $this->sku = (string) $data;
203 }
204
205 return $this->sku;
206 }
207
214 public function getQuantity()
215 {
216 if (is_null($this->quantity)) {
218 $data = $this->raw(self::FIELD_QUANTITY);
219 if (is_null($data)) {
220 return null;
221 }
222 $this->quantity = (int) $data;
223 }
224
225 return $this->quantity;
226 }
227
236 public function getAddedAt()
237 {
238 if (is_null($this->addedAt)) {
240 $data = $this->raw(self::FIELD_ADDED_AT);
241 if (is_null($data)) {
242 return null;
243 }
244 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
245 if (false === $data) {
246 return null;
247 }
248 $this->addedAt = $data;
249 }
250
251 return $this->addedAt;
252 }
253
261 public function getSupplyChannel()
262 {
263 if (is_null($this->supplyChannel)) {
265 $data = $this->raw(self::FIELD_SUPPLY_CHANNEL);
266 if (is_null($data)) {
267 return null;
268 }
269
270 $this->supplyChannel = ChannelResourceIdentifierModel::of($data);
271 }
272
274 }
275
285 public function getDistributionChannel()
286 {
287 if (is_null($this->distributionChannel)) {
289 $data = $this->raw(self::FIELD_DISTRIBUTION_CHANNEL);
290 if (is_null($data)) {
291 return null;
292 }
293
294 $this->distributionChannel = ChannelResourceIdentifierModel::of($data);
295 }
296
298 }
299
306 public function getShippingDetails()
307 {
308 if (is_null($this->shippingDetails)) {
310 $data = $this->raw(self::FIELD_SHIPPING_DETAILS);
311 if (is_null($data)) {
312 return null;
313 }
314
315 $this->shippingDetails = ItemShippingDetailsDraftModel::of($data);
316 }
317
319 }
320
327 public function getRecurrenceInfo()
328 {
329 if (is_null($this->recurrenceInfo)) {
331 $data = $this->raw(self::FIELD_RECURRENCE_INFO);
332 if (is_null($data)) {
333 return null;
334 }
335
336 $this->recurrenceInfo = LineItemRecurrenceInfoDraftModel::of($data);
337 }
338
340 }
341
348 public function getCustom()
349 {
350 if (is_null($this->custom)) {
352 $data = $this->raw(self::FIELD_CUSTOM);
353 if (is_null($data)) {
354 return null;
355 }
356
357 $this->custom = CustomFieldsDraftModel::of($data);
358 }
359
360 return $this->custom;
361 }
362
363
367 public function setKey(?string $key): void
368 {
369 $this->key = $key;
370 }
371
375 public function setProductId(?string $productId): void
376 {
377 $this->productId = $productId;
378 }
379
383 public function setVariantId(?int $variantId): void
384 {
385 $this->variantId = $variantId;
386 }
387
391 public function setSku(?string $sku): void
392 {
393 $this->sku = $sku;
394 }
395
399 public function setQuantity(?int $quantity): void
400 {
401 $this->quantity = $quantity;
402 }
403
407 public function setAddedAt(?DateTimeImmutable $addedAt): void
408 {
409 $this->addedAt = $addedAt;
410 }
411
416 {
417 $this->supplyChannel = $supplyChannel;
418 }
419
424 {
425 $this->distributionChannel = $distributionChannel;
426 }
427
432 {
433 $this->shippingDetails = $shippingDetails;
434 }
435
440 {
441 $this->recurrenceInfo = $recurrenceInfo;
442 }
443
447 public function setCustom(?CustomFieldsDraft $custom): void
448 {
449 $this->custom = $custom;
450 }
451
452
453 #[\ReturnTypeWillChange]
454 public function jsonSerialize()
455 {
456 $data = $this->toArray();
457 if (isset($data[MyLineItemDraft::FIELD_ADDED_AT]) && $data[MyLineItemDraft::FIELD_ADDED_AT] instanceof \DateTimeImmutable) {
458 $data[MyLineItemDraft::FIELD_ADDED_AT] = $data[MyLineItemDraft::FIELD_ADDED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
459 }
460 return (object) $data;
461 }
462}
__construct(?string $key=null, ?string $productId=null, ?int $variantId=null, ?string $sku=null, ?int $quantity=null, ?DateTimeImmutable $addedAt=null, ?ChannelResourceIdentifier $supplyChannel=null, ?ChannelResourceIdentifier $distributionChannel=null, ?ItemShippingDetailsDraft $shippingDetails=null, ?LineItemRecurrenceInfoDraft $recurrenceInfo=null, ?CustomFieldsDraft $custom=null)
setDistributionChannel(?ChannelResourceIdentifier $distributionChannel)
setShippingDetails(?ItemShippingDetailsDraft $shippingDetails)
setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo)
setSupplyChannel(?ChannelResourceIdentifier $supplyChannel)