commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductPublishedMessageModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
30{
31 public const DISCRIMINATOR_VALUE = 'ProductPublished';
36 protected $id;
37
42 protected $version;
43
48 protected $createdAt;
49
54 protected $lastModifiedAt;
55
60 protected $lastModifiedBy;
61
66 protected $createdBy;
67
72 protected $sequenceNumber;
73
78 protected $resource;
79
85
90 protected $type;
91
97
103
109
114 protected $scope;
115
116
120 public function __construct(
121 ?string $id = null,
122 ?int $version = null,
123 ?DateTimeImmutable $createdAt = null,
124 ?DateTimeImmutable $lastModifiedAt = null,
126 ?CreatedBy $createdBy = null,
127 ?int $sequenceNumber = null,
128 ?Reference $resource = null,
129 ?int $resourceVersion = null,
131 ?array $removedImageUrls = null,
133 ?string $scope = null,
134 ?string $type = null
135 ) {
136 $this->id = $id;
137 $this->version = $version;
138 $this->createdAt = $createdAt;
139 $this->lastModifiedAt = $lastModifiedAt;
140 $this->lastModifiedBy = $lastModifiedBy;
141 $this->createdBy = $createdBy;
142 $this->sequenceNumber = $sequenceNumber;
143 $this->resource = $resource;
144 $this->resourceVersion = $resourceVersion;
145 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
146 $this->removedImageUrls = $removedImageUrls;
147 $this->productProjection = $productProjection;
148 $this->scope = $scope;
149 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
150 }
151
158 public function getId()
159 {
160 if (is_null($this->id)) {
162 $data = $this->raw(self::FIELD_ID);
163 if (is_null($data)) {
164 return null;
165 }
166 $this->id = (string) $data;
167 }
168
169 return $this->id;
170 }
171
178 public function getVersion()
179 {
180 if (is_null($this->version)) {
182 $data = $this->raw(self::FIELD_VERSION);
183 if (is_null($data)) {
184 return null;
185 }
186 $this->version = (int) $data;
187 }
188
189 return $this->version;
190 }
191
198 public function getCreatedAt()
199 {
200 if (is_null($this->createdAt)) {
202 $data = $this->raw(self::FIELD_CREATED_AT);
203 if (is_null($data)) {
204 return null;
205 }
206 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
207 if (false === $data) {
208 return null;
209 }
210 $this->createdAt = $data;
211 }
212
213 return $this->createdAt;
214 }
215
222 public function getLastModifiedAt()
223 {
224 if (is_null($this->lastModifiedAt)) {
226 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
227 if (is_null($data)) {
228 return null;
229 }
230 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
231 if (false === $data) {
232 return null;
233 }
234 $this->lastModifiedAt = $data;
235 }
236
238 }
239
246 public function getLastModifiedBy()
247 {
248 if (is_null($this->lastModifiedBy)) {
250 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
251 if (is_null($data)) {
252 return null;
253 }
254
255 $this->lastModifiedBy = LastModifiedByModel::of($data);
256 }
257
259 }
260
267 public function getCreatedBy()
268 {
269 if (is_null($this->createdBy)) {
271 $data = $this->raw(self::FIELD_CREATED_BY);
272 if (is_null($data)) {
273 return null;
274 }
275
276 $this->createdBy = CreatedByModel::of($data);
277 }
278
279 return $this->createdBy;
280 }
281
289 public function getSequenceNumber()
290 {
291 if (is_null($this->sequenceNumber)) {
293 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
294 if (is_null($data)) {
295 return null;
296 }
297 $this->sequenceNumber = (int) $data;
298 }
299
301 }
302
309 public function getResource()
310 {
311 if (is_null($this->resource)) {
313 $data = $this->raw(self::FIELD_RESOURCE);
314 if (is_null($data)) {
315 return null;
316 }
317 $className = ReferenceModel::resolveDiscriminatorClass($data);
318 $this->resource = $className::of($data);
319 }
320
321 return $this->resource;
322 }
323
330 public function getResourceVersion()
331 {
332 if (is_null($this->resourceVersion)) {
334 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
335 if (is_null($data)) {
336 return null;
337 }
338 $this->resourceVersion = (int) $data;
339 }
340
342 }
343
350 public function getType()
351 {
352 if (is_null($this->type)) {
354 $data = $this->raw(self::FIELD_TYPE);
355 if (is_null($data)) {
356 return null;
357 }
358 $this->type = (string) $data;
359 }
360
361 return $this->type;
362 }
363
371 {
372 if (is_null($this->resourceUserProvidedIdentifiers)) {
374 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
375 if (is_null($data)) {
376 return null;
377 }
378
379 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
380 }
381
383 }
384
391 public function getRemovedImageUrls()
392 {
393 if (is_null($this->removedImageUrls)) {
395 $data = $this->raw(self::FIELD_REMOVED_IMAGE_URLS);
396 if (is_null($data)) {
397 return null;
398 }
399 $this->removedImageUrls = $data;
400 }
401
403 }
404
411 public function getProductProjection()
412 {
413 if (is_null($this->productProjection)) {
415 $data = $this->raw(self::FIELD_PRODUCT_PROJECTION);
416 if (is_null($data)) {
417 return null;
418 }
419
420 $this->productProjection = ProductProjectionModel::of($data);
421 }
422
424 }
425
432 public function getScope()
433 {
434 if (is_null($this->scope)) {
436 $data = $this->raw(self::FIELD_SCOPE);
437 if (is_null($data)) {
438 return null;
439 }
440 $this->scope = (string) $data;
441 }
442
443 return $this->scope;
444 }
445
446
450 public function setId(?string $id): void
451 {
452 $this->id = $id;
453 }
454
458 public function setVersion(?int $version): void
459 {
460 $this->version = $version;
461 }
462
466 public function setCreatedAt(?DateTimeImmutable $createdAt): void
467 {
468 $this->createdAt = $createdAt;
469 }
470
474 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
475 {
476 $this->lastModifiedAt = $lastModifiedAt;
477 }
478
483 {
484 $this->lastModifiedBy = $lastModifiedBy;
485 }
486
490 public function setCreatedBy(?CreatedBy $createdBy): void
491 {
492 $this->createdBy = $createdBy;
493 }
494
498 public function setSequenceNumber(?int $sequenceNumber): void
499 {
500 $this->sequenceNumber = $sequenceNumber;
501 }
502
506 public function setResource(?Reference $resource): void
507 {
508 $this->resource = $resource;
509 }
510
514 public function setResourceVersion(?int $resourceVersion): void
515 {
516 $this->resourceVersion = $resourceVersion;
517 }
518
523 {
524 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
525 }
526
530 public function setRemovedImageUrls(?array $removedImageUrls): void
531 {
532 $this->removedImageUrls = $removedImageUrls;
533 }
534
539 {
540 $this->productProjection = $productProjection;
541 }
542
546 public function setScope(?string $scope): void
547 {
548 $this->scope = $scope;
549 }
550
551
552 #[\ReturnTypeWillChange]
553 public function jsonSerialize()
554 {
555 $data = $this->toArray();
556 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
557 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
558 }
559
560 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
561 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
562 }
563 return (object) $data;
564 }
565}
__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, ?array $removedImageUrls=null, ?ProductProjection $productProjection=null, ?string $scope=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)