commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CloudEventsPayloadBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
16 use DateTimeImmutable;
17 use stdClass;
18 
22 final class CloudEventsPayloadBuilder implements Builder
23 {
28  private $specversion;
29 
34  private $id;
35 
40  private $type;
41 
46  private $source;
47 
52  private $subject;
53 
58  private $time;
59 
64  private $sequence;
65 
70  private $sequencetype;
71 
76  private $dataref;
77 
82  private $data;
83 
90  public function getSpecversion()
91  {
92  return $this->specversion;
93  }
94 
101  public function getId()
102  {
103  return $this->id;
104  }
105 
113  public function getType()
114  {
115  return $this->type;
116  }
117 
124  public function getSource()
125  {
126  return $this->source;
127  }
128 
135  public function getSubject()
136  {
137  return $this->subject;
138  }
139 
146  public function getTime()
147  {
148  return $this->time;
149  }
150 
157  public function getSequence()
158  {
159  return $this->sequence;
160  }
161 
168  public function getSequencetype()
169  {
170  return $this->sequencetype;
171  }
172 
179  public function getDataref()
180  {
181  return $this->dataref;
182  }
183 
190  public function getData()
191  {
192  return $this->data instanceof DeliveryPayloadBuilder ? $this->data->build() : $this->data;
193  }
194 
199  public function withSpecversion(?string $specversion)
200  {
201  $this->specversion = $specversion;
202 
203  return $this;
204  }
205 
210  public function withId(?string $id)
211  {
212  $this->id = $id;
213 
214  return $this;
215  }
216 
221  public function withType(?string $type)
222  {
223  $this->type = $type;
224 
225  return $this;
226  }
227 
232  public function withSource(?string $source)
233  {
234  $this->source = $source;
235 
236  return $this;
237  }
238 
243  public function withSubject(?string $subject)
244  {
245  $this->subject = $subject;
246 
247  return $this;
248  }
249 
254  public function withTime(?DateTimeImmutable $time)
255  {
256  $this->time = $time;
257 
258  return $this;
259  }
260 
265  public function withSequence(?string $sequence)
266  {
267  $this->sequence = $sequence;
268 
269  return $this;
270  }
271 
276  public function withSequencetype(?string $sequencetype)
277  {
278  $this->sequencetype = $sequencetype;
279 
280  return $this;
281  }
282 
287  public function withDataref(?string $dataref)
288  {
289  $this->dataref = $dataref;
290 
291  return $this;
292  }
293 
298  public function withData(?DeliveryPayload $data)
299  {
300  $this->data = $data;
301 
302  return $this;
303  }
304 
309  public function withDataBuilder(?DeliveryPayloadBuilder $data)
310  {
311  $this->data = $data;
312 
313  return $this;
314  }
315 
316  public function build(): CloudEventsPayload
317  {
318  return new CloudEventsPayloadModel(
319  $this->specversion,
320  $this->id,
321  $this->type,
322  $this->source,
323  $this->subject,
324  $this->time,
325  $this->sequence,
326  $this->sequencetype,
327  $this->dataref,
328  $this->data instanceof DeliveryPayloadBuilder ? $this->data->build() : $this->data
329  );
330  }
331 
332  public static function of(): CloudEventsPayloadBuilder
333  {
334  return new self();
335  }
336 }