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
56 public function getDeliveryId()
57 {
58 return $this->deliveryId;
59 }
60
65 public function getMeasurements()
66 {
67 return $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements;
68 }
69
74 public function getTrackingData()
75 {
76 return $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData;
77 }
78
83 public function getItems()
84 {
85 return $this->items;
86 }
87
92 public function withDeliveryId(?string $deliveryId)
93 {
94 $this->deliveryId = $deliveryId;
95
96 return $this;
97 }
98
103 public function withMeasurements(?ParcelMeasurements $measurements)
104 {
105 $this->measurements = $measurements;
106
107 return $this;
108 }
109
114 public function withTrackingData(?TrackingData $trackingData)
115 {
116 $this->trackingData = $trackingData;
117
118 return $this;
119 }
120
125 public function withItems(?DeliveryItemCollection $items)
126 {
127 $this->items = $items;
128
129 return $this;
130 }
131
137 {
138 $this->measurements = $measurements;
139
140 return $this;
141 }
142
147 public function withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
148 {
149 $this->trackingData = $trackingData;
150
151 return $this;
152 }
153
154 public function build(): DeliveryParcel
155 {
156 return new DeliveryParcelModel(
157 $this->deliveryId,
158 $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements,
159 $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData,
160 $this->items
161 );
162 }
163
164 public static function of(): DeliveryParcelBuilder
165 {
166 return new self();
167 }
168}