commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
ParcelBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use DateTimeImmutable;
19 use stdClass;
20 
24 final class ParcelBuilder implements Builder
25 {
30  private $id;
31 
36  private $createdAt;
37 
42  private $measurements;
43 
48  private $trackingData;
49 
54  private $items;
55 
60  private $custom;
61 
66  public function getId()
67  {
68  return $this->id;
69  }
70 
75  public function getCreatedAt()
76  {
77  return $this->createdAt;
78  }
79 
84  public function getMeasurements()
85  {
86  return $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements;
87  }
88 
93  public function getTrackingData()
94  {
95  return $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData;
96  }
97 
102  public function getItems()
103  {
104  return $this->items;
105  }
106 
113  public function getCustom()
114  {
115  return $this->custom instanceof CustomBuilder ? $this->custom->build() : $this->custom;
116  }
117 
122  public function withId(?string $id)
123  {
124  $this->id = $id;
125 
126  return $this;
127  }
128 
133  public function withCreatedAt(?DateTimeImmutable $createdAt)
134  {
135  $this->createdAt = $createdAt;
136 
137  return $this;
138  }
139 
144  public function withMeasurements(?ParcelMeasurements $measurements)
145  {
146  $this->measurements = $measurements;
147 
148  return $this;
149  }
150 
155  public function withTrackingData(?TrackingData $trackingData)
156  {
157  $this->trackingData = $trackingData;
158 
159  return $this;
160  }
161 
166  public function withItems(?DeliveryItemCollection $items)
167  {
168  $this->items = $items;
169 
170  return $this;
171  }
172 
177  public function withCustom(?Custom $custom)
178  {
179  $this->custom = $custom;
180 
181  return $this;
182  }
183 
188  public function withMeasurementsBuilder(?ParcelMeasurementsBuilder $measurements)
189  {
190  $this->measurements = $measurements;
191 
192  return $this;
193  }
194 
199  public function withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
200  {
201  $this->trackingData = $trackingData;
202 
203  return $this;
204  }
205 
210  public function withCustomBuilder(?CustomBuilder $custom)
211  {
212  $this->custom = $custom;
213 
214  return $this;
215  }
216 
217  public function build(): Parcel
218  {
219  return new ParcelModel(
220  $this->id,
221  $this->createdAt,
222  $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements,
223  $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData,
224  $this->items,
225  $this->custom instanceof CustomBuilder ? $this->custom->build() : $this->custom
226  );
227  }
228 
229  public static function of(): ParcelBuilder
230  {
231  return new self();
232  }
233 }
withMeasurements(?ParcelMeasurements $measurements)
withCreatedAt(?DateTimeImmutable $createdAt)
withMeasurementsBuilder(?ParcelMeasurementsBuilder $measurements)
withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
withItems(?DeliveryItemCollection $items)