commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DeliveryParcelBuilder.php
1<?php
2
3declare(strict_types=1);
10
21use stdClass;
22
26final class DeliveryParcelBuilder implements Builder
27{
32 private $deliveryId;
33
38 private $measurements;
39
44 private $trackingData;
45
50 private $items;
51
58 public function getDeliveryId()
59 {
60 return $this->deliveryId;
61 }
62
69 public function getMeasurements()
70 {
71 return $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements;
72 }
73
80 public function getTrackingData()
81 {
82 return $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData;
83 }
84
91 public function getItems()
92 {
93 return $this->items;
94 }
95
100 public function withDeliveryId(?string $deliveryId)
101 {
102 $this->deliveryId = $deliveryId;
103
104 return $this;
105 }
106
111 public function withMeasurements(?ParcelMeasurements $measurements)
112 {
113 $this->measurements = $measurements;
114
115 return $this;
116 }
117
122 public function withTrackingData(?TrackingData $trackingData)
123 {
124 $this->trackingData = $trackingData;
125
126 return $this;
127 }
128
133 public function withItems(?DeliveryItemCollection $items)
134 {
135 $this->items = $items;
136
137 return $this;
138 }
139
145 {
146 $this->measurements = $measurements;
147
148 return $this;
149 }
150
155 public function withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
156 {
157 $this->trackingData = $trackingData;
158
159 return $this;
160 }
161
162 public function build(): DeliveryParcel
163 {
164 return new DeliveryParcelModel(
165 $this->deliveryId,
166 $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements,
167 $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData,
168 $this->items
169 );
170 }
171
172 public static function of(): DeliveryParcelBuilder
173 {
174 return new self();
175 }
176}