commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantCreatedMessageModel.php
1<?php
2
3declare(strict_types=1);
10
26use DateTimeImmutable;
27use stdClass;
28
33{
34 public const DISCRIMINATOR_VALUE = 'VariantCreated';
39 protected $id;
40
45 protected $version;
46
51 protected $createdAt;
52
57 protected $lastModifiedAt;
58
63 protected $lastModifiedBy;
64
69 protected $createdBy;
70
75 protected $sequenceNumber;
76
81 protected $resource;
82
88
93 protected $type;
94
100
105 protected $product;
106
111 protected $variantId;
112
117 protected $key;
118
123 protected $sku;
124
129 protected $attributes;
130
135 protected $assets;
136
141 protected $images;
142
147 protected $publish;
148
149
153 public function __construct(
154 ?string $id = null,
155 ?int $version = null,
156 ?DateTimeImmutable $createdAt = null,
157 ?DateTimeImmutable $lastModifiedAt = null,
159 ?CreatedBy $createdBy = null,
160 ?int $sequenceNumber = null,
161 ?Reference $resource = null,
162 ?int $resourceVersion = null,
165 ?int $variantId = null,
166 ?string $key = null,
167 ?string $sku = null,
169 ?AssetCollection $assets = null,
170 ?ImageCollection $images = null,
171 ?bool $publish = null,
172 ?string $type = null
173 ) {
174 $this->id = $id;
175 $this->version = $version;
176 $this->createdAt = $createdAt;
177 $this->lastModifiedAt = $lastModifiedAt;
178 $this->lastModifiedBy = $lastModifiedBy;
179 $this->createdBy = $createdBy;
180 $this->sequenceNumber = $sequenceNumber;
181 $this->resource = $resource;
182 $this->resourceVersion = $resourceVersion;
183 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
184 $this->product = $product;
185 $this->variantId = $variantId;
186 $this->key = $key;
187 $this->sku = $sku;
188 $this->attributes = $attributes;
189 $this->assets = $assets;
190 $this->images = $images;
191 $this->publish = $publish;
192 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
193 }
194
201 public function getId()
202 {
203 if (is_null($this->id)) {
205 $data = $this->raw(self::FIELD_ID);
206 if (is_null($data)) {
207 return null;
208 }
209 $this->id = (string) $data;
210 }
211
212 return $this->id;
213 }
214
221 public function getVersion()
222 {
223 if (is_null($this->version)) {
225 $data = $this->raw(self::FIELD_VERSION);
226 if (is_null($data)) {
227 return null;
228 }
229 $this->version = (int) $data;
230 }
231
232 return $this->version;
233 }
234
241 public function getCreatedAt()
242 {
243 if (is_null($this->createdAt)) {
245 $data = $this->raw(self::FIELD_CREATED_AT);
246 if (is_null($data)) {
247 return null;
248 }
249 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
250 if (false === $data) {
251 return null;
252 }
253 $this->createdAt = $data;
254 }
255
256 return $this->createdAt;
257 }
258
265 public function getLastModifiedAt()
266 {
267 if (is_null($this->lastModifiedAt)) {
269 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
270 if (is_null($data)) {
271 return null;
272 }
273 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
274 if (false === $data) {
275 return null;
276 }
277 $this->lastModifiedAt = $data;
278 }
279
281 }
282
289 public function getLastModifiedBy()
290 {
291 if (is_null($this->lastModifiedBy)) {
293 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
294 if (is_null($data)) {
295 return null;
296 }
297
298 $this->lastModifiedBy = LastModifiedByModel::of($data);
299 }
300
302 }
303
310 public function getCreatedBy()
311 {
312 if (is_null($this->createdBy)) {
314 $data = $this->raw(self::FIELD_CREATED_BY);
315 if (is_null($data)) {
316 return null;
317 }
318
319 $this->createdBy = CreatedByModel::of($data);
320 }
321
322 return $this->createdBy;
323 }
324
332 public function getSequenceNumber()
333 {
334 if (is_null($this->sequenceNumber)) {
336 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
337 if (is_null($data)) {
338 return null;
339 }
340 $this->sequenceNumber = (int) $data;
341 }
342
344 }
345
352 public function getResource()
353 {
354 if (is_null($this->resource)) {
356 $data = $this->raw(self::FIELD_RESOURCE);
357 if (is_null($data)) {
358 return null;
359 }
360 $className = ReferenceModel::resolveDiscriminatorClass($data);
361 $this->resource = $className::of($data);
362 }
363
364 return $this->resource;
365 }
366
373 public function getResourceVersion()
374 {
375 if (is_null($this->resourceVersion)) {
377 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
378 if (is_null($data)) {
379 return null;
380 }
381 $this->resourceVersion = (int) $data;
382 }
383
385 }
386
393 public function getType()
394 {
395 if (is_null($this->type)) {
397 $data = $this->raw(self::FIELD_TYPE);
398 if (is_null($data)) {
399 return null;
400 }
401 $this->type = (string) $data;
402 }
403
404 return $this->type;
405 }
406
414 {
415 if (is_null($this->resourceUserProvidedIdentifiers)) {
417 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
418 if (is_null($data)) {
419 return null;
420 }
421
422 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
423 }
424
426 }
427
434 public function getProduct()
435 {
436 if (is_null($this->product)) {
438 $data = $this->raw(self::FIELD_PRODUCT);
439 if (is_null($data)) {
440 return null;
441 }
442
443 $this->product = ProductReferenceModel::of($data);
444 }
445
446 return $this->product;
447 }
448
455 public function getVariantId()
456 {
457 if (is_null($this->variantId)) {
459 $data = $this->raw(self::FIELD_VARIANT_ID);
460 if (is_null($data)) {
461 return null;
462 }
463 $this->variantId = (int) $data;
464 }
465
466 return $this->variantId;
467 }
468
475 public function getKey()
476 {
477 if (is_null($this->key)) {
479 $data = $this->raw(self::FIELD_KEY);
480 if (is_null($data)) {
481 return null;
482 }
483 $this->key = (string) $data;
484 }
485
486 return $this->key;
487 }
488
495 public function getSku()
496 {
497 if (is_null($this->sku)) {
499 $data = $this->raw(self::FIELD_SKU);
500 if (is_null($data)) {
501 return null;
502 }
503 $this->sku = (string) $data;
504 }
505
506 return $this->sku;
507 }
508
515 public function getAttributes()
516 {
517 if (is_null($this->attributes)) {
519 $data = $this->raw(self::FIELD_ATTRIBUTES);
520 if (is_null($data)) {
521 return null;
522 }
523 $this->attributes = AttributeCollection::fromArray($data);
524 }
525
526 return $this->attributes;
527 }
528
535 public function getAssets()
536 {
537 if (is_null($this->assets)) {
539 $data = $this->raw(self::FIELD_ASSETS);
540 if (is_null($data)) {
541 return null;
542 }
543 $this->assets = AssetCollection::fromArray($data);
544 }
545
546 return $this->assets;
547 }
548
555 public function getImages()
556 {
557 if (is_null($this->images)) {
559 $data = $this->raw(self::FIELD_IMAGES);
560 if (is_null($data)) {
561 return null;
562 }
563 $this->images = ImageCollection::fromArray($data);
564 }
565
566 return $this->images;
567 }
568
575 public function getPublish()
576 {
577 if (is_null($this->publish)) {
579 $data = $this->raw(self::FIELD_PUBLISH);
580 if (is_null($data)) {
581 return null;
582 }
583 $this->publish = (bool) $data;
584 }
585
586 return $this->publish;
587 }
588
589
593 public function setId(?string $id): void
594 {
595 $this->id = $id;
596 }
597
601 public function setVersion(?int $version): void
602 {
603 $this->version = $version;
604 }
605
609 public function setCreatedAt(?DateTimeImmutable $createdAt): void
610 {
611 $this->createdAt = $createdAt;
612 }
613
617 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
618 {
619 $this->lastModifiedAt = $lastModifiedAt;
620 }
621
626 {
627 $this->lastModifiedBy = $lastModifiedBy;
628 }
629
633 public function setCreatedBy(?CreatedBy $createdBy): void
634 {
635 $this->createdBy = $createdBy;
636 }
637
641 public function setSequenceNumber(?int $sequenceNumber): void
642 {
643 $this->sequenceNumber = $sequenceNumber;
644 }
645
649 public function setResource(?Reference $resource): void
650 {
651 $this->resource = $resource;
652 }
653
657 public function setResourceVersion(?int $resourceVersion): void
658 {
659 $this->resourceVersion = $resourceVersion;
660 }
661
666 {
667 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
668 }
669
673 public function setProduct(?ProductReference $product): void
674 {
675 $this->product = $product;
676 }
677
681 public function setVariantId(?int $variantId): void
682 {
683 $this->variantId = $variantId;
684 }
685
689 public function setKey(?string $key): void
690 {
691 $this->key = $key;
692 }
693
697 public function setSku(?string $sku): void
698 {
699 $this->sku = $sku;
700 }
701
706 {
707 $this->attributes = $attributes;
708 }
709
713 public function setAssets(?AssetCollection $assets): void
714 {
715 $this->assets = $assets;
716 }
717
721 public function setImages(?ImageCollection $images): void
722 {
723 $this->images = $images;
724 }
725
729 public function setPublish(?bool $publish): void
730 {
731 $this->publish = $publish;
732 }
733
734
735 #[\ReturnTypeWillChange]
736 public function jsonSerialize()
737 {
738 $data = $this->toArray();
739 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
740 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
741 }
742
743 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
744 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
745 }
746 return (object) $data;
747 }
748}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?int $sequenceNumber=null, ?Reference $resource=null, ?int $resourceVersion=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?ProductReference $product=null, ?int $variantId=null, ?string $key=null, ?string $sku=null, ?AttributeCollection $attributes=null, ?AssetCollection $assets=null, ?ImageCollection $images=null, ?bool $publish=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)