commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CartDiscountDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
29final class CartDiscountDraftBuilder implements Builder
30{
35 private $name;
36
41 private $key;
42
47 private $description;
48
53 private $value;
54
59 private $cartPredicate;
60
65 private $target;
66
71 private $sortOrder;
72
77 private $stores;
78
83 private $isActive;
84
89 private $validFrom;
90
95 private $validUntil;
96
101 private $requiresDiscountCode;
102
107 private $stackingMode;
108
113 private $custom;
114
119 private $discountGroup;
120
127 public function getName()
128 {
129 return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
130 }
131
138 public function getKey()
139 {
140 return $this->key;
141 }
142
149 public function getDescription()
150 {
151 return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
152 }
153
160 public function getValue()
161 {
162 return $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value;
163 }
164
171 public function getCartPredicate()
172 {
173 return $this->cartPredicate;
174 }
175
183 public function getTarget()
184 {
185 return $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target;
186 }
187
196 public function getSortOrder()
197 {
198 return $this->sortOrder;
199 }
200
212 public function getStores()
213 {
214 return $this->stores;
215 }
216
224 public function getIsActive()
225 {
226 return $this->isActive;
227 }
228
235 public function getValidFrom()
236 {
237 return $this->validFrom;
238 }
239
246 public function getValidUntil()
247 {
248 return $this->validUntil;
249 }
250
257 public function getRequiresDiscountCode()
258 {
259 return $this->requiresDiscountCode;
260 }
261
268 public function getStackingMode()
269 {
270 return $this->stackingMode;
271 }
272
279 public function getCustom()
280 {
281 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
282 }
283
290 public function getDiscountGroup()
291 {
292 return $this->discountGroup instanceof DiscountGroupResourceIdentifierBuilder ? $this->discountGroup->build() : $this->discountGroup;
293 }
294
299 public function withName(?LocalizedString $name)
300 {
301 $this->name = $name;
302
303 return $this;
304 }
305
310 public function withKey(?string $key)
311 {
312 $this->key = $key;
313
314 return $this;
315 }
316
321 public function withDescription(?LocalizedString $description)
322 {
323 $this->description = $description;
324
325 return $this;
326 }
327
332 public function withValue(?CartDiscountValueDraft $value)
333 {
334 $this->value = $value;
335
336 return $this;
337 }
338
343 public function withCartPredicate(?string $cartPredicate)
344 {
345 $this->cartPredicate = $cartPredicate;
346
347 return $this;
348 }
349
354 public function withTarget(?CartDiscountTarget $target)
355 {
356 $this->target = $target;
357
358 return $this;
359 }
360
365 public function withSortOrder(?string $sortOrder)
366 {
367 $this->sortOrder = $sortOrder;
368
369 return $this;
370 }
371
377 {
378 $this->stores = $stores;
379
380 return $this;
381 }
382
387 public function withIsActive(?bool $isActive)
388 {
389 $this->isActive = $isActive;
390
391 return $this;
392 }
393
398 public function withValidFrom(?DateTimeImmutable $validFrom)
399 {
400 $this->validFrom = $validFrom;
401
402 return $this;
403 }
404
409 public function withValidUntil(?DateTimeImmutable $validUntil)
410 {
411 $this->validUntil = $validUntil;
412
413 return $this;
414 }
415
420 public function withRequiresDiscountCode(?bool $requiresDiscountCode)
421 {
422 $this->requiresDiscountCode = $requiresDiscountCode;
423
424 return $this;
425 }
426
431 public function withStackingMode(?string $stackingMode)
432 {
433 $this->stackingMode = $stackingMode;
434
435 return $this;
436 }
437
442 public function withCustom(?CustomFieldsDraft $custom)
443 {
444 $this->custom = $custom;
445
446 return $this;
447 }
448
453 public function withDiscountGroup(?DiscountGroupResourceIdentifier $discountGroup)
454 {
455 $this->discountGroup = $discountGroup;
456
457 return $this;
458 }
459
465 {
466 $this->name = $name;
467
468 return $this;
469 }
470
475 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
476 {
477 $this->description = $description;
478
479 return $this;
480 }
481
487 {
488 $this->value = $value;
489
490 return $this;
491 }
492
498 {
499 $this->target = $target;
500
501 return $this;
502 }
503
509 {
510 $this->custom = $custom;
511
512 return $this;
513 }
514
520 {
521 $this->discountGroup = $discountGroup;
522
523 return $this;
524 }
525
526 public function build(): CartDiscountDraft
527 {
528 return new CartDiscountDraftModel(
529 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
530 $this->key,
531 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
532 $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value,
533 $this->cartPredicate,
534 $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target,
535 $this->sortOrder,
536 $this->stores,
537 $this->isActive,
538 $this->validFrom,
539 $this->validUntil,
540 $this->requiresDiscountCode,
541 $this->stackingMode,
542 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
543 $this->discountGroup instanceof DiscountGroupResourceIdentifierBuilder ? $this->discountGroup->build() : $this->discountGroup
544 );
545 }
546
547 public static function of(): CartDiscountDraftBuilder
548 {
549 return new self();
550 }
551}
withDiscountGroup(?DiscountGroupResourceIdentifier $discountGroup)
withDiscountGroupBuilder(?DiscountGroupResourceIdentifierBuilder $discountGroup)