commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
PriceDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
22 use DateTimeImmutable;
23 use stdClass;
24 
28 final 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 
107  public function getValue()
108  {
109  return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value;
110  }
111 
118  public function getCountry()
119  {
120  return $this->country;
121  }
122 
129  public function getCustomerGroup()
130  {
131  return $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup;
132  }
133 
140  public function getChannel()
141  {
142  return $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel;
143  }
144 
151  public function getValidFrom()
152  {
153  return $this->validFrom;
154  }
155 
162  public function getValidUntil()
163  {
164  return $this->validUntil;
165  }
166 
180  public function getDiscounted()
181  {
182  return $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted;
183  }
184 
192  public function getTiers()
193  {
194  return $this->tiers;
195  }
196 
203  public function getCustom()
204  {
205  return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
206  }
207 
212  public function withKey(?string $key)
213  {
214  $this->key = $key;
215 
216  return $this;
217  }
218 
223  public function withValue(?Money $value)
224  {
225  $this->value = $value;
226 
227  return $this;
228  }
229 
234  public function withCountry(?string $country)
235  {
236  $this->country = $country;
237 
238  return $this;
239  }
240 
245  public function withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
246  {
247  $this->customerGroup = $customerGroup;
248 
249  return $this;
250  }
251 
256  public function withChannel(?ChannelResourceIdentifier $channel)
257  {
258  $this->channel = $channel;
259 
260  return $this;
261  }
262 
267  public function withValidFrom(?DateTimeImmutable $validFrom)
268  {
269  $this->validFrom = $validFrom;
270 
271  return $this;
272  }
273 
278  public function withValidUntil(?DateTimeImmutable $validUntil)
279  {
280  $this->validUntil = $validUntil;
281 
282  return $this;
283  }
284 
289  public function withDiscounted(?DiscountedPriceDraft $discounted)
290  {
291  $this->discounted = $discounted;
292 
293  return $this;
294  }
295 
300  public function withTiers(?PriceTierDraftCollection $tiers)
301  {
302  $this->tiers = $tiers;
303 
304  return $this;
305  }
306 
311  public function withCustom(?CustomFieldsDraft $custom)
312  {
313  $this->custom = $custom;
314 
315  return $this;
316  }
317 
322  public function withValueBuilder(?MoneyBuilder $value)
323  {
324  $this->value = $value;
325 
326  return $this;
327  }
328 
334  {
335  $this->customerGroup = $customerGroup;
336 
337  return $this;
338  }
339 
345  {
346  $this->channel = $channel;
347 
348  return $this;
349  }
350 
356  {
357  $this->discounted = $discounted;
358 
359  return $this;
360  }
361 
366  public function withCustomBuilder(?CustomFieldsDraftBuilder $custom)
367  {
368  $this->custom = $custom;
369 
370  return $this;
371  }
372 
373  public function build(): PriceDraft
374  {
375  return new PriceDraftModel(
376  $this->key,
377  $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value,
378  $this->country,
379  $this->customerGroup instanceof CustomerGroupResourceIdentifierBuilder ? $this->customerGroup->build() : $this->customerGroup,
380  $this->channel instanceof ChannelResourceIdentifierBuilder ? $this->channel->build() : $this->channel,
381  $this->validFrom,
382  $this->validUntil,
383  $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted,
384  $this->tiers,
385  $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
386  );
387  }
388 
389  public static function of(): PriceDraftBuilder
390  {
391  return new self();
392  }
393 }
withDiscounted(?DiscountedPriceDraft $discounted)
withCustomerGroupBuilder(?CustomerGroupResourceIdentifierBuilder $customerGroup)
withChannel(?ChannelResourceIdentifier $channel)
withChannelBuilder(?ChannelResourceIdentifierBuilder $channel)
withCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
withDiscountedBuilder(?DiscountedPriceDraftBuilder $discounted)
withCustomBuilder(?CustomFieldsDraftBuilder $custom)