commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ParcelRemovedFromDeliveryMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'ParcelRemovedFromDelivery';
36  protected $id;
37 
42  protected $version;
43 
48  protected $createdAt;
49 
54  protected $lastModifiedAt;
55 
60  protected $lastModifiedBy;
61 
66  protected $createdBy;
67 
72  protected $sequenceNumber;
73 
78  protected $resource;
79 
84  protected $resourceVersion;
85 
90  protected $type;
91 
97 
102  protected $deliveryId;
103 
108  protected $parcel;
109 
114  protected $shippingKey;
115 
116 
120  public function __construct(
121  ?string $id = null,
122  ?int $version = null,
123  ?DateTimeImmutable $createdAt = null,
124  ?DateTimeImmutable $lastModifiedAt = null,
126  ?CreatedBy $createdBy = null,
127  ?int $sequenceNumber = null,
128  ?Reference $resource = null,
129  ?int $resourceVersion = null,
131  ?string $deliveryId = null,
132  ?Parcel $parcel = null,
133  ?string $shippingKey = null,
134  ?string $type = null
135  ) {
136  $this->id = $id;
137  $this->version = $version;
138  $this->createdAt = $createdAt;
139  $this->lastModifiedAt = $lastModifiedAt;
140  $this->lastModifiedBy = $lastModifiedBy;
141  $this->createdBy = $createdBy;
142  $this->sequenceNumber = $sequenceNumber;
143  $this->resource = $resource;
144  $this->resourceVersion = $resourceVersion;
145  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
146  $this->deliveryId = $deliveryId;
147  $this->parcel = $parcel;
148  $this->shippingKey = $shippingKey;
149  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
150  }
151 
158  public function getId()
159  {
160  if (is_null($this->id)) {
162  $data = $this->raw(self::FIELD_ID);
163  if (is_null($data)) {
164  return null;
165  }
166  $this->id = (string) $data;
167  }
168 
169  return $this->id;
170  }
171 
178  public function getVersion()
179  {
180  if (is_null($this->version)) {
182  $data = $this->raw(self::FIELD_VERSION);
183  if (is_null($data)) {
184  return null;
185  }
186  $this->version = (int) $data;
187  }
188 
189  return $this->version;
190  }
191 
198  public function getCreatedAt()
199  {
200  if (is_null($this->createdAt)) {
202  $data = $this->raw(self::FIELD_CREATED_AT);
203  if (is_null($data)) {
204  return null;
205  }
206  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
207  if (false === $data) {
208  return null;
209  }
210  $this->createdAt = $data;
211  }
212 
213  return $this->createdAt;
214  }
215 
222  public function getLastModifiedAt()
223  {
224  if (is_null($this->lastModifiedAt)) {
226  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
227  if (is_null($data)) {
228  return null;
229  }
230  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
231  if (false === $data) {
232  return null;
233  }
234  $this->lastModifiedAt = $data;
235  }
236 
237  return $this->lastModifiedAt;
238  }
239 
246  public function getLastModifiedBy()
247  {
248  if (is_null($this->lastModifiedBy)) {
250  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
251  if (is_null($data)) {
252  return null;
253  }
254 
255  $this->lastModifiedBy = LastModifiedByModel::of($data);
256  }
257 
258  return $this->lastModifiedBy;
259  }
260 
267  public function getCreatedBy()
268  {
269  if (is_null($this->createdBy)) {
271  $data = $this->raw(self::FIELD_CREATED_BY);
272  if (is_null($data)) {
273  return null;
274  }
275 
276  $this->createdBy = CreatedByModel::of($data);
277  }
278 
279  return $this->createdBy;
280  }
281 
289  public function getSequenceNumber()
290  {
291  if (is_null($this->sequenceNumber)) {
293  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
294  if (is_null($data)) {
295  return null;
296  }
297  $this->sequenceNumber = (int) $data;
298  }
299 
300  return $this->sequenceNumber;
301  }
302 
309  public function getResource()
310  {
311  if (is_null($this->resource)) {
313  $data = $this->raw(self::FIELD_RESOURCE);
314  if (is_null($data)) {
315  return null;
316  }
317  $className = ReferenceModel::resolveDiscriminatorClass($data);
318  $this->resource = $className::of($data);
319  }
320 
321  return $this->resource;
322  }
323 
330  public function getResourceVersion()
331  {
332  if (is_null($this->resourceVersion)) {
334  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
335  if (is_null($data)) {
336  return null;
337  }
338  $this->resourceVersion = (int) $data;
339  }
340 
341  return $this->resourceVersion;
342  }
343 
350  public function getType()
351  {
352  if (is_null($this->type)) {
354  $data = $this->raw(self::FIELD_TYPE);
355  if (is_null($data)) {
356  return null;
357  }
358  $this->type = (string) $data;
359  }
360 
361  return $this->type;
362  }
363 
371  {
372  if (is_null($this->resourceUserProvidedIdentifiers)) {
374  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
375  if (is_null($data)) {
376  return null;
377  }
378 
379  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
380  }
381 
383  }
384 
391  public function getDeliveryId()
392  {
393  if (is_null($this->deliveryId)) {
395  $data = $this->raw(self::FIELD_DELIVERY_ID);
396  if (is_null($data)) {
397  return null;
398  }
399  $this->deliveryId = (string) $data;
400  }
401 
402  return $this->deliveryId;
403  }
404 
411  public function getParcel()
412  {
413  if (is_null($this->parcel)) {
415  $data = $this->raw(self::FIELD_PARCEL);
416  if (is_null($data)) {
417  return null;
418  }
419 
420  $this->parcel = ParcelModel::of($data);
421  }
422 
423  return $this->parcel;
424  }
425 
432  public function getShippingKey()
433  {
434  if (is_null($this->shippingKey)) {
436  $data = $this->raw(self::FIELD_SHIPPING_KEY);
437  if (is_null($data)) {
438  return null;
439  }
440  $this->shippingKey = (string) $data;
441  }
442 
443  return $this->shippingKey;
444  }
445 
446 
450  public function setId(?string $id): void
451  {
452  $this->id = $id;
453  }
454 
458  public function setVersion(?int $version): void
459  {
460  $this->version = $version;
461  }
462 
466  public function setCreatedAt(?DateTimeImmutable $createdAt): void
467  {
468  $this->createdAt = $createdAt;
469  }
470 
474  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
475  {
476  $this->lastModifiedAt = $lastModifiedAt;
477  }
478 
483  {
484  $this->lastModifiedBy = $lastModifiedBy;
485  }
486 
490  public function setCreatedBy(?CreatedBy $createdBy): void
491  {
492  $this->createdBy = $createdBy;
493  }
494 
498  public function setSequenceNumber(?int $sequenceNumber): void
499  {
500  $this->sequenceNumber = $sequenceNumber;
501  }
502 
506  public function setResource(?Reference $resource): void
507  {
508  $this->resource = $resource;
509  }
510 
514  public function setResourceVersion(?int $resourceVersion): void
515  {
516  $this->resourceVersion = $resourceVersion;
517  }
518 
523  {
524  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
525  }
526 
530  public function setDeliveryId(?string $deliveryId): void
531  {
532  $this->deliveryId = $deliveryId;
533  }
534 
538  public function setParcel(?Parcel $parcel): void
539  {
540  $this->parcel = $parcel;
541  }
542 
546  public function setShippingKey(?string $shippingKey): void
547  {
548  $this->shippingKey = $shippingKey;
549  }
550 
551 
552  #[\ReturnTypeWillChange]
553  public function jsonSerialize()
554  {
555  $data = $this->toArray();
556  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
557  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
558  }
559 
560  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
561  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
562  }
563  return (object) $data;
564  }
565 }
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?int $sequenceNumber=null, ?Reference $resource=null, ?int $resourceVersion=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?string $deliveryId=null, ?Parcel $parcel=null, ?string $shippingKey=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)