commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DiscountCodeBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
28 use DateTimeImmutable;
29 use stdClass;
30 
34 final class DiscountCodeBuilder implements Builder
35 {
40  private $id;
41 
46  private $version;
47 
52  private $createdAt;
53 
58  private $lastModifiedAt;
59 
64  private $key;
65 
70  private $lastModifiedBy;
71 
76  private $createdBy;
77 
82  private $name;
83 
88  private $description;
89 
94  private $code;
95 
100  private $cartDiscounts;
101 
106  private $cartPredicate;
107 
112  private $isActive;
113 
118  private $references;
119 
124  private $maxApplications;
125 
130  private $maxApplicationsPerCustomer;
131 
136  private $custom;
137 
142  private $groups;
143 
148  private $validFrom;
149 
154  private $validUntil;
155 
160  private $applicationVersion;
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 getKey()
213  {
214  return $this->key;
215  }
216 
223  public function getLastModifiedBy()
224  {
225  return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
226  }
227 
234  public function getCreatedBy()
235  {
236  return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
237  }
238 
245  public function getName()
246  {
247  return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
248  }
249 
256  public function getDescription()
257  {
258  return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
259  }
260 
267  public function getCode()
268  {
269  return $this->code;
270  }
271 
278  public function getCartDiscounts()
279  {
280  return $this->cartDiscounts;
281  }
282 
289  public function getCartPredicate()
290  {
291  return $this->cartPredicate;
292  }
293 
300  public function getIsActive()
301  {
302  return $this->isActive;
303  }
304 
312  public function getReferences()
313  {
314  return $this->references;
315  }
316 
324  public function getMaxApplications()
325  {
326  return $this->maxApplications;
327  }
328 
337  {
338  return $this->maxApplicationsPerCustomer;
339  }
340 
347  public function getCustom()
348  {
349  return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
350  }
351 
358  public function getGroups()
359  {
360  return $this->groups;
361  }
362 
369  public function getValidFrom()
370  {
371  return $this->validFrom;
372  }
373 
380  public function getValidUntil()
381  {
382  return $this->validUntil;
383  }
384 
392  public function getApplicationVersion()
393  {
394  return $this->applicationVersion;
395  }
396 
401  public function withId(?string $id)
402  {
403  $this->id = $id;
404 
405  return $this;
406  }
407 
412  public function withVersion(?int $version)
413  {
414  $this->version = $version;
415 
416  return $this;
417  }
418 
423  public function withCreatedAt(?DateTimeImmutable $createdAt)
424  {
425  $this->createdAt = $createdAt;
426 
427  return $this;
428  }
429 
434  public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
435  {
436  $this->lastModifiedAt = $lastModifiedAt;
437 
438  return $this;
439  }
440 
445  public function withKey(?string $key)
446  {
447  $this->key = $key;
448 
449  return $this;
450  }
451 
456  public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
457  {
458  $this->lastModifiedBy = $lastModifiedBy;
459 
460  return $this;
461  }
462 
467  public function withCreatedBy(?CreatedBy $createdBy)
468  {
469  $this->createdBy = $createdBy;
470 
471  return $this;
472  }
473 
478  public function withName(?LocalizedString $name)
479  {
480  $this->name = $name;
481 
482  return $this;
483  }
484 
489  public function withDescription(?LocalizedString $description)
490  {
491  $this->description = $description;
492 
493  return $this;
494  }
495 
500  public function withCode(?string $code)
501  {
502  $this->code = $code;
503 
504  return $this;
505  }
506 
511  public function withCartDiscounts(?CartDiscountReferenceCollection $cartDiscounts)
512  {
513  $this->cartDiscounts = $cartDiscounts;
514 
515  return $this;
516  }
517 
522  public function withCartPredicate(?string $cartPredicate)
523  {
524  $this->cartPredicate = $cartPredicate;
525 
526  return $this;
527  }
528 
533  public function withIsActive(?bool $isActive)
534  {
535  $this->isActive = $isActive;
536 
537  return $this;
538  }
539 
544  public function withReferences(?ReferenceCollection $references)
545  {
546  $this->references = $references;
547 
548  return $this;
549  }
550 
555  public function withMaxApplications(?int $maxApplications)
556  {
557  $this->maxApplications = $maxApplications;
558 
559  return $this;
560  }
561 
566  public function withMaxApplicationsPerCustomer(?int $maxApplicationsPerCustomer)
567  {
568  $this->maxApplicationsPerCustomer = $maxApplicationsPerCustomer;
569 
570  return $this;
571  }
572 
577  public function withCustom(?CustomFields $custom)
578  {
579  $this->custom = $custom;
580 
581  return $this;
582  }
583 
588  public function withGroups(?array $groups)
589  {
590  $this->groups = $groups;
591 
592  return $this;
593  }
594 
599  public function withValidFrom(?DateTimeImmutable $validFrom)
600  {
601  $this->validFrom = $validFrom;
602 
603  return $this;
604  }
605 
610  public function withValidUntil(?DateTimeImmutable $validUntil)
611  {
612  $this->validUntil = $validUntil;
613 
614  return $this;
615  }
616 
621  public function withApplicationVersion(?int $applicationVersion)
622  {
623  $this->applicationVersion = $applicationVersion;
624 
625  return $this;
626  }
627 
632  public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
633  {
634  $this->lastModifiedBy = $lastModifiedBy;
635 
636  return $this;
637  }
638 
643  public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
644  {
645  $this->createdBy = $createdBy;
646 
647  return $this;
648  }
649 
654  public function withNameBuilder(?LocalizedStringBuilder $name)
655  {
656  $this->name = $name;
657 
658  return $this;
659  }
660 
665  public function withDescriptionBuilder(?LocalizedStringBuilder $description)
666  {
667  $this->description = $description;
668 
669  return $this;
670  }
671 
676  public function withCustomBuilder(?CustomFieldsBuilder $custom)
677  {
678  $this->custom = $custom;
679 
680  return $this;
681  }
682 
683  public function build(): DiscountCode
684  {
685  return new DiscountCodeModel(
686  $this->id,
687  $this->version,
688  $this->createdAt,
689  $this->lastModifiedAt,
690  $this->key,
691  $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
692  $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy,
693  $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
694  $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
695  $this->code,
696  $this->cartDiscounts,
697  $this->cartPredicate,
698  $this->isActive,
699  $this->references,
700  $this->maxApplications,
701  $this->maxApplicationsPerCustomer,
702  $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom,
703  $this->groups,
704  $this->validFrom,
705  $this->validUntil,
706  $this->applicationVersion
707  );
708  }
709 
710  public static function of(): DiscountCodeBuilder
711  {
712  return new self();
713  }
714 }
withDescriptionBuilder(?LocalizedStringBuilder $description)
withCartDiscounts(?CartDiscountReferenceCollection $cartDiscounts)
withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)