commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DiscountCodeBuilder.php
1<?php
2
3declare(strict_types=1);
10
28use DateTimeImmutable;
29use stdClass;
30
34final 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
325 public function getMaxApplications()
326 {
327 return $this->maxApplications;
328 }
329
339 {
340 return $this->maxApplicationsPerCustomer;
341 }
342
349 public function getCustom()
350 {
351 return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
352 }
353
360 public function getGroups()
361 {
362 return $this->groups;
363 }
364
371 public function getValidFrom()
372 {
373 return $this->validFrom;
374 }
375
382 public function getValidUntil()
383 {
384 return $this->validUntil;
385 }
386
394 public function getApplicationVersion()
395 {
396 return $this->applicationVersion;
397 }
398
403 public function withId(?string $id)
404 {
405 $this->id = $id;
406
407 return $this;
408 }
409
414 public function withVersion(?int $version)
415 {
416 $this->version = $version;
417
418 return $this;
419 }
420
425 public function withCreatedAt(?DateTimeImmutable $createdAt)
426 {
427 $this->createdAt = $createdAt;
428
429 return $this;
430 }
431
436 public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
437 {
438 $this->lastModifiedAt = $lastModifiedAt;
439
440 return $this;
441 }
442
447 public function withKey(?string $key)
448 {
449 $this->key = $key;
450
451 return $this;
452 }
453
458 public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
459 {
460 $this->lastModifiedBy = $lastModifiedBy;
461
462 return $this;
463 }
464
469 public function withCreatedBy(?CreatedBy $createdBy)
470 {
471 $this->createdBy = $createdBy;
472
473 return $this;
474 }
475
480 public function withName(?LocalizedString $name)
481 {
482 $this->name = $name;
483
484 return $this;
485 }
486
491 public function withDescription(?LocalizedString $description)
492 {
493 $this->description = $description;
494
495 return $this;
496 }
497
502 public function withCode(?string $code)
503 {
504 $this->code = $code;
505
506 return $this;
507 }
508
513 public function withCartDiscounts(?CartDiscountReferenceCollection $cartDiscounts)
514 {
515 $this->cartDiscounts = $cartDiscounts;
516
517 return $this;
518 }
519
524 public function withCartPredicate(?string $cartPredicate)
525 {
526 $this->cartPredicate = $cartPredicate;
527
528 return $this;
529 }
530
535 public function withIsActive(?bool $isActive)
536 {
537 $this->isActive = $isActive;
538
539 return $this;
540 }
541
546 public function withReferences(?ReferenceCollection $references)
547 {
548 $this->references = $references;
549
550 return $this;
551 }
552
557 public function withMaxApplications(?int $maxApplications)
558 {
559 $this->maxApplications = $maxApplications;
560
561 return $this;
562 }
563
568 public function withMaxApplicationsPerCustomer(?int $maxApplicationsPerCustomer)
569 {
570 $this->maxApplicationsPerCustomer = $maxApplicationsPerCustomer;
571
572 return $this;
573 }
574
579 public function withCustom(?CustomFields $custom)
580 {
581 $this->custom = $custom;
582
583 return $this;
584 }
585
590 public function withGroups(?array $groups)
591 {
592 $this->groups = $groups;
593
594 return $this;
595 }
596
601 public function withValidFrom(?DateTimeImmutable $validFrom)
602 {
603 $this->validFrom = $validFrom;
604
605 return $this;
606 }
607
612 public function withValidUntil(?DateTimeImmutable $validUntil)
613 {
614 $this->validUntil = $validUntil;
615
616 return $this;
617 }
618
623 public function withApplicationVersion(?int $applicationVersion)
624 {
625 $this->applicationVersion = $applicationVersion;
626
627 return $this;
628 }
629
634 public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
635 {
636 $this->lastModifiedBy = $lastModifiedBy;
637
638 return $this;
639 }
640
645 public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
646 {
647 $this->createdBy = $createdBy;
648
649 return $this;
650 }
651
657 {
658 $this->name = $name;
659
660 return $this;
661 }
662
667 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
668 {
669 $this->description = $description;
670
671 return $this;
672 }
673
678 public function withCustomBuilder(?CustomFieldsBuilder $custom)
679 {
680 $this->custom = $custom;
681
682 return $this;
683 }
684
685 public function build(): DiscountCode
686 {
687 return new DiscountCodeModel(
688 $this->id,
689 $this->version,
690 $this->createdAt,
691 $this->lastModifiedAt,
692 $this->key,
693 $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
694 $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy,
695 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
696 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
697 $this->code,
698 $this->cartDiscounts,
699 $this->cartPredicate,
700 $this->isActive,
701 $this->references,
702 $this->maxApplications,
703 $this->maxApplicationsPerCustomer,
704 $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom,
705 $this->groups,
706 $this->validFrom,
707 $this->validUntil,
708 $this->applicationVersion
709 );
710 }
711
712 public static function of(): DiscountCodeBuilder
713 {
714 return new self();
715 }
716}
withCartDiscounts(?CartDiscountReferenceCollection $cartDiscounts)
withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)