commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DiscountCodeDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
21use DateTimeImmutable;
22use stdClass;
23
27final class DiscountCodeDraftBuilder implements Builder
28{
33 private $key;
34
39 private $name;
40
45 private $description;
46
51 private $code;
52
57 private $cartDiscounts;
58
63 private $cartPredicate;
64
69 private $isActive;
70
75 private $maxApplications;
76
81 private $maxApplicationsPerCustomer;
82
87 private $custom;
88
93 private $groups;
94
99 private $validFrom;
100
105 private $validUntil;
106
115 public function getKey()
116 {
117 return $this->key;
118 }
119
126 public function getName()
127 {
128 return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
129 }
130
137 public function getDescription()
138 {
139 return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
140 }
141
150 public function getCode()
151 {
152 return $this->code;
153 }
154
161 public function getCartDiscounts()
162 {
163 return $this->cartDiscounts;
164 }
165
172 public function getCartPredicate()
173 {
174 return $this->cartPredicate;
175 }
176
183 public function getIsActive()
184 {
185 return $this->isActive;
186 }
187
197 public function getMaxApplications()
198 {
199 return $this->maxApplications;
200 }
201
212 {
213 return $this->maxApplicationsPerCustomer;
214 }
215
222 public function getCustom()
223 {
224 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
225 }
226
233 public function getGroups()
234 {
235 return $this->groups;
236 }
237
244 public function getValidFrom()
245 {
246 return $this->validFrom;
247 }
248
255 public function getValidUntil()
256 {
257 return $this->validUntil;
258 }
259
264 public function withKey(?string $key)
265 {
266 $this->key = $key;
267
268 return $this;
269 }
270
275 public function withName(?LocalizedString $name)
276 {
277 $this->name = $name;
278
279 return $this;
280 }
281
286 public function withDescription(?LocalizedString $description)
287 {
288 $this->description = $description;
289
290 return $this;
291 }
292
297 public function withCode(?string $code)
298 {
299 $this->code = $code;
300
301 return $this;
302 }
303
309 {
310 $this->cartDiscounts = $cartDiscounts;
311
312 return $this;
313 }
314
319 public function withCartPredicate(?string $cartPredicate)
320 {
321 $this->cartPredicate = $cartPredicate;
322
323 return $this;
324 }
325
330 public function withIsActive(?bool $isActive)
331 {
332 $this->isActive = $isActive;
333
334 return $this;
335 }
336
341 public function withMaxApplications(?int $maxApplications)
342 {
343 $this->maxApplications = $maxApplications;
344
345 return $this;
346 }
347
352 public function withMaxApplicationsPerCustomer(?int $maxApplicationsPerCustomer)
353 {
354 $this->maxApplicationsPerCustomer = $maxApplicationsPerCustomer;
355
356 return $this;
357 }
358
363 public function withCustom(?CustomFieldsDraft $custom)
364 {
365 $this->custom = $custom;
366
367 return $this;
368 }
369
374 public function withGroups(?array $groups)
375 {
376 $this->groups = $groups;
377
378 return $this;
379 }
380
385 public function withValidFrom(?DateTimeImmutable $validFrom)
386 {
387 $this->validFrom = $validFrom;
388
389 return $this;
390 }
391
396 public function withValidUntil(?DateTimeImmutable $validUntil)
397 {
398 $this->validUntil = $validUntil;
399
400 return $this;
401 }
402
408 {
409 $this->name = $name;
410
411 return $this;
412 }
413
418 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
419 {
420 $this->description = $description;
421
422 return $this;
423 }
424
430 {
431 $this->custom = $custom;
432
433 return $this;
434 }
435
436 public function build(): DiscountCodeDraft
437 {
438 return new DiscountCodeDraftModel(
439 $this->key,
440 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
441 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
442 $this->code,
443 $this->cartDiscounts,
444 $this->cartPredicate,
445 $this->isActive,
446 $this->maxApplications,
447 $this->maxApplicationsPerCustomer,
448 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
449 $this->groups,
450 $this->validFrom,
451 $this->validUntil
452 );
453 }
454
455 public static function of(): DiscountCodeDraftBuilder
456 {
457 return new self();
458 }
459}
withCartDiscounts(?CartDiscountResourceIdentifierCollection $cartDiscounts)