commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StoreCreatedMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
28 use DateTimeImmutable;
29 use stdClass;
30 
35 {
36  public const DISCRIMINATOR_VALUE = 'StoreCreated';
41  protected $id;
42 
47  protected $version;
48 
53  protected $createdAt;
54 
59  protected $lastModifiedAt;
60 
65  protected $lastModifiedBy;
66 
71  protected $createdBy;
72 
77  protected $sequenceNumber;
78 
83  protected $resource;
84 
89  protected $resourceVersion;
90 
95  protected $type;
96 
102 
107  protected $name;
108 
113  protected $languages;
114 
119  protected $countries;
120 
126 
131  protected $supplyChannels;
132 
138 
143  protected $custom;
144 
145 
149  public function __construct(
150  ?string $id = null,
151  ?int $version = null,
152  ?DateTimeImmutable $createdAt = null,
153  ?DateTimeImmutable $lastModifiedAt = null,
155  ?CreatedBy $createdBy = null,
156  ?int $sequenceNumber = null,
157  ?Reference $resource = null,
158  ?int $resourceVersion = null,
160  ?LocalizedString $name = null,
161  ?array $languages = null,
166  ?CustomFields $custom = null,
167  ?string $type = null
168  ) {
169  $this->id = $id;
170  $this->version = $version;
171  $this->createdAt = $createdAt;
172  $this->lastModifiedAt = $lastModifiedAt;
173  $this->lastModifiedBy = $lastModifiedBy;
174  $this->createdBy = $createdBy;
175  $this->sequenceNumber = $sequenceNumber;
176  $this->resource = $resource;
177  $this->resourceVersion = $resourceVersion;
178  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
179  $this->name = $name;
180  $this->languages = $languages;
181  $this->countries = $countries;
182  $this->distributionChannels = $distributionChannels;
183  $this->supplyChannels = $supplyChannels;
184  $this->productSelections = $productSelections;
185  $this->custom = $custom;
186  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
187  }
188 
195  public function getId()
196  {
197  if (is_null($this->id)) {
199  $data = $this->raw(self::FIELD_ID);
200  if (is_null($data)) {
201  return null;
202  }
203  $this->id = (string) $data;
204  }
205 
206  return $this->id;
207  }
208 
215  public function getVersion()
216  {
217  if (is_null($this->version)) {
219  $data = $this->raw(self::FIELD_VERSION);
220  if (is_null($data)) {
221  return null;
222  }
223  $this->version = (int) $data;
224  }
225 
226  return $this->version;
227  }
228 
235  public function getCreatedAt()
236  {
237  if (is_null($this->createdAt)) {
239  $data = $this->raw(self::FIELD_CREATED_AT);
240  if (is_null($data)) {
241  return null;
242  }
243  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
244  if (false === $data) {
245  return null;
246  }
247  $this->createdAt = $data;
248  }
249 
250  return $this->createdAt;
251  }
252 
259  public function getLastModifiedAt()
260  {
261  if (is_null($this->lastModifiedAt)) {
263  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
264  if (is_null($data)) {
265  return null;
266  }
267  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
268  if (false === $data) {
269  return null;
270  }
271  $this->lastModifiedAt = $data;
272  }
273 
274  return $this->lastModifiedAt;
275  }
276 
283  public function getLastModifiedBy()
284  {
285  if (is_null($this->lastModifiedBy)) {
287  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
288  if (is_null($data)) {
289  return null;
290  }
291 
292  $this->lastModifiedBy = LastModifiedByModel::of($data);
293  }
294 
295  return $this->lastModifiedBy;
296  }
297 
304  public function getCreatedBy()
305  {
306  if (is_null($this->createdBy)) {
308  $data = $this->raw(self::FIELD_CREATED_BY);
309  if (is_null($data)) {
310  return null;
311  }
312 
313  $this->createdBy = CreatedByModel::of($data);
314  }
315 
316  return $this->createdBy;
317  }
318 
326  public function getSequenceNumber()
327  {
328  if (is_null($this->sequenceNumber)) {
330  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
331  if (is_null($data)) {
332  return null;
333  }
334  $this->sequenceNumber = (int) $data;
335  }
336 
337  return $this->sequenceNumber;
338  }
339 
346  public function getResource()
347  {
348  if (is_null($this->resource)) {
350  $data = $this->raw(self::FIELD_RESOURCE);
351  if (is_null($data)) {
352  return null;
353  }
354  $className = ReferenceModel::resolveDiscriminatorClass($data);
355  $this->resource = $className::of($data);
356  }
357 
358  return $this->resource;
359  }
360 
367  public function getResourceVersion()
368  {
369  if (is_null($this->resourceVersion)) {
371  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
372  if (is_null($data)) {
373  return null;
374  }
375  $this->resourceVersion = (int) $data;
376  }
377 
378  return $this->resourceVersion;
379  }
380 
387  public function getType()
388  {
389  if (is_null($this->type)) {
391  $data = $this->raw(self::FIELD_TYPE);
392  if (is_null($data)) {
393  return null;
394  }
395  $this->type = (string) $data;
396  }
397 
398  return $this->type;
399  }
400 
408  {
409  if (is_null($this->resourceUserProvidedIdentifiers)) {
411  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
412  if (is_null($data)) {
413  return null;
414  }
415 
416  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
417  }
418 
420  }
421 
428  public function getName()
429  {
430  if (is_null($this->name)) {
432  $data = $this->raw(self::FIELD_NAME);
433  if (is_null($data)) {
434  return null;
435  }
436 
437  $this->name = LocalizedStringModel::of($data);
438  }
439 
440  return $this->name;
441  }
442 
449  public function getLanguages()
450  {
451  if (is_null($this->languages)) {
453  $data = $this->raw(self::FIELD_LANGUAGES);
454  if (is_null($data)) {
455  return null;
456  }
457  $this->languages = $data;
458  }
459 
460  return $this->languages;
461  }
462 
469  public function getCountries()
470  {
471  if (is_null($this->countries)) {
473  $data = $this->raw(self::FIELD_COUNTRIES);
474  if (is_null($data)) {
475  return null;
476  }
477  $this->countries = StoreCountryCollection::fromArray($data);
478  }
479 
480  return $this->countries;
481  }
482 
489  public function getDistributionChannels()
490  {
491  if (is_null($this->distributionChannels)) {
493  $data = $this->raw(self::FIELD_DISTRIBUTION_CHANNELS);
494  if (is_null($data)) {
495  return null;
496  }
497  $this->distributionChannels = ChannelReferenceCollection::fromArray($data);
498  }
499 
501  }
502 
509  public function getSupplyChannels()
510  {
511  if (is_null($this->supplyChannels)) {
513  $data = $this->raw(self::FIELD_SUPPLY_CHANNELS);
514  if (is_null($data)) {
515  return null;
516  }
517  $this->supplyChannels = ChannelReferenceCollection::fromArray($data);
518  }
519 
520  return $this->supplyChannels;
521  }
522 
529  public function getProductSelections()
530  {
531  if (is_null($this->productSelections)) {
533  $data = $this->raw(self::FIELD_PRODUCT_SELECTIONS);
534  if (is_null($data)) {
535  return null;
536  }
537  $this->productSelections = ProductSelectionSettingCollection::fromArray($data);
538  }
539 
541  }
542 
549  public function getCustom()
550  {
551  if (is_null($this->custom)) {
553  $data = $this->raw(self::FIELD_CUSTOM);
554  if (is_null($data)) {
555  return null;
556  }
557 
558  $this->custom = CustomFieldsModel::of($data);
559  }
560 
561  return $this->custom;
562  }
563 
564 
568  public function setId(?string $id): void
569  {
570  $this->id = $id;
571  }
572 
576  public function setVersion(?int $version): void
577  {
578  $this->version = $version;
579  }
580 
584  public function setCreatedAt(?DateTimeImmutable $createdAt): void
585  {
586  $this->createdAt = $createdAt;
587  }
588 
592  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
593  {
594  $this->lastModifiedAt = $lastModifiedAt;
595  }
596 
601  {
602  $this->lastModifiedBy = $lastModifiedBy;
603  }
604 
608  public function setCreatedBy(?CreatedBy $createdBy): void
609  {
610  $this->createdBy = $createdBy;
611  }
612 
616  public function setSequenceNumber(?int $sequenceNumber): void
617  {
618  $this->sequenceNumber = $sequenceNumber;
619  }
620 
624  public function setResource(?Reference $resource): void
625  {
626  $this->resource = $resource;
627  }
628 
632  public function setResourceVersion(?int $resourceVersion): void
633  {
634  $this->resourceVersion = $resourceVersion;
635  }
636 
641  {
642  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
643  }
644 
648  public function setName(?LocalizedString $name): void
649  {
650  $this->name = $name;
651  }
652 
656  public function setLanguages(?array $languages): void
657  {
658  $this->languages = $languages;
659  }
660 
665  {
666  $this->countries = $countries;
667  }
668 
673  {
674  $this->distributionChannels = $distributionChannels;
675  }
676 
681  {
682  $this->supplyChannels = $supplyChannels;
683  }
684 
689  {
690  $this->productSelections = $productSelections;
691  }
692 
696  public function setCustom(?CustomFields $custom): void
697  {
698  $this->custom = $custom;
699  }
700 
701 
702  #[\ReturnTypeWillChange]
703  public function jsonSerialize()
704  {
705  $data = $this->toArray();
706  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
707  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
708  }
709 
710  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
711  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
712  }
713  return (object) $data;
714  }
715 }
setProductSelections(?ProductSelectionSettingCollection $productSelections)
__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, ?LocalizedString $name=null, ?array $languages=null, ?StoreCountryCollection $countries=null, ?ChannelReferenceCollection $distributionChannels=null, ?ChannelReferenceCollection $supplyChannels=null, ?ProductSelectionSettingCollection $productSelections=null, ?CustomFields $custom=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
setSupplyChannels(?ChannelReferenceCollection $supplyChannels)
setDistributionChannels(?ChannelReferenceCollection $distributionChannels)
static of($data=null)
Definition: MapperMap.php:45