commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ParcelDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
18use stdClass;
19
23final class ParcelDraftBuilder implements Builder
24{
29 private $key;
30
35 private $measurements;
36
41 private $trackingData;
42
47 private $items;
48
53 private $custom;
54
61 public function getKey()
62 {
63 return $this->key;
64 }
65
72 public function getMeasurements()
73 {
74 return $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements;
75 }
76
83 public function getTrackingData()
84 {
85 return $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData;
86 }
87
94 public function getItems()
95 {
96 return $this->items;
97 }
98
105 public function getCustom()
106 {
107 return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom;
108 }
109
114 public function withKey(?string $key)
115 {
116 $this->key = $key;
117
118 return $this;
119 }
120
125 public function withMeasurements(?ParcelMeasurements $measurements)
126 {
127 $this->measurements = $measurements;
128
129 return $this;
130 }
131
136 public function withTrackingData(?TrackingData $trackingData)
137 {
138 $this->trackingData = $trackingData;
139
140 return $this;
141 }
142
147 public function withItems(?DeliveryItemCollection $items)
148 {
149 $this->items = $items;
150
151 return $this;
152 }
153
158 public function withCustom(?CustomFieldsDraft $custom)
159 {
160 $this->custom = $custom;
161
162 return $this;
163 }
164
170 {
171 $this->measurements = $measurements;
172
173 return $this;
174 }
175
180 public function withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
181 {
182 $this->trackingData = $trackingData;
183
184 return $this;
185 }
186
192 {
193 $this->custom = $custom;
194
195 return $this;
196 }
197
198 public function build(): ParcelDraft
199 {
200 return new ParcelDraftModel(
201 $this->key,
202 $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements,
203 $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData,
204 $this->items,
205 $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom
206 );
207 }
208
209 public static function of(): ParcelDraftBuilder
210 {
211 return new self();
212 }
213}
withTrackingDataBuilder(?TrackingDataBuilder $trackingData)
withCustomBuilder(?CustomFieldsDraftBuilder $custom)
withMeasurements(?ParcelMeasurements $measurements)
withMeasurementsBuilder(?ParcelMeasurementsBuilder $measurements)