commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CustomerCustomFieldChangedMessageModel.php
1<?php
2
3declare(strict_types=1);
10
21use DateTimeImmutable;
22use stdClass;
23
28{
29 public const DISCRIMINATOR_VALUE = 'CustomerCustomFieldChanged';
34 protected $id;
35
40 protected $version;
41
46 protected $createdAt;
47
52 protected $lastModifiedAt;
53
58 protected $lastModifiedBy;
59
64 protected $createdBy;
65
70 protected $sequenceNumber;
71
76 protected $resource;
77
83
88 protected $type;
89
95
100 protected $name;
101
106 protected $value;
107
112 protected $previousValue;
113
114
118 public function __construct(
119 ?string $id = null,
120 ?int $version = null,
121 ?DateTimeImmutable $createdAt = null,
122 ?DateTimeImmutable $lastModifiedAt = null,
124 ?CreatedBy $createdBy = null,
125 ?int $sequenceNumber = null,
126 ?Reference $resource = null,
127 ?int $resourceVersion = null,
129 ?string $name = null,
130 $value = null,
131 $previousValue = null,
132 ?string $type = null
133 ) {
134 $this->id = $id;
135 $this->version = $version;
136 $this->createdAt = $createdAt;
137 $this->lastModifiedAt = $lastModifiedAt;
138 $this->lastModifiedBy = $lastModifiedBy;
139 $this->createdBy = $createdBy;
140 $this->sequenceNumber = $sequenceNumber;
141 $this->resource = $resource;
142 $this->resourceVersion = $resourceVersion;
143 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
144 $this->name = $name;
145 $this->value = $value;
146 $this->previousValue = $previousValue;
147 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
148 }
149
156 public function getId()
157 {
158 if (is_null($this->id)) {
160 $data = $this->raw(self::FIELD_ID);
161 if (is_null($data)) {
162 return null;
163 }
164 $this->id = (string) $data;
165 }
166
167 return $this->id;
168 }
169
176 public function getVersion()
177 {
178 if (is_null($this->version)) {
180 $data = $this->raw(self::FIELD_VERSION);
181 if (is_null($data)) {
182 return null;
183 }
184 $this->version = (int) $data;
185 }
186
187 return $this->version;
188 }
189
196 public function getCreatedAt()
197 {
198 if (is_null($this->createdAt)) {
200 $data = $this->raw(self::FIELD_CREATED_AT);
201 if (is_null($data)) {
202 return null;
203 }
204 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
205 if (false === $data) {
206 return null;
207 }
208 $this->createdAt = $data;
209 }
210
211 return $this->createdAt;
212 }
213
220 public function getLastModifiedAt()
221 {
222 if (is_null($this->lastModifiedAt)) {
224 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
225 if (is_null($data)) {
226 return null;
227 }
228 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
229 if (false === $data) {
230 return null;
231 }
232 $this->lastModifiedAt = $data;
233 }
234
236 }
237
244 public function getLastModifiedBy()
245 {
246 if (is_null($this->lastModifiedBy)) {
248 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
249 if (is_null($data)) {
250 return null;
251 }
252
253 $this->lastModifiedBy = LastModifiedByModel::of($data);
254 }
255
257 }
258
265 public function getCreatedBy()
266 {
267 if (is_null($this->createdBy)) {
269 $data = $this->raw(self::FIELD_CREATED_BY);
270 if (is_null($data)) {
271 return null;
272 }
273
274 $this->createdBy = CreatedByModel::of($data);
275 }
276
277 return $this->createdBy;
278 }
279
287 public function getSequenceNumber()
288 {
289 if (is_null($this->sequenceNumber)) {
291 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
292 if (is_null($data)) {
293 return null;
294 }
295 $this->sequenceNumber = (int) $data;
296 }
297
299 }
300
307 public function getResource()
308 {
309 if (is_null($this->resource)) {
311 $data = $this->raw(self::FIELD_RESOURCE);
312 if (is_null($data)) {
313 return null;
314 }
315 $className = ReferenceModel::resolveDiscriminatorClass($data);
316 $this->resource = $className::of($data);
317 }
318
319 return $this->resource;
320 }
321
328 public function getResourceVersion()
329 {
330 if (is_null($this->resourceVersion)) {
332 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
333 if (is_null($data)) {
334 return null;
335 }
336 $this->resourceVersion = (int) $data;
337 }
338
340 }
341
348 public function getType()
349 {
350 if (is_null($this->type)) {
352 $data = $this->raw(self::FIELD_TYPE);
353 if (is_null($data)) {
354 return null;
355 }
356 $this->type = (string) $data;
357 }
358
359 return $this->type;
360 }
361
369 {
370 if (is_null($this->resourceUserProvidedIdentifiers)) {
372 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
373 if (is_null($data)) {
374 return null;
375 }
376
377 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
378 }
379
381 }
382
389 public function getName()
390 {
391 if (is_null($this->name)) {
393 $data = $this->raw(self::FIELD_NAME);
394 if (is_null($data)) {
395 return null;
396 }
397 $this->name = (string) $data;
398 }
399
400 return $this->name;
401 }
402
409 public function getValue()
410 {
411 if (is_null($this->value)) {
413 $data = $this->raw(self::FIELD_VALUE);
414 if (is_null($data)) {
415 return null;
416 }
417 $this->value = $data;
418 }
419
420 return $this->value;
421 }
422
430 public function getPreviousValue()
431 {
432 if (is_null($this->previousValue)) {
434 $data = $this->raw(self::FIELD_PREVIOUS_VALUE);
435 if (is_null($data)) {
436 return null;
437 }
438 $this->previousValue = $data;
439 }
440
442 }
443
444
448 public function setId(?string $id): void
449 {
450 $this->id = $id;
451 }
452
456 public function setVersion(?int $version): void
457 {
458 $this->version = $version;
459 }
460
464 public function setCreatedAt(?DateTimeImmutable $createdAt): void
465 {
466 $this->createdAt = $createdAt;
467 }
468
472 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
473 {
474 $this->lastModifiedAt = $lastModifiedAt;
475 }
476
481 {
482 $this->lastModifiedBy = $lastModifiedBy;
483 }
484
488 public function setCreatedBy(?CreatedBy $createdBy): void
489 {
490 $this->createdBy = $createdBy;
491 }
492
496 public function setSequenceNumber(?int $sequenceNumber): void
497 {
498 $this->sequenceNumber = $sequenceNumber;
499 }
500
504 public function setResource(?Reference $resource): void
505 {
506 $this->resource = $resource;
507 }
508
512 public function setResourceVersion(?int $resourceVersion): void
513 {
514 $this->resourceVersion = $resourceVersion;
515 }
516
521 {
522 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
523 }
524
528 public function setName(?string $name): void
529 {
530 $this->name = $name;
531 }
532
536 public function setValue($value): void
537 {
538 $this->value = $value;
539 }
540
544 public function setPreviousValue($previousValue): void
545 {
546 $this->previousValue = $previousValue;
547 }
548
549
550 #[\ReturnTypeWillChange]
551 public function jsonSerialize()
552 {
553 $data = $this->toArray();
554 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
555 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
556 }
557
558 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
559 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
560 }
561 return (object) $data;
562 }
563}
__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, ?string $name=null, $value=null, $previousValue=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)