commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
RecurringOrderFailedMessageModel.php
1<?php
2
3declare(strict_types=1);
10
22use DateTimeImmutable;
23use stdClass;
24
29{
30 public const DISCRIMINATOR_VALUE = 'RecurringOrderFailed';
35 protected $id;
36
41 protected $version;
42
47 protected $createdAt;
48
53 protected $lastModifiedAt;
54
59 protected $lastModifiedBy;
60
65 protected $createdBy;
66
71 protected $sequenceNumber;
72
77 protected $resource;
78
84
89 protected $type;
90
96
101 protected $cartId;
102
107 protected $failedAt;
108
113 protected $failureReason;
114
120
125 protected $errors;
126
127
131 public function __construct(
132 ?string $id = null,
133 ?int $version = null,
134 ?DateTimeImmutable $createdAt = null,
135 ?DateTimeImmutable $lastModifiedAt = null,
137 ?CreatedBy $createdBy = null,
138 ?int $sequenceNumber = null,
139 ?Reference $resource = null,
140 ?int $resourceVersion = null,
142 ?string $cartId = null,
143 ?DateTimeImmutable $failedAt = null,
144 ?string $failureReason = null,
145 ?DateTimeImmutable $orderScheduledAt = null,
147 ?string $type = null
148 ) {
149 $this->id = $id;
150 $this->version = $version;
151 $this->createdAt = $createdAt;
152 $this->lastModifiedAt = $lastModifiedAt;
153 $this->lastModifiedBy = $lastModifiedBy;
154 $this->createdBy = $createdBy;
155 $this->sequenceNumber = $sequenceNumber;
156 $this->resource = $resource;
157 $this->resourceVersion = $resourceVersion;
158 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
159 $this->cartId = $cartId;
160 $this->failedAt = $failedAt;
161 $this->failureReason = $failureReason;
162 $this->orderScheduledAt = $orderScheduledAt;
163 $this->errors = $errors;
164 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
165 }
166
173 public function getId()
174 {
175 if (is_null($this->id)) {
177 $data = $this->raw(self::FIELD_ID);
178 if (is_null($data)) {
179 return null;
180 }
181 $this->id = (string) $data;
182 }
183
184 return $this->id;
185 }
186
193 public function getVersion()
194 {
195 if (is_null($this->version)) {
197 $data = $this->raw(self::FIELD_VERSION);
198 if (is_null($data)) {
199 return null;
200 }
201 $this->version = (int) $data;
202 }
203
204 return $this->version;
205 }
206
213 public function getCreatedAt()
214 {
215 if (is_null($this->createdAt)) {
217 $data = $this->raw(self::FIELD_CREATED_AT);
218 if (is_null($data)) {
219 return null;
220 }
221 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
222 if (false === $data) {
223 return null;
224 }
225 $this->createdAt = $data;
226 }
227
228 return $this->createdAt;
229 }
230
237 public function getLastModifiedAt()
238 {
239 if (is_null($this->lastModifiedAt)) {
241 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
242 if (is_null($data)) {
243 return null;
244 }
245 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
246 if (false === $data) {
247 return null;
248 }
249 $this->lastModifiedAt = $data;
250 }
251
253 }
254
261 public function getLastModifiedBy()
262 {
263 if (is_null($this->lastModifiedBy)) {
265 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
266 if (is_null($data)) {
267 return null;
268 }
269
270 $this->lastModifiedBy = LastModifiedByModel::of($data);
271 }
272
274 }
275
282 public function getCreatedBy()
283 {
284 if (is_null($this->createdBy)) {
286 $data = $this->raw(self::FIELD_CREATED_BY);
287 if (is_null($data)) {
288 return null;
289 }
290
291 $this->createdBy = CreatedByModel::of($data);
292 }
293
294 return $this->createdBy;
295 }
296
304 public function getSequenceNumber()
305 {
306 if (is_null($this->sequenceNumber)) {
308 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
309 if (is_null($data)) {
310 return null;
311 }
312 $this->sequenceNumber = (int) $data;
313 }
314
316 }
317
324 public function getResource()
325 {
326 if (is_null($this->resource)) {
328 $data = $this->raw(self::FIELD_RESOURCE);
329 if (is_null($data)) {
330 return null;
331 }
332 $className = ReferenceModel::resolveDiscriminatorClass($data);
333 $this->resource = $className::of($data);
334 }
335
336 return $this->resource;
337 }
338
345 public function getResourceVersion()
346 {
347 if (is_null($this->resourceVersion)) {
349 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
350 if (is_null($data)) {
351 return null;
352 }
353 $this->resourceVersion = (int) $data;
354 }
355
357 }
358
365 public function getType()
366 {
367 if (is_null($this->type)) {
369 $data = $this->raw(self::FIELD_TYPE);
370 if (is_null($data)) {
371 return null;
372 }
373 $this->type = (string) $data;
374 }
375
376 return $this->type;
377 }
378
386 {
387 if (is_null($this->resourceUserProvidedIdentifiers)) {
389 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
390 if (is_null($data)) {
391 return null;
392 }
393
394 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
395 }
396
398 }
399
406 public function getCartId()
407 {
408 if (is_null($this->cartId)) {
410 $data = $this->raw(self::FIELD_CART_ID);
411 if (is_null($data)) {
412 return null;
413 }
414 $this->cartId = (string) $data;
415 }
416
417 return $this->cartId;
418 }
419
426 public function getFailedAt()
427 {
428 if (is_null($this->failedAt)) {
430 $data = $this->raw(self::FIELD_FAILED_AT);
431 if (is_null($data)) {
432 return null;
433 }
434 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
435 if (false === $data) {
436 return null;
437 }
438 $this->failedAt = $data;
439 }
440
441 return $this->failedAt;
442 }
443
450 public function getFailureReason()
451 {
452 if (is_null($this->failureReason)) {
454 $data = $this->raw(self::FIELD_FAILURE_REASON);
455 if (is_null($data)) {
456 return null;
457 }
458 $this->failureReason = (string) $data;
459 }
460
462 }
463
470 public function getOrderScheduledAt()
471 {
472 if (is_null($this->orderScheduledAt)) {
474 $data = $this->raw(self::FIELD_ORDER_SCHEDULED_AT);
475 if (is_null($data)) {
476 return null;
477 }
478 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
479 if (false === $data) {
480 return null;
481 }
482 $this->orderScheduledAt = $data;
483 }
484
486 }
487
494 public function getErrors()
495 {
496 if (is_null($this->errors)) {
498 $data = $this->raw(self::FIELD_ERRORS);
499 if (is_null($data)) {
500 return null;
501 }
502 $this->errors = RecurringOrderFailureErrorCollection::fromArray($data);
503 }
504
505 return $this->errors;
506 }
507
508
512 public function setId(?string $id): void
513 {
514 $this->id = $id;
515 }
516
520 public function setVersion(?int $version): void
521 {
522 $this->version = $version;
523 }
524
528 public function setCreatedAt(?DateTimeImmutable $createdAt): void
529 {
530 $this->createdAt = $createdAt;
531 }
532
536 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
537 {
538 $this->lastModifiedAt = $lastModifiedAt;
539 }
540
545 {
546 $this->lastModifiedBy = $lastModifiedBy;
547 }
548
552 public function setCreatedBy(?CreatedBy $createdBy): void
553 {
554 $this->createdBy = $createdBy;
555 }
556
560 public function setSequenceNumber(?int $sequenceNumber): void
561 {
562 $this->sequenceNumber = $sequenceNumber;
563 }
564
568 public function setResource(?Reference $resource): void
569 {
570 $this->resource = $resource;
571 }
572
576 public function setResourceVersion(?int $resourceVersion): void
577 {
578 $this->resourceVersion = $resourceVersion;
579 }
580
585 {
586 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
587 }
588
592 public function setCartId(?string $cartId): void
593 {
594 $this->cartId = $cartId;
595 }
596
600 public function setFailedAt(?DateTimeImmutable $failedAt): void
601 {
602 $this->failedAt = $failedAt;
603 }
604
608 public function setFailureReason(?string $failureReason): void
609 {
610 $this->failureReason = $failureReason;
611 }
612
616 public function setOrderScheduledAt(?DateTimeImmutable $orderScheduledAt): void
617 {
618 $this->orderScheduledAt = $orderScheduledAt;
619 }
620
625 {
626 $this->errors = $errors;
627 }
628
629
630 #[\ReturnTypeWillChange]
631 public function jsonSerialize()
632 {
633 $data = $this->toArray();
634 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
635 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
636 }
637
638 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
639 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
640 }
641
642 if (isset($data[RecurringOrderFailedMessage::FIELD_FAILED_AT]) && $data[RecurringOrderFailedMessage::FIELD_FAILED_AT] instanceof \DateTimeImmutable) {
643 $data[RecurringOrderFailedMessage::FIELD_FAILED_AT] = $data[RecurringOrderFailedMessage::FIELD_FAILED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
644 }
645
647 $data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT] = $data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
648 }
649 return (object) $data;
650 }
651}
__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 $cartId=null, ?DateTimeImmutable $failedAt=null, ?string $failureReason=null, ?DateTimeImmutable $orderScheduledAt=null, ?RecurringOrderFailureErrorCollection $errors=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)