commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CartDiscountDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
21 use DateTimeImmutable;
22 use stdClass;
23 
27 final class CartDiscountDraftBuilder implements Builder
28 {
33  private $name;
34 
39  private $key;
40 
45  private $description;
46 
51  private $value;
52 
57  private $cartPredicate;
58 
63  private $target;
64 
69  private $sortOrder;
70 
75  private $stores;
76 
81  private $isActive;
82 
87  private $validFrom;
88 
93  private $validUntil;
94 
99  private $requiresDiscountCode;
100 
105  private $stackingMode;
106 
111  private $custom;
112 
119  public function getName()
120  {
121  return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
122  }
123 
130  public function getKey()
131  {
132  return $this->key;
133  }
134 
141  public function getDescription()
142  {
143  return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
144  }
145 
152  public function getValue()
153  {
154  return $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value;
155  }
156 
163  public function getCartPredicate()
164  {
165  return $this->cartPredicate;
166  }
167 
175  public function getTarget()
176  {
177  return $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target;
178  }
179 
188  public function getSortOrder()
189  {
190  return $this->sortOrder;
191  }
192 
204  public function getStores()
205  {
206  return $this->stores;
207  }
208 
216  public function getIsActive()
217  {
218  return $this->isActive;
219  }
220 
227  public function getValidFrom()
228  {
229  return $this->validFrom;
230  }
231 
238  public function getValidUntil()
239  {
240  return $this->validUntil;
241  }
242 
249  public function getRequiresDiscountCode()
250  {
251  return $this->requiresDiscountCode;
252  }
253 
260  public function getStackingMode()
261  {
262  return $this->stackingMode;
263  }
264 
271  public function getCustom()
272  {
273  return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
274  }
275 
280  public function withName(?LocalizedString $name)
281  {
282  $this->name = $name;
283 
284  return $this;
285  }
286 
291  public function withKey(?string $key)
292  {
293  $this->key = $key;
294 
295  return $this;
296  }
297 
302  public function withDescription(?LocalizedString $description)
303  {
304  $this->description = $description;
305 
306  return $this;
307  }
308 
313  public function withValue(?CartDiscountValueDraft $value)
314  {
315  $this->value = $value;
316 
317  return $this;
318  }
319 
324  public function withCartPredicate(?string $cartPredicate)
325  {
326  $this->cartPredicate = $cartPredicate;
327 
328  return $this;
329  }
330 
335  public function withTarget(?CartDiscountTarget $target)
336  {
337  $this->target = $target;
338 
339  return $this;
340  }
341 
346  public function withSortOrder(?string $sortOrder)
347  {
348  $this->sortOrder = $sortOrder;
349 
350  return $this;
351  }
352 
358  {
359  $this->stores = $stores;
360 
361  return $this;
362  }
363 
368  public function withIsActive(?bool $isActive)
369  {
370  $this->isActive = $isActive;
371 
372  return $this;
373  }
374 
379  public function withValidFrom(?DateTimeImmutable $validFrom)
380  {
381  $this->validFrom = $validFrom;
382 
383  return $this;
384  }
385 
390  public function withValidUntil(?DateTimeImmutable $validUntil)
391  {
392  $this->validUntil = $validUntil;
393 
394  return $this;
395  }
396 
401  public function withRequiresDiscountCode(?bool $requiresDiscountCode)
402  {
403  $this->requiresDiscountCode = $requiresDiscountCode;
404 
405  return $this;
406  }
407 
412  public function withStackingMode(?string $stackingMode)
413  {
414  $this->stackingMode = $stackingMode;
415 
416  return $this;
417  }
418 
423  public function withCustom(?CustomFieldsDraft $custom)
424  {
425  $this->custom = $custom;
426 
427  return $this;
428  }
429 
434  public function withNameBuilder(?LocalizedStringBuilder $name)
435  {
436  $this->name = $name;
437 
438  return $this;
439  }
440 
445  public function withDescriptionBuilder(?LocalizedStringBuilder $description)
446  {
447  $this->description = $description;
448 
449  return $this;
450  }
451 
457  {
458  $this->value = $value;
459 
460  return $this;
461  }
462 
468  {
469  $this->target = $target;
470 
471  return $this;
472  }
473 
478  public function withCustomBuilder(?CustomFieldsDraftBuilder $custom)
479  {
480  $this->custom = $custom;
481 
482  return $this;
483  }
484 
485  public function build(): CartDiscountDraft
486  {
487  return new CartDiscountDraftModel(
488  $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
489  $this->key,
490  $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
491  $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value,
492  $this->cartPredicate,
493  $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target,
494  $this->sortOrder,
495  $this->stores,
496  $this->isActive,
497  $this->validFrom,
498  $this->validUntil,
499  $this->requiresDiscountCode,
500  $this->stackingMode,
501  $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
502  );
503  }
504 
505  public static function of(): CartDiscountDraftBuilder
506  {
507  return new self();
508  }
509 }