commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
ShippingRateDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class ShippingRateDraftBuilder implements Builder
24 {
29  private $price;
30 
35  private $freeAbove;
36 
41  private $tiers;
42 
47  public function getPrice()
48  {
49  return $this->price instanceof MoneyBuilder ? $this->price->build() : $this->price;
50  }
51 
56  public function getFreeAbove()
57  {
58  return $this->freeAbove instanceof MoneyBuilder ? $this->freeAbove->build() : $this->freeAbove;
59  }
60 
65  public function getTiers()
66  {
67  return $this->tiers;
68  }
69 
74  public function withPrice(?Money $price)
75  {
76  $this->price = $price;
77 
78  return $this;
79  }
80 
85  public function withFreeAbove(?Money $freeAbove)
86  {
87  $this->freeAbove = $freeAbove;
88 
89  return $this;
90  }
91 
96  public function withTiers(?ShippingRatePriceTierCollection $tiers)
97  {
98  $this->tiers = $tiers;
99 
100  return $this;
101  }
102 
107  public function withPriceBuilder(?MoneyBuilder $price)
108  {
109  $this->price = $price;
110 
111  return $this;
112  }
113 
118  public function withFreeAboveBuilder(?MoneyBuilder $freeAbove)
119  {
120  $this->freeAbove = $freeAbove;
121 
122  return $this;
123  }
124 
125  public function build(): ShippingRateDraft
126  {
127  return new ShippingRateDraftModel(
128  $this->price instanceof MoneyBuilder ? $this->price->build() : $this->price,
129  $this->freeAbove instanceof MoneyBuilder ? $this->freeAbove->build() : $this->freeAbove,
130  $this->tiers
131  );
132  }
133 
134  public static function of(): ShippingRateDraftBuilder
135  {
136  return new self();
137  }
138 }