commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MessageDeliveryPayloadModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
27 public const DISCRIMINATOR_VALUE = 'Message';
32 protected $projectKey;
33
39
44 protected $resource;
45
51
56 protected $id;
57
62 protected $version;
63
68 protected $createdAt;
69
74 protected $lastModifiedAt;
75
80 protected $sequenceNumber;
81
87
93
94
98 public function __construct(
99 ?string $projectKey = null,
100 ?Reference $resource = null,
102 ?string $id = null,
103 ?int $version = null,
104 ?DateTimeImmutable $createdAt = null,
105 ?DateTimeImmutable $lastModifiedAt = null,
106 ?int $sequenceNumber = null,
107 ?int $resourceVersion = null,
109 ?string $notificationType = null
110 ) {
111 $this->projectKey = $projectKey;
112 $this->resource = $resource;
113 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
114 $this->id = $id;
115 $this->version = $version;
116 $this->createdAt = $createdAt;
117 $this->lastModifiedAt = $lastModifiedAt;
118 $this->sequenceNumber = $sequenceNumber;
119 $this->resourceVersion = $resourceVersion;
120 $this->payloadNotIncluded = $payloadNotIncluded;
121 $this->notificationType = $notificationType ?? self::DISCRIMINATOR_VALUE;
122 }
123
131 public function getProjectKey()
132 {
133 if (is_null($this->projectKey)) {
135 $data = $this->raw(self::FIELD_PROJECT_KEY);
136 if (is_null($data)) {
137 return null;
138 }
139 $this->projectKey = (string) $data;
140 }
141
142 return $this->projectKey;
143 }
144
151 public function getNotificationType()
152 {
153 if (is_null($this->notificationType)) {
155 $data = $this->raw(self::FIELD_NOTIFICATION_TYPE);
156 if (is_null($data)) {
157 return null;
158 }
159 $this->notificationType = (string) $data;
160 }
161
163 }
164
171 public function getResource()
172 {
173 if (is_null($this->resource)) {
175 $data = $this->raw(self::FIELD_RESOURCE);
176 if (is_null($data)) {
177 return null;
178 }
179 $className = ReferenceModel::resolveDiscriminatorClass($data);
180 $this->resource = $className::of($data);
181 }
182
183 return $this->resource;
184 }
185
193 {
194 if (is_null($this->resourceUserProvidedIdentifiers)) {
196 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
197 if (is_null($data)) {
198 return null;
199 }
200
201 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
202 }
203
205 }
206
213 public function getId()
214 {
215 if (is_null($this->id)) {
217 $data = $this->raw(self::FIELD_ID);
218 if (is_null($data)) {
219 return null;
220 }
221 $this->id = (string) $data;
222 }
223
224 return $this->id;
225 }
226
233 public function getVersion()
234 {
235 if (is_null($this->version)) {
237 $data = $this->raw(self::FIELD_VERSION);
238 if (is_null($data)) {
239 return null;
240 }
241 $this->version = (int) $data;
242 }
243
244 return $this->version;
245 }
246
253 public function getCreatedAt()
254 {
255 if (is_null($this->createdAt)) {
257 $data = $this->raw(self::FIELD_CREATED_AT);
258 if (is_null($data)) {
259 return null;
260 }
261 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
262 if (false === $data) {
263 return null;
264 }
265 $this->createdAt = $data;
266 }
267
268 return $this->createdAt;
269 }
270
277 public function getLastModifiedAt()
278 {
279 if (is_null($this->lastModifiedAt)) {
281 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
282 if (is_null($data)) {
283 return null;
284 }
285 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
286 if (false === $data) {
287 return null;
288 }
289 $this->lastModifiedAt = $data;
290 }
291
293 }
294
302 public function getSequenceNumber()
303 {
304 if (is_null($this->sequenceNumber)) {
306 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
307 if (is_null($data)) {
308 return null;
309 }
310 $this->sequenceNumber = (int) $data;
311 }
312
314 }
315
322 public function getResourceVersion()
323 {
324 if (is_null($this->resourceVersion)) {
326 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
327 if (is_null($data)) {
328 return null;
329 }
330 $this->resourceVersion = (int) $data;
331 }
332
334 }
335
342 public function getPayloadNotIncluded()
343 {
344 if (is_null($this->payloadNotIncluded)) {
346 $data = $this->raw(self::FIELD_PAYLOAD_NOT_INCLUDED);
347 if (is_null($data)) {
348 return null;
349 }
350
351 $this->payloadNotIncluded = PayloadNotIncludedModel::of($data);
352 }
353
355 }
356
357
361 public function setProjectKey(?string $projectKey): void
362 {
363 $this->projectKey = $projectKey;
364 }
365
369 public function setResource(?Reference $resource): void
370 {
371 $this->resource = $resource;
372 }
373
378 {
379 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
380 }
381
385 public function setId(?string $id): void
386 {
387 $this->id = $id;
388 }
389
393 public function setVersion(?int $version): void
394 {
395 $this->version = $version;
396 }
397
401 public function setCreatedAt(?DateTimeImmutable $createdAt): void
402 {
403 $this->createdAt = $createdAt;
404 }
405
409 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
410 {
411 $this->lastModifiedAt = $lastModifiedAt;
412 }
413
417 public function setSequenceNumber(?int $sequenceNumber): void
418 {
419 $this->sequenceNumber = $sequenceNumber;
420 }
421
425 public function setResourceVersion(?int $resourceVersion): void
426 {
427 $this->resourceVersion = $resourceVersion;
428 }
429
434 {
435 $this->payloadNotIncluded = $payloadNotIncluded;
436 }
437
438
439 #[\ReturnTypeWillChange]
440 public function jsonSerialize()
441 {
442 $data = $this->toArray();
443 if (isset($data[MessageDeliveryPayload::FIELD_CREATED_AT]) && $data[MessageDeliveryPayload::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
444 $data[MessageDeliveryPayload::FIELD_CREATED_AT] = $data[MessageDeliveryPayload::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
445 }
446
447 if (isset($data[MessageDeliveryPayload::FIELD_LAST_MODIFIED_AT]) && $data[MessageDeliveryPayload::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
448 $data[MessageDeliveryPayload::FIELD_LAST_MODIFIED_AT] = $data[MessageDeliveryPayload::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
449 }
450 return (object) $data;
451 }
452}
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__construct(?string $projectKey=null, ?Reference $resource=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?int $sequenceNumber=null, ?int $resourceVersion=null, ?PayloadNotIncluded $payloadNotIncluded=null, ?string $notificationType=null)