commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ShippingDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use stdClass;
24 
28 final class ShippingDraftBuilder implements Builder
29 {
34  private $key;
35 
40  private $shippingMethod;
41 
46  private $shippingAddress;
47 
52  private $shippingRateInput;
53 
58  private $externalTaxRate;
59 
64  private $deliveries;
65 
70  private $custom;
71 
78  public function getKey()
79  {
80  return $this->key;
81  }
82 
89  public function getShippingMethod()
90  {
91  return $this->shippingMethod instanceof ShippingMethodReferenceBuilder ? $this->shippingMethod->build() : $this->shippingMethod;
92  }
93 
100  public function getShippingAddress()
101  {
102  return $this->shippingAddress instanceof BaseAddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress;
103  }
104 
117  public function getShippingRateInput()
118  {
119  return $this->shippingRateInput instanceof ShippingRateInputDraftBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput;
120  }
121 
128  public function getExternalTaxRate()
129  {
130  return $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate;
131  }
132 
139  public function getDeliveries()
140  {
141  return $this->deliveries;
142  }
143 
150  public function getCustom()
151  {
152  return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
153  }
154 
159  public function withKey(?string $key)
160  {
161  $this->key = $key;
162 
163  return $this;
164  }
165 
170  public function withShippingMethod(?ShippingMethodReference $shippingMethod)
171  {
172  $this->shippingMethod = $shippingMethod;
173 
174  return $this;
175  }
176 
181  public function withShippingAddress(?BaseAddress $shippingAddress)
182  {
183  $this->shippingAddress = $shippingAddress;
184 
185  return $this;
186  }
187 
192  public function withShippingRateInput(?ShippingRateInputDraft $shippingRateInput)
193  {
194  $this->shippingRateInput = $shippingRateInput;
195 
196  return $this;
197  }
198 
203  public function withExternalTaxRate(?ExternalTaxRateDraft $externalTaxRate)
204  {
205  $this->externalTaxRate = $externalTaxRate;
206 
207  return $this;
208  }
209 
214  public function withDeliveries(?DeliveryDraftCollection $deliveries)
215  {
216  $this->deliveries = $deliveries;
217 
218  return $this;
219  }
220 
225  public function withCustom(?CustomFieldsDraft $custom)
226  {
227  $this->custom = $custom;
228 
229  return $this;
230  }
231 
237  {
238  $this->shippingMethod = $shippingMethod;
239 
240  return $this;
241  }
242 
247  public function withShippingAddressBuilder(?BaseAddressBuilder $shippingAddress)
248  {
249  $this->shippingAddress = $shippingAddress;
250 
251  return $this;
252  }
253 
258  public function withShippingRateInputBuilder(?ShippingRateInputDraftBuilder $shippingRateInput)
259  {
260  $this->shippingRateInput = $shippingRateInput;
261 
262  return $this;
263  }
264 
269  public function withExternalTaxRateBuilder(?ExternalTaxRateDraftBuilder $externalTaxRate)
270  {
271  $this->externalTaxRate = $externalTaxRate;
272 
273  return $this;
274  }
275 
280  public function withCustomBuilder(?CustomFieldsDraftBuilder $custom)
281  {
282  $this->custom = $custom;
283 
284  return $this;
285  }
286 
287  public function build(): ShippingDraft
288  {
289  return new ShippingDraftModel(
290  $this->key,
291  $this->shippingMethod instanceof ShippingMethodReferenceBuilder ? $this->shippingMethod->build() : $this->shippingMethod,
292  $this->shippingAddress instanceof BaseAddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress,
293  $this->shippingRateInput instanceof ShippingRateInputDraftBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput,
294  $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate,
295  $this->deliveries,
296  $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
297  );
298  }
299 
300  public static function of(): ShippingDraftBuilder
301  {
302  return new self();
303  }
304 }
withExternalTaxRateBuilder(?ExternalTaxRateDraftBuilder $externalTaxRate)
withExternalTaxRate(?ExternalTaxRateDraft $externalTaxRate)
withCustomBuilder(?CustomFieldsDraftBuilder $custom)
withShippingMethodBuilder(?ShippingMethodReferenceBuilder $shippingMethod)
withShippingRateInput(?ShippingRateInputDraft $shippingRateInput)
withShippingRateInputBuilder(?ShippingRateInputDraftBuilder $shippingRateInput)
withShippingAddressBuilder(?BaseAddressBuilder $shippingAddress)
withDeliveries(?DeliveryDraftCollection $deliveries)
withShippingMethod(?ShippingMethodReference $shippingMethod)