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
22use DateTimeImmutable;
23use stdClass;
24
28final class PriceDraftBuilder implements Builder
29{
34 private $key;
35
40 private $value;
41
46 private $country;
47
52 private $customerGroup;
53
58 private $channel;
59
64 private $validFrom;
65
70 private $validUntil;
71
76 private $discounted;
77
82 private $tiers;
83
88 private $custom;
89
96 public function getKey()
97 {
98 return $this->key;
99 }
100
108 public function getValue()
109 {
110 return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value;
111 }
112
119 public function getCountry()
120 {
121 return $this->country;
122 }
123
130 public function getCustomerGroup()
131 {
132 return $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup;
133 }
134
141 public function getChannel()
142 {
143 return $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel;
144 }
145
152 public function getValidFrom()
153 {
154 return $this->validFrom;
155 }
156
163 public function getValidUntil()
164 {
165 return $this->validUntil;
166 }
167
181 public function getDiscounted()
182 {
183 return $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted;
184 }
185
193 public function getTiers()
194 {
195 return $this->tiers;
196 }
197
204 public function getCustom()
205 {
206 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
207 }
208
213 public function withKey(?string $key)
214 {
215 $this->key = $key;
216
217 return $this;
218 }
219
224 public function withValue(?Money $value)
225 {
226 $this->value = $value;
227
228 return $this;
229 }
230
235 public function withCountry(?string $country)
236 {
237 $this->country = $country;
238
239 return $this;
240 }
241
246 public function withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
247 {
248 $this->customerGroup = $customerGroup;
249
250 return $this;
251 }
252
257 public function withChannel(?ChannelResourceIdentifier $channel)
258 {
259 $this->channel = $channel;
260
261 return $this;
262 }
263
268 public function withValidFrom(?DateTimeImmutable $validFrom)
269 {
270 $this->validFrom = $validFrom;
271
272 return $this;
273 }
274
279 public function withValidUntil(?DateTimeImmutable $validUntil)
280 {
281 $this->validUntil = $validUntil;
282
283 return $this;
284 }
285
290 public function withDiscounted(?DiscountedPriceDraft $discounted)
291 {
292 $this->discounted = $discounted;
293
294 return $this;
295 }
296
301 public function withTiers(?PriceTierDraftCollection $tiers)
302 {
303 $this->tiers = $tiers;
304
305 return $this;
306 }
307
312 public function withCustom(?CustomFieldsDraft $custom)
313 {
314 $this->custom = $custom;
315
316 return $this;
317 }
318
323 public function withValueBuilder(?MoneyBuilder $value)
324 {
325 $this->value = $value;
326
327 return $this;
328 }
329
335 {
336 $this->customerGroup = $customerGroup;
337
338 return $this;
339 }
340
346 {
347 $this->channel = $channel;
348
349 return $this;
350 }
351
357 {
358 $this->discounted = $discounted;
359
360 return $this;
361 }
362
368 {
369 $this->custom = $custom;
370
371 return $this;
372 }
373
374 public function build(): PriceDraft
375 {
376 return new PriceDraftModel(
377 $this->key,
378 $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value,
379 $this->country,
380 $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup,
381 $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel,
382 $this->validFrom,
383 $this->validUntil,
384 $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted,
385 $this->tiers,
386 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
387 );
388 }
389
390 public static function of(): PriceDraftBuilder
391 {
392 return new self();
393 }
394}
withDiscounted(?DiscountedPriceDraft $discounted)
withCustomerGroupBuilder(?CustomerGroupResourceIdentifierBuilder $customerGroup)
withChannel(?ChannelResourceIdentifier $channel)
withChannelBuilder(?ChannelResourceIdentifierBuilder $channel)
withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
withDiscountedBuilder(?DiscountedPriceDraftBuilder $discounted)
withCustomBuilder(?CustomFieldsDraftBuilder $custom)