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
375 public function getOriginOrder()
376 {
377 if (is_null($this->originOrder)) {
379 $data = $this->raw(self::FIELD_ORIGIN_ORDER);
380 if (is_null($data)) {
381 return null;
382 }
383
384 $this->originOrder = OrderReferenceModel::of($data);
385 }
386
387 return $this->originOrder;
388 }
389
396 public function getStartsAt()
397 {
398 if (is_null($this->startsAt)) {
400 $data = $this->raw(self::FIELD_STARTS_AT);
401 if (is_null($data)) {
402 return null;
403 }
404 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
405 if (false === $data) {
406 return null;
407 }
408 $this->startsAt = $data;
409 }
410
411 return $this->startsAt;
412 }
413
420 public function getResumesAt()
421 {
422 if (is_null($this->resumesAt)) {
424 $data = $this->raw(self::FIELD_RESUMES_AT);
425 if (is_null($data)) {
426 return null;
427 }
428 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
429 if (false === $data) {
430 return null;
431 }
432 $this->resumesAt = $data;
433 }
434
435 return $this->resumesAt;
436 }
437
444 public function getExpiresAt()
445 {
446 if (is_null($this->expiresAt)) {
448 $data = $this->raw(self::FIELD_EXPIRES_AT);
449 if (is_null($data)) {
450 return null;
451 }
452 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
453 if (false === $data) {
454 return null;
455 }
456 $this->expiresAt = $data;
457 }
458
459 return $this->expiresAt;
460 }
461
468 public function getLastOrderAt()
469 {
470 if (is_null($this->lastOrderAt)) {
472 $data = $this->raw(self::FIELD_LAST_ORDER_AT);
473 if (is_null($data)) {
474 return null;
475 }
476 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
477 if (false === $data) {
478 return null;
479 }
480 $this->lastOrderAt = $data;
481 }
482
483 return $this->lastOrderAt;
484 }
485
492 public function getNextOrderAt()
493 {
494 if (is_null($this->nextOrderAt)) {
496 $data = $this->raw(self::FIELD_NEXT_ORDER_AT);
497 if (is_null($data)) {
498 return null;
499 }
500 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
501 if (false === $data) {
502 return null;
503 }
504 $this->nextOrderAt = $data;
505 }
506
507 return $this->nextOrderAt;
508 }
509
516 public function getSkipConfiguration()
517 {
518 if (is_null($this->skipConfiguration)) {
520 $data = $this->raw(self::FIELD_SKIP_CONFIGURATION);
521 if (is_null($data)) {
522 return null;
523 }
525 $this->skipConfiguration = $className::of($data);
526 }
527
529 }
530
537 public function getStore()
538 {
539 if (is_null($this->store)) {
541 $data = $this->raw(self::FIELD_STORE);
542 if (is_null($data)) {
543 return null;
544 }
545
546 $this->store = StoreKeyReferenceModel::of($data);
547 }
548
549 return $this->store;
550 }
551
558 public function getBusinessUnit()
559 {
560 if (is_null($this->businessUnit)) {
562 $data = $this->raw(self::FIELD_BUSINESS_UNIT);
563 if (is_null($data)) {
564 return null;
565 }
566
567 $this->businessUnit = BusinessUnitKeyReferenceModel::of($data);
568 }
569
570 return $this->businessUnit;
571 }
572
579 public function getState()
580 {
581 if (is_null($this->state)) {
583 $data = $this->raw(self::FIELD_STATE);
584 if (is_null($data)) {
585 return null;
586 }
587
588 $this->state = StateReferenceModel::of($data);
589 }
590
591 return $this->state;
592 }
593
600 public function getRecurringOrderState()
601 {
602 if (is_null($this->recurringOrderState)) {
604 $data = $this->raw(self::FIELD_RECURRING_ORDER_STATE);
605 if (is_null($data)) {
606 return null;
607 }
608 $this->recurringOrderState = (string) $data;
609 }
610
612 }
613
620 public function getSchedule()
621 {
622 if (is_null($this->schedule)) {
624 $data = $this->raw(self::FIELD_SCHEDULE);
625 if (is_null($data)) {
626 return null;
627 }
628 $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data);
629 $this->schedule = $className::of($data);
630 }
631
632 return $this->schedule;
633 }
634
641 public function getCustomer()
642 {
643 if (is_null($this->customer)) {
645 $data = $this->raw(self::FIELD_CUSTOMER);
646 if (is_null($data)) {
647 return null;
648 }
649
650 $this->customer = CustomerReferenceModel::of($data);
651 }
652
653 return $this->customer;
654 }
655
662 public function getCustomerEmail()
663 {
664 if (is_null($this->customerEmail)) {
666 $data = $this->raw(self::FIELD_CUSTOMER_EMAIL);
667 if (is_null($data)) {
668 return null;
669 }
670 $this->customerEmail = (string) $data;
671 }
672
674 }
675
682 public function getCustom()
683 {
684 if (is_null($this->custom)) {
686 $data = $this->raw(self::FIELD_CUSTOM);
687 if (is_null($data)) {
688 return null;
689 }
690
691 $this->custom = CustomFieldsModel::of($data);
692 }
693
694 return $this->custom;
695 }
696
703 public function getLastModifiedBy()
704 {
705 if (is_null($this->lastModifiedBy)) {
707 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
708 if (is_null($data)) {
709 return null;
710 }
711
712 $this->lastModifiedBy = LastModifiedByModel::of($data);
713 }
714
716 }
717
724 public function getCreatedBy()
725 {
726 if (is_null($this->createdBy)) {
728 $data = $this->raw(self::FIELD_CREATED_BY);
729 if (is_null($data)) {
730 return null;
731 }
732
733 $this->createdBy = CreatedByModel::of($data);
734 }
735
736 return $this->createdBy;
737 }
738
739
743 public function setId(?string $id): void
744 {
745 $this->id = $id;
746 }
747
751 public function setVersion(?int $version): void
752 {
753 $this->version = $version;
754 }
755
759 public function setCreatedAt(?DateTimeImmutable $createdAt): void
760 {
761 $this->createdAt = $createdAt;
762 }
763
767 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
768 {
769 $this->lastModifiedAt = $lastModifiedAt;
770 }
771
775 public function setKey(?string $key): void
776 {
777 $this->key = $key;
778 }
779
783 public function setCart(?CartReference $cart): void
784 {
785 $this->cart = $cart;
786 }
787
792 {
793 $this->originOrder = $originOrder;
794 }
795
799 public function setStartsAt(?DateTimeImmutable $startsAt): void
800 {
801 $this->startsAt = $startsAt;
802 }
803
807 public function setResumesAt(?DateTimeImmutable $resumesAt): void
808 {
809 $this->resumesAt = $resumesAt;
810 }
811
815 public function setExpiresAt(?DateTimeImmutable $expiresAt): void
816 {
817 $this->expiresAt = $expiresAt;
818 }
819
823 public function setLastOrderAt(?DateTimeImmutable $lastOrderAt): void
824 {
825 $this->lastOrderAt = $lastOrderAt;
826 }
827
831 public function setNextOrderAt(?DateTimeImmutable $nextOrderAt): void
832 {
833 $this->nextOrderAt = $nextOrderAt;
834 }
835
840 {
841 $this->skipConfiguration = $skipConfiguration;
842 }
843
847 public function setStore(?StoreKeyReference $store): void
848 {
849 $this->store = $store;
850 }
851
856 {
857 $this->businessUnit = $businessUnit;
858 }
859
863 public function setState(?StateReference $state): void
864 {
865 $this->state = $state;
866 }
867
871 public function setRecurringOrderState(?string $recurringOrderState): void
872 {
873 $this->recurringOrderState = $recurringOrderState;
874 }
875
880 {
881 $this->schedule = $schedule;
882 }
883
888 {
889 $this->customer = $customer;
890 }
891
895 public function setCustomerEmail(?string $customerEmail): void
896 {
897 $this->customerEmail = $customerEmail;
898 }
899
903 public function setCustom(?CustomFields $custom): void
904 {
905 $this->custom = $custom;
906 }
907
912 {
913 $this->lastModifiedBy = $lastModifiedBy;
914 }
915
919 public function setCreatedBy(?CreatedBy $createdBy): void
920 {
921 $this->createdBy = $createdBy;
922 }
923
924
925 #[\ReturnTypeWillChange]
926 public function jsonSerialize()
927 {
928 $data = $this->toArray();
929 if (isset($data[RecurringOrder::FIELD_CREATED_AT]) && $data[RecurringOrder::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
930 $data[RecurringOrder::FIELD_CREATED_AT] = $data[RecurringOrder::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
931 }
932
933 if (isset($data[RecurringOrder::FIELD_LAST_MODIFIED_AT]) && $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
934 $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] = $data[RecurringOrder::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
935 }
936
937 if (isset($data[RecurringOrder::FIELD_STARTS_AT]) && $data[RecurringOrder::FIELD_STARTS_AT] instanceof \DateTimeImmutable) {
938 $data[RecurringOrder::FIELD_STARTS_AT] = $data[RecurringOrder::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
939 }
940
941 if (isset($data[RecurringOrder::FIELD_RESUMES_AT]) && $data[RecurringOrder::FIELD_RESUMES_AT] instanceof \DateTimeImmutable) {
942 $data[RecurringOrder::FIELD_RESUMES_AT] = $data[RecurringOrder::FIELD_RESUMES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
943 }
944
945 if (isset($data[RecurringOrder::FIELD_EXPIRES_AT]) && $data[RecurringOrder::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
946 $data[RecurringOrder::FIELD_EXPIRES_AT] = $data[RecurringOrder::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
947 }
948
949 if (isset($data[RecurringOrder::FIELD_LAST_ORDER_AT]) && $data[RecurringOrder::FIELD_LAST_ORDER_AT] instanceof \DateTimeImmutable) {
950 $data[RecurringOrder::FIELD_LAST_ORDER_AT] = $data[RecurringOrder::FIELD_LAST_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
951 }
952
953 if (isset($data[RecurringOrder::FIELD_NEXT_ORDER_AT]) && $data[RecurringOrder::FIELD_NEXT_ORDER_AT] instanceof \DateTimeImmutable) {
954 $data[RecurringOrder::FIELD_NEXT_ORDER_AT] = $data[RecurringOrder::FIELD_NEXT_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
955 }
956 return (object) $data;
957 }
958}
__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)