commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ShippingBuilder.php
1<?php
2
3declare(strict_types=1);
10
20use stdClass;
21
25final class ShippingBuilder implements Builder
26{
31 private $shippingKey;
32
37 private $shippingInfo;
38
43 private $shippingAddress;
44
49 private $shippingRateInput;
50
55 private $shippingCustomFields;
56
63 public function getShippingKey()
64 {
65 return $this->shippingKey;
66 }
67
74 public function getShippingInfo()
75 {
76 return $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo;
77 }
78
85 public function getShippingAddress()
86 {
87 return $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress;
88 }
89
102 public function getShippingRateInput()
103 {
104 return $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput;
105 }
106
113 public function getShippingCustomFields()
114 {
115 return $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields;
116 }
117
122 public function withShippingKey(?string $shippingKey)
123 {
124 $this->shippingKey = $shippingKey;
125
126 return $this;
127 }
128
133 public function withShippingInfo(?ShippingInfo $shippingInfo)
134 {
135 $this->shippingInfo = $shippingInfo;
136
137 return $this;
138 }
139
144 public function withShippingAddress(?Address $shippingAddress)
145 {
146 $this->shippingAddress = $shippingAddress;
147
148 return $this;
149 }
150
155 public function withShippingRateInput(?ShippingRateInput $shippingRateInput)
156 {
157 $this->shippingRateInput = $shippingRateInput;
158
159 return $this;
160 }
161
166 public function withShippingCustomFields(?CustomFields $shippingCustomFields)
167 {
168 $this->shippingCustomFields = $shippingCustomFields;
169
170 return $this;
171 }
172
177 public function withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
178 {
179 $this->shippingInfo = $shippingInfo;
180
181 return $this;
182 }
183
188 public function withShippingAddressBuilder(?AddressBuilder $shippingAddress)
189 {
190 $this->shippingAddress = $shippingAddress;
191
192 return $this;
193 }
194
199 public function withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
200 {
201 $this->shippingRateInput = $shippingRateInput;
202
203 return $this;
204 }
205
210 public function withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
211 {
212 $this->shippingCustomFields = $shippingCustomFields;
213
214 return $this;
215 }
216
217 public function build(): Shipping
218 {
219 return new ShippingModel(
220 $this->shippingKey,
221 $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo,
222 $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress,
223 $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput,
224 $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields
225 );
226 }
227
228 public static function of(): ShippingBuilder
229 {
230 return new self();
231 }
232}
withShippingCustomFields(?CustomFields $shippingCustomFields)
withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
withShippingAddressBuilder(?AddressBuilder $shippingAddress)
withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
withShippingRateInput(?ShippingRateInput $shippingRateInput)