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
193 public function getMaxApplications()
194 {
195 return $this->maxApplications;
196 }
197
206 {
207 return $this->maxApplicationsPerCustomer;
208 }
209
216 public function getCustom()
217 {
218 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
219 }
220
227 public function getGroups()
228 {
229 return $this->groups;
230 }
231
238 public function getValidFrom()
239 {
240 return $this->validFrom;
241 }
242
249 public function getValidUntil()
250 {
251 return $this->validUntil;
252 }
253
258 public function withKey(?string $key)
259 {
260 $this->key = $key;
261
262 return $this;
263 }
264
269 public function withName(?LocalizedString $name)
270 {
271 $this->name = $name;
272
273 return $this;
274 }
275
280 public function withDescription(?LocalizedString $description)
281 {
282 $this->description = $description;
283
284 return $this;
285 }
286
291 public function withCode(?string $code)
292 {
293 $this->code = $code;
294
295 return $this;
296 }
297
303 {
304 $this->cartDiscounts = $cartDiscounts;
305
306 return $this;
307 }
308
313 public function withCartPredicate(?string $cartPredicate)
314 {
315 $this->cartPredicate = $cartPredicate;
316
317 return $this;
318 }
319
324 public function withIsActive(?bool $isActive)
325 {
326 $this->isActive = $isActive;
327
328 return $this;
329 }
330
335 public function withMaxApplications(?int $maxApplications)
336 {
337 $this->maxApplications = $maxApplications;
338
339 return $this;
340 }
341
346 public function withMaxApplicationsPerCustomer(?int $maxApplicationsPerCustomer)
347 {
348 $this->maxApplicationsPerCustomer = $maxApplicationsPerCustomer;
349
350 return $this;
351 }
352
357 public function withCustom(?CustomFieldsDraft $custom)
358 {
359 $this->custom = $custom;
360
361 return $this;
362 }
363
368 public function withGroups(?array $groups)
369 {
370 $this->groups = $groups;
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
402 {
403 $this->name = $name;
404
405 return $this;
406 }
407
412 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
413 {
414 $this->description = $description;
415
416 return $this;
417 }
418
424 {
425 $this->custom = $custom;
426
427 return $this;
428 }
429
430 public function build(): DiscountCodeDraft
431 {
432 return new DiscountCodeDraftModel(
433 $this->key,
434 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
435 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
436 $this->code,
437 $this->cartDiscounts,
438 $this->cartPredicate,
439 $this->isActive,
440 $this->maxApplications,
441 $this->maxApplicationsPerCustomer,
442 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
443 $this->groups,
444 $this->validFrom,
445 $this->validUntil
446 );
447 }
448
449 public static function of(): DiscountCodeDraftBuilder
450 {
451 return new self();
452 }
453}
withCartDiscounts(?CartDiscountResourceIdentifierCollection $cartDiscounts)