commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CartDiscountBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
28 use DateTimeImmutable;
29 use stdClass;
30 
34 final class CartDiscountBuilder implements Builder
35 {
40  private $id;
41 
46  private $version;
47 
52  private $createdAt;
53 
58  private $lastModifiedAt;
59 
64  private $lastModifiedBy;
65 
70  private $createdBy;
71 
76  private $name;
77 
82  private $key;
83 
88  private $description;
89 
94  private $value;
95 
100  private $cartPredicate;
101 
106  private $target;
107 
112  private $sortOrder;
113 
118  private $stores;
119 
124  private $isActive;
125 
130  private $validFrom;
131 
136  private $validUntil;
137 
142  private $requiresDiscountCode;
143 
148  private $references;
149 
154  private $stackingMode;
155 
160  private $custom;
161 
168  public function getId()
169  {
170  return $this->id;
171  }
172 
179  public function getVersion()
180  {
181  return $this->version;
182  }
183 
190  public function getCreatedAt()
191  {
192  return $this->createdAt;
193  }
194 
201  public function getLastModifiedAt()
202  {
203  return $this->lastModifiedAt;
204  }
205 
212  public function getLastModifiedBy()
213  {
214  return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
215  }
216 
223  public function getCreatedBy()
224  {
225  return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
226  }
227 
234  public function getName()
235  {
236  return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
237  }
238 
245  public function getKey()
246  {
247  return $this->key;
248  }
249 
256  public function getDescription()
257  {
258  return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
259  }
260 
267  public function getValue()
268  {
269  return $this->value instanceof CartDiscountValueBuilder ? $this->value->build() : $this->value;
270  }
271 
278  public function getCartPredicate()
279  {
280  return $this->cartPredicate;
281  }
282 
290  public function getTarget()
291  {
292  return $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target;
293  }
294 
304  public function getSortOrder()
305  {
306  return $this->sortOrder;
307  }
308 
318  public function getStores()
319  {
320  return $this->stores;
321  }
322 
329  public function getIsActive()
330  {
331  return $this->isActive;
332  }
333 
340  public function getValidFrom()
341  {
342  return $this->validFrom;
343  }
344 
351  public function getValidUntil()
352  {
353  return $this->validUntil;
354  }
355 
362  public function getRequiresDiscountCode()
363  {
364  return $this->requiresDiscountCode;
365  }
366 
374  public function getReferences()
375  {
376  return $this->references;
377  }
378 
385  public function getStackingMode()
386  {
387  return $this->stackingMode;
388  }
389 
396  public function getCustom()
397  {
398  return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
399  }
400 
405  public function withId(?string $id)
406  {
407  $this->id = $id;
408 
409  return $this;
410  }
411 
416  public function withVersion(?int $version)
417  {
418  $this->version = $version;
419 
420  return $this;
421  }
422 
427  public function withCreatedAt(?DateTimeImmutable $createdAt)
428  {
429  $this->createdAt = $createdAt;
430 
431  return $this;
432  }
433 
438  public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
439  {
440  $this->lastModifiedAt = $lastModifiedAt;
441 
442  return $this;
443  }
444 
449  public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
450  {
451  $this->lastModifiedBy = $lastModifiedBy;
452 
453  return $this;
454  }
455 
460  public function withCreatedBy(?CreatedBy $createdBy)
461  {
462  $this->createdBy = $createdBy;
463 
464  return $this;
465  }
466 
471  public function withName(?LocalizedString $name)
472  {
473  $this->name = $name;
474 
475  return $this;
476  }
477 
482  public function withKey(?string $key)
483  {
484  $this->key = $key;
485 
486  return $this;
487  }
488 
493  public function withDescription(?LocalizedString $description)
494  {
495  $this->description = $description;
496 
497  return $this;
498  }
499 
504  public function withValue(?CartDiscountValue $value)
505  {
506  $this->value = $value;
507 
508  return $this;
509  }
510 
515  public function withCartPredicate(?string $cartPredicate)
516  {
517  $this->cartPredicate = $cartPredicate;
518 
519  return $this;
520  }
521 
526  public function withTarget(?CartDiscountTarget $target)
527  {
528  $this->target = $target;
529 
530  return $this;
531  }
532 
537  public function withSortOrder(?string $sortOrder)
538  {
539  $this->sortOrder = $sortOrder;
540 
541  return $this;
542  }
543 
548  public function withStores(?StoreKeyReferenceCollection $stores)
549  {
550  $this->stores = $stores;
551 
552  return $this;
553  }
554 
559  public function withIsActive(?bool $isActive)
560  {
561  $this->isActive = $isActive;
562 
563  return $this;
564  }
565 
570  public function withValidFrom(?DateTimeImmutable $validFrom)
571  {
572  $this->validFrom = $validFrom;
573 
574  return $this;
575  }
576 
581  public function withValidUntil(?DateTimeImmutable $validUntil)
582  {
583  $this->validUntil = $validUntil;
584 
585  return $this;
586  }
587 
592  public function withRequiresDiscountCode(?bool $requiresDiscountCode)
593  {
594  $this->requiresDiscountCode = $requiresDiscountCode;
595 
596  return $this;
597  }
598 
603  public function withReferences(?ReferenceCollection $references)
604  {
605  $this->references = $references;
606 
607  return $this;
608  }
609 
614  public function withStackingMode(?string $stackingMode)
615  {
616  $this->stackingMode = $stackingMode;
617 
618  return $this;
619  }
620 
625  public function withCustom(?CustomFields $custom)
626  {
627  $this->custom = $custom;
628 
629  return $this;
630  }
631 
636  public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
637  {
638  $this->lastModifiedBy = $lastModifiedBy;
639 
640  return $this;
641  }
642 
647  public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
648  {
649  $this->createdBy = $createdBy;
650 
651  return $this;
652  }
653 
658  public function withNameBuilder(?LocalizedStringBuilder $name)
659  {
660  $this->name = $name;
661 
662  return $this;
663  }
664 
669  public function withDescriptionBuilder(?LocalizedStringBuilder $description)
670  {
671  $this->description = $description;
672 
673  return $this;
674  }
675 
681  {
682  $this->value = $value;
683 
684  return $this;
685  }
686 
692  {
693  $this->target = $target;
694 
695  return $this;
696  }
697 
702  public function withCustomBuilder(?CustomFieldsBuilder $custom)
703  {
704  $this->custom = $custom;
705 
706  return $this;
707  }
708 
709  public function build(): CartDiscount
710  {
711  return new CartDiscountModel(
712  $this->id,
713  $this->version,
714  $this->createdAt,
715  $this->lastModifiedAt,
716  $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
717  $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy,
718  $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
719  $this->key,
720  $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
721  $this->value instanceof CartDiscountValueBuilder ? $this->value->build() : $this->value,
722  $this->cartPredicate,
723  $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target,
724  $this->sortOrder,
725  $this->stores,
726  $this->isActive,
727  $this->validFrom,
728  $this->validUntil,
729  $this->requiresDiscountCode,
730  $this->references,
731  $this->stackingMode,
732  $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom
733  );
734  }
735 
736  public static function of(): CartDiscountBuilder
737  {
738  return new self();
739  }
740 }
withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
withDescriptionBuilder(?LocalizedStringBuilder $description)