commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
RecurringOrderModel.php
1<?php
2
3declare(strict_types=1);
10
37use DateTimeImmutable;
38use stdClass;
39
44{
49 protected $id;
50
55 protected $version;
56
61 protected $createdAt;
62
67 protected $lastModifiedAt;
68
73 protected $key;
74
79 protected $cart;
80
85 protected $originOrder;
86
91 protected $startsAt;
92
97 protected $resumesAt;
98
103 protected $expiresAt;
104
109 protected $lastOrderAt;
110
115 protected $nextOrderAt;
116
122
127 protected $store;
128
133 protected $businessUnit;
134
139 protected $state;
140
146
151 protected $schedule;
152
157 protected $customer;
158
163 protected $customerEmail;
164
169 protected $custom;
170
176
181 protected $createdBy;
182
183
187 public function __construct(
188 ?string $id = null,
189 ?int $version = null,
190 ?DateTimeImmutable $createdAt = null,
191 ?DateTimeImmutable $lastModifiedAt = null,
192 ?string $key = null,
193 ?CartReference $cart = null,
195 ?DateTimeImmutable $startsAt = null,
196 ?DateTimeImmutable $resumesAt = null,
197 ?DateTimeImmutable $expiresAt = null,
198 ?DateTimeImmutable $lastOrderAt = null,
199 ?DateTimeImmutable $nextOrderAt = null,
203 ?StateReference $state = null,
204 ?string $recurringOrderState = null,
207 ?string $customerEmail = null,
208 ?CustomFields $custom = null,
210 ?CreatedBy $createdBy = null
211 ) {
212 $this->id = $id;
213 $this->version = $version;
214 $this->createdAt = $createdAt;
215 $this->lastModifiedAt = $lastModifiedAt;
216 $this->key = $key;
217 $this->cart = $cart;
218 $this->originOrder = $originOrder;
219 $this->startsAt = $startsAt;
220 $this->resumesAt = $resumesAt;
221 $this->expiresAt = $expiresAt;
222 $this->lastOrderAt = $lastOrderAt;
223 $this->nextOrderAt = $nextOrderAt;
224 $this->skipConfiguration = $skipConfiguration;
225 $this->store = $store;
226 $this->businessUnit = $businessUnit;
227 $this->state = $state;
228 $this->recurringOrderState = $recurringOrderState;
229 $this->schedule = $schedule;
230 $this->customer = $customer;
231 $this->customerEmail = $customerEmail;
232 $this->custom = $custom;
233 $this->lastModifiedBy = $lastModifiedBy;
234 $this->createdBy = $createdBy;
235 }
236
243 public function getId()
244 {
245 if (is_null($this->id)) {
247 $data = $this->raw(self::FIELD_ID);
248 if (is_null($data)) {
249 return null;
250 }
251 $this->id = (string) $data;
252 }
253
254 return $this->id;
255 }
256
263 public function getVersion()
264 {
265 if (is_null($this->version)) {
267 $data = $this->raw(self::FIELD_VERSION);
268 if (is_null($data)) {
269 return null;
270 }
271 $this->version = (int) $data;
272 }
273
274 return $this->version;
275 }
276
283 public function getCreatedAt()
284 {
285 if (is_null($this->createdAt)) {
287 $data = $this->raw(self::FIELD_CREATED_AT);
288 if (is_null($data)) {
289 return null;
290 }
291 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
292 if (false === $data) {
293 return null;
294 }
295 $this->createdAt = $data;
296 }
297
298 return $this->createdAt;
299 }
300
307 public function getLastModifiedAt()
308 {
309 if (is_null($this->lastModifiedAt)) {
311 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
312 if (is_null($data)) {
313 return null;
314 }
315 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
316 if (false === $data) {
317 return null;
318 }
319 $this->lastModifiedAt = $data;
320 }
321
323 }
324
331 public function getKey()
332 {
333 if (is_null($this->key)) {
335 $data = $this->raw(self::FIELD_KEY);
336 if (is_null($data)) {
337 return null;
338 }
339 $this->key = (string) $data;
340 }
341
342 return $this->key;
343 }
344
352 public function getCart()
353 {
354 if (is_null($this->cart)) {
356 $data = $this->raw(self::FIELD_CART);
357 if (is_null($data)) {
358 return null;
359 }
360
361 $this->cart = CartReferenceModel::of($data);
362 }
363
364 return $this->cart;
365 }
366
373 public function getOriginOrder()
374 {
375 if (is_null($this->originOrder)) {
377 $data = $this->raw(self::FIELD_ORIGIN_ORDER);
378 if (is_null($data)) {
379 return null;
380 }
381
382 $this->originOrder = OrderReferenceModel::of($data);
383 }
384
385 return $this->originOrder;
386 }
387
394 public function getStartsAt()
395 {
396 if (is_null($this->startsAt)) {
398 $data = $this->raw(self::FIELD_STARTS_AT);
399 if (is_null($data)) {
400 return null;
401 }
402 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
403 if (false === $data) {
404 return null;
405 }
406 $this->startsAt = $data;
407 }
408
409 return $this->startsAt;
410 }
411
418 public function getResumesAt()
419 {
420 if (is_null($this->resumesAt)) {
422 $data = $this->raw(self::FIELD_RESUMES_AT);
423 if (is_null($data)) {
424 return null;
425 }
426 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
427 if (false === $data) {
428 return null;
429 }
430 $this->resumesAt = $data;
431 }
432
433 return $this->resumesAt;
434 }
435
442 public function getExpiresAt()
443 {
444 if (is_null($this->expiresAt)) {
446 $data = $this->raw(self::FIELD_EXPIRES_AT);
447 if (is_null($data)) {
448 return null;
449 }
450 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
451 if (false === $data) {
452 return null;
453 }
454 $this->expiresAt = $data;
455 }
456
457 return $this->expiresAt;
458 }
459
466 public function getLastOrderAt()
467 {
468 if (is_null($this->lastOrderAt)) {
470 $data = $this->raw(self::FIELD_LAST_ORDER_AT);
471 if (is_null($data)) {
472 return null;
473 }
474 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
475 if (false === $data) {
476 return null;
477 }
478 $this->lastOrderAt = $data;
479 }
480
481 return $this->lastOrderAt;
482 }
483
490 public function getNextOrderAt()
491 {
492 if (is_null($this->nextOrderAt)) {
494 $data = $this->raw(self::FIELD_NEXT_ORDER_AT);
495 if (is_null($data)) {
496 return null;
497 }
498 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
499 if (false === $data) {
500 return null;
501 }
502 $this->nextOrderAt = $data;
503 }
504
505 return $this->nextOrderAt;
506 }
507
514 public function getSkipConfiguration()
515 {
516 if (is_null($this->skipConfiguration)) {
518 $data = $this->raw(self::FIELD_SKIP_CONFIGURATION);
519 if (is_null($data)) {
520 return null;
521 }
523 $this->skipConfiguration = $className::of($data);
524 }
525
527 }
528
535 public function getStore()
536 {
537 if (is_null($this->store)) {
539 $data = $this->raw(self::FIELD_STORE);
540 if (is_null($data)) {
541 return null;
542 }
543
544 $this->store = StoreKeyReferenceModel::of($data);
545 }
546
547 return $this->store;
548 }
549
556 public function getBusinessUnit()
557 {
558 if (is_null($this->businessUnit)) {
560 $data = $this->raw(self::FIELD_BUSINESS_UNIT);
561 if (is_null($data)) {
562 return null;
563 }
564
565 $this->businessUnit = BusinessUnitKeyReferenceModel::of($data);
566 }
567
568 return $this->businessUnit;
569 }
570
577 public function getState()
578 {
579 if (is_null($this->state)) {
581 $data = $this->raw(self::FIELD_STATE);
582 if (is_null($data)) {
583 return null;
584 }
585
586 $this->state = StateReferenceModel::of($data);
587 }
588
589 return $this->state;
590 }
591
598 public function getRecurringOrderState()
599 {
600 if (is_null($this->recurringOrderState)) {
602 $data = $this->raw(self::FIELD_RECURRING_ORDER_STATE);
603 if (is_null($data)) {
604 return null;
605 }
606 $this->recurringOrderState = (string) $data;
607 }
608
610 }
611
618 public function getSchedule()
619 {
620 if (is_null($this->schedule)) {
622 $data = $this->raw(self::FIELD_SCHEDULE);
623 if (is_null($data)) {
624 return null;
625 }
626 $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data);
627 $this->schedule = $className::of($data);
628 }
629
630 return $this->schedule;
631 }
632
639 public function getCustomer()
640 {
641 if (is_null($this->customer)) {
643 $data = $this->raw(self::FIELD_CUSTOMER);
644 if (is_null($data)) {
645 return null;
646 }
647
648 $this->customer = CustomerReferenceModel::of($data);
649 }
650
651 return $this->customer;
652 }
653
660 public function getCustomerEmail()
661 {
662 if (is_null($this->customerEmail)) {
664 $data = $this->raw(self::FIELD_CUSTOMER_EMAIL);
665 if (is_null($data)) {
666 return null;
667 }
668 $this->customerEmail = (string) $data;
669 }
670
672 }
673
680 public function getCustom()
681 {
682 if (is_null($this->custom)) {
684 $data = $this->raw(self::FIELD_CUSTOM);
685 if (is_null($data)) {
686 return null;
687 }
688
689 $this->custom = CustomFieldsModel::of($data);
690 }
691
692 return $this->custom;
693 }
694
701 public function getLastModifiedBy()
702 {
703 if (is_null($this->lastModifiedBy)) {
705 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
706 if (is_null($data)) {
707 return null;
708 }
709
710 $this->lastModifiedBy = LastModifiedByModel::of($data);
711 }
712
714 }
715
722 public function getCreatedBy()
723 {
724 if (is_null($this->createdBy)) {
726 $data = $this->raw(self::FIELD_CREATED_BY);
727 if (is_null($data)) {
728 return null;
729 }
730
731 $this->createdBy = CreatedByModel::of($data);
732 }
733
734 return $this->createdBy;
735 }
736
737
741 public function setId(?string $id): void
742 {
743 $this->id = $id;
744 }
745
749 public function setVersion(?int $version): void
750 {
751 $this->version = $version;
752 }
753
757 public function setCreatedAt(?DateTimeImmutable $createdAt): void
758 {
759 $this->createdAt = $createdAt;
760 }
761
765 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
766 {
767 $this->lastModifiedAt = $lastModifiedAt;
768 }
769
773 public function setKey(?string $key): void
774 {
775 $this->key = $key;
776 }
777
781 public function setCart(?CartReference $cart): void
782 {
783 $this->cart = $cart;
784 }
785
790 {
791 $this->originOrder = $originOrder;
792 }
793
797 public function setStartsAt(?DateTimeImmutable $startsAt): void
798 {
799 $this->startsAt = $startsAt;
800 }
801
805 public function setResumesAt(?DateTimeImmutable $resumesAt): void
806 {
807 $this->resumesAt = $resumesAt;
808 }
809
813 public function setExpiresAt(?DateTimeImmutable $expiresAt): void
814 {
815 $this->expiresAt = $expiresAt;
816 }
817
821 public function setLastOrderAt(?DateTimeImmutable $lastOrderAt): void
822 {
823 $this->lastOrderAt = $lastOrderAt;
824 }
825
829 public function setNextOrderAt(?DateTimeImmutable $nextOrderAt): void
830 {
831 $this->nextOrderAt = $nextOrderAt;
832 }
833
838 {
839 $this->skipConfiguration = $skipConfiguration;
840 }
841
845 public function setStore(?StoreKeyReference $store): void
846 {
847 $this->store = $store;
848 }
849
854 {
855 $this->businessUnit = $businessUnit;
856 }
857
861 public function setState(?StateReference $state): void
862 {
863 $this->state = $state;
864 }
865
869 public function setRecurringOrderState(?string $recurringOrderState): void
870 {
871 $this->recurringOrderState = $recurringOrderState;
872 }
873
878 {
879 $this->schedule = $schedule;
880 }
881
886 {
887 $this->customer = $customer;
888 }
889
893 public function setCustomerEmail(?string $customerEmail): void
894 {
895 $this->customerEmail = $customerEmail;
896 }
897
901 public function setCustom(?CustomFields $custom): void
902 {
903 $this->custom = $custom;
904 }
905
910 {
911 $this->lastModifiedBy = $lastModifiedBy;
912 }
913
917 public function setCreatedBy(?CreatedBy $createdBy): void
918 {
919 $this->createdBy = $createdBy;
920 }
921
922
923 #[\ReturnTypeWillChange]
924 public function jsonSerialize()
925 {
926 $data = $this->toArray();
927 if (isset($data[RecurringOrder::FIELD_CREATED_AT]) && $data[RecurringOrder::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
928 $data[RecurringOrder::FIELD_CREATED_AT] = $data[RecurringOrder::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
929 }
930
931 if (isset($data[RecurringOrder::FIELD_LAST_MODIFIED_AT]) && $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
932 $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] = $data[RecurringOrder::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
933 }
934
935 if (isset($data[RecurringOrder::FIELD_STARTS_AT]) && $data[RecurringOrder::FIELD_STARTS_AT] instanceof \DateTimeImmutable) {
936 $data[RecurringOrder::FIELD_STARTS_AT] = $data[RecurringOrder::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
937 }
938
939 if (isset($data[RecurringOrder::FIELD_RESUMES_AT]) && $data[RecurringOrder::FIELD_RESUMES_AT] instanceof \DateTimeImmutable) {
940 $data[RecurringOrder::FIELD_RESUMES_AT] = $data[RecurringOrder::FIELD_RESUMES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
941 }
942
943 if (isset($data[RecurringOrder::FIELD_EXPIRES_AT]) && $data[RecurringOrder::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
944 $data[RecurringOrder::FIELD_EXPIRES_AT] = $data[RecurringOrder::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
945 }
946
947 if (isset($data[RecurringOrder::FIELD_LAST_ORDER_AT]) && $data[RecurringOrder::FIELD_LAST_ORDER_AT] instanceof \DateTimeImmutable) {
948 $data[RecurringOrder::FIELD_LAST_ORDER_AT] = $data[RecurringOrder::FIELD_LAST_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
949 }
950
951 if (isset($data[RecurringOrder::FIELD_NEXT_ORDER_AT]) && $data[RecurringOrder::FIELD_NEXT_ORDER_AT] instanceof \DateTimeImmutable) {
952 $data[RecurringOrder::FIELD_NEXT_ORDER_AT] = $data[RecurringOrder::FIELD_NEXT_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
953 }
954 return (object) $data;
955 }
956}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?CartReference $cart=null, ?OrderReference $originOrder=null, ?DateTimeImmutable $startsAt=null, ?DateTimeImmutable $resumesAt=null, ?DateTimeImmutable $expiresAt=null, ?DateTimeImmutable $lastOrderAt=null, ?DateTimeImmutable $nextOrderAt=null, ?SkipConfiguration $skipConfiguration=null, ?StoreKeyReference $store=null, ?BusinessUnitKeyReference $businessUnit=null, ?StateReference $state=null, ?string $recurringOrderState=null, ?RecurrencePolicySchedule $schedule=null, ?CustomerReference $customer=null, ?string $customerEmail=null, ?CustomFields $custom=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null)