commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
PriceDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
24use DateTimeImmutable;
25use stdClass;
26
30final class PriceDraftBuilder implements Builder
31{
36 private $key;
37
42 private $value;
43
48 private $country;
49
54 private $customerGroup;
55
60 private $channel;
61
66 private $validFrom;
67
72 private $validUntil;
73
78 private $discounted;
79
84 private $tiers;
85
90 private $custom;
91
96 private $recurrencePolicy;
97
105 public function getKey()
106 {
107 return $this->key;
108 }
109
117 public function getValue()
118 {
119 return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value;
120 }
121
128 public function getCountry()
129 {
130 return $this->country;
131 }
132
139 public function getCustomerGroup()
140 {
141 return $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup;
142 }
143
150 public function getChannel()
151 {
152 return $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel;
153 }
154
161 public function getValidFrom()
162 {
163 return $this->validFrom;
164 }
165
172 public function getValidUntil()
173 {
174 return $this->validUntil;
175 }
176
190 public function getDiscounted()
191 {
192 return $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted;
193 }
194
202 public function getTiers()
203 {
204 return $this->tiers;
205 }
206
213 public function getCustom()
214 {
215 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
216 }
217
224 public function getRecurrencePolicy()
225 {
226 return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy;
227 }
228
233 public function withKey(?string $key)
234 {
235 $this->key = $key;
236
237 return $this;
238 }
239
244 public function withValue(?Money $value)
245 {
246 $this->value = $value;
247
248 return $this;
249 }
250
255 public function withCountry(?string $country)
256 {
257 $this->country = $country;
258
259 return $this;
260 }
261
266 public function withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
267 {
268 $this->customerGroup = $customerGroup;
269
270 return $this;
271 }
272
277 public function withChannel(?ChannelResourceIdentifier $channel)
278 {
279 $this->channel = $channel;
280
281 return $this;
282 }
283
288 public function withValidFrom(?DateTimeImmutable $validFrom)
289 {
290 $this->validFrom = $validFrom;
291
292 return $this;
293 }
294
299 public function withValidUntil(?DateTimeImmutable $validUntil)
300 {
301 $this->validUntil = $validUntil;
302
303 return $this;
304 }
305
310 public function withDiscounted(?DiscountedPriceDraft $discounted)
311 {
312 $this->discounted = $discounted;
313
314 return $this;
315 }
316
321 public function withTiers(?PriceTierDraftCollection $tiers)
322 {
323 $this->tiers = $tiers;
324
325 return $this;
326 }
327
332 public function withCustom(?CustomFieldsDraft $custom)
333 {
334 $this->custom = $custom;
335
336 return $this;
337 }
338
344 {
345 $this->recurrencePolicy = $recurrencePolicy;
346
347 return $this;
348 }
349
354 public function withValueBuilder(?MoneyBuilder $value)
355 {
356 $this->value = $value;
357
358 return $this;
359 }
360
366 {
367 $this->customerGroup = $customerGroup;
368
369 return $this;
370 }
371
377 {
378 $this->channel = $channel;
379
380 return $this;
381 }
382
388 {
389 $this->discounted = $discounted;
390
391 return $this;
392 }
393
399 {
400 $this->custom = $custom;
401
402 return $this;
403 }
404
410 {
411 $this->recurrencePolicy = $recurrencePolicy;
412
413 return $this;
414 }
415
416 public function build(): PriceDraft
417 {
418 return new PriceDraftModel(
419 $this->key,
420 $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value,
421 $this->country,
422 $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup,
423 $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel,
424 $this->validFrom,
425 $this->validUntil,
426 $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted,
427 $this->tiers,
428 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom,
429 $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy
430 );
431 }
432
433 public static function of(): PriceDraftBuilder
434 {
435 return new self();
436 }
437}
withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy)
withRecurrencePolicyBuilder(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy)
withDiscounted(?DiscountedPriceDraft $discounted)
withCustomerGroupBuilder(?CustomerGroupResourceIdentifierBuilder $customerGroup)
withChannel(?ChannelResourceIdentifier $channel)
withChannelBuilder(?ChannelResourceIdentifierBuilder $channel)
withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
withDiscountedBuilder(?DiscountedPriceDraftBuilder $discounted)
withCustomBuilder(?CustomFieldsDraftBuilder $custom)