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
114 public function getKey()
115 {
116 return $this->key;
117 }
118
125 public function getName()
126 {
127 return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
128 }
129
136 public function getDescription()
137 {
138 return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
139 }
140
148 public function getCode()
149 {
150 return $this->code;
151 }
152
159 public function getCartDiscounts()
160 {
161 return $this->cartDiscounts;
162 }
163
170 public function getCartPredicate()
171 {
172 return $this->cartPredicate;
173 }
174
181 public function getIsActive()
182 {
183 return $this->isActive;
184 }
185
194 public function getMaxApplications()
195 {
196 return $this->maxApplications;
197 }
198
208 {
209 return $this->maxApplicationsPerCustomer;
210 }
211
218 public function getCustom()
219 {
220 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
221 }
222
229 public function getGroups()
230 {
231 return $this->groups;
232 }
233
240 public function getValidFrom()
241 {
242 return $this->validFrom;
243 }
244
251 public function getValidUntil()
252 {
253 return $this->validUntil;
254 }
255
260 public function withKey(?string $key)
261 {
262 $this->key = $key;
263
264 return $this;
265 }
266
271 public function withName(?LocalizedString $name)
272 {
273 $this->name = $name;
274
275 return $this;
276 }
277
282 public function withDescription(?LocalizedString $description)
283 {
284 $this->description = $description;
285
286 return $this;
287 }
288
293 public function withCode(?string $code)
294 {
295 $this->code = $code;
296
297 return $this;
298 }
299
305 {
306 $this->cartDiscounts = $cartDiscounts;
307
308 return $this;
309 }
310
315 public function withCartPredicate(?string $cartPredicate)
316 {
317 $this->cartPredicate = $cartPredicate;
318
319 return $this;
320 }
321
326 public function withIsActive(?bool $isActive)
327 {
328 $this->isActive = $isActive;
329
330 return $this;
331 }
332
337 public function withMaxApplications(?int $maxApplications)
338 {
339 $this->maxApplications = $maxApplications;
340
341 return $this;
342 }
343
348 public function withMaxApplicationsPerCustomer(?int $maxApplicationsPerCustomer)
349 {
350 $this->maxApplicationsPerCustomer = $maxApplicationsPerCustomer;
351
352 return $this;
353 }
354
359 public function withCustom(?CustomFieldsDraft $custom)
360 {
361 $this->custom = $custom;
362
363 return $this;
364 }
365
370 public function withGroups(?array $groups)
371 {
372 $this->groups = $groups;
373
374 return $this;
375 }
376
381 public function withValidFrom(?DateTimeImmutable $validFrom)
382 {
383 $this->validFrom = $validFrom;
384
385 return $this;
386 }
387
392 public function withValidUntil(?DateTimeImmutable $validUntil)
393 {
394 $this->validUntil = $validUntil;
395
396 return $this;
397 }
398
404 {
405 $this->name = $name;
406
407 return $this;
408 }
409
414 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
415 {
416 $this->description = $description;
417
418 return $this;
419 }
420
426 {
427 $this->custom = $custom;
428
429 return $this;
430 }
431
432 public function build(): DiscountCodeDraft
433 {
434 return new DiscountCodeDraftModel(
435 $this->key,
436 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
437 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
438 $this->code,
439 $this->cartDiscounts,
440 $this->cartPredicate,
441 $this->isActive,
442 $this->maxApplications,
443 $this->maxApplicationsPerCustomer,
444 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
445 $this->groups,
446 $this->validFrom,
447 $this->validUntil
448 );
449 }
450
451 public static function of(): DiscountCodeDraftBuilder
452 {
453 return new self();
454 }
455}
withCartDiscounts(?CartDiscountResourceIdentifierCollection $cartDiscounts)