commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
LineItemStateTransitionMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'LineItemStateTransition';
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 $lineItemId;
103 
108  protected $lineItemKey;
109 
114  protected $transitionDate;
115 
120  protected $quantity;
121 
126  protected $fromState;
127 
132  protected $toState;
133 
134 
138  public function __construct(
139  ?string $id = null,
140  ?int $version = null,
141  ?DateTimeImmutable $createdAt = null,
142  ?DateTimeImmutable $lastModifiedAt = null,
144  ?CreatedBy $createdBy = null,
145  ?int $sequenceNumber = null,
146  ?Reference $resource = null,
147  ?int $resourceVersion = null,
149  ?string $lineItemId = null,
150  ?string $lineItemKey = null,
151  ?DateTimeImmutable $transitionDate = null,
152  ?int $quantity = null,
153  ?StateReference $fromState = null,
154  ?StateReference $toState = null,
155  ?string $type = null
156  ) {
157  $this->id = $id;
158  $this->version = $version;
159  $this->createdAt = $createdAt;
160  $this->lastModifiedAt = $lastModifiedAt;
161  $this->lastModifiedBy = $lastModifiedBy;
162  $this->createdBy = $createdBy;
163  $this->sequenceNumber = $sequenceNumber;
164  $this->resource = $resource;
165  $this->resourceVersion = $resourceVersion;
166  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
167  $this->lineItemId = $lineItemId;
168  $this->lineItemKey = $lineItemKey;
169  $this->transitionDate = $transitionDate;
170  $this->quantity = $quantity;
171  $this->fromState = $fromState;
172  $this->toState = $toState;
173  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
174  }
175 
182  public function getId()
183  {
184  if (is_null($this->id)) {
186  $data = $this->raw(self::FIELD_ID);
187  if (is_null($data)) {
188  return null;
189  }
190  $this->id = (string) $data;
191  }
192 
193  return $this->id;
194  }
195 
202  public function getVersion()
203  {
204  if (is_null($this->version)) {
206  $data = $this->raw(self::FIELD_VERSION);
207  if (is_null($data)) {
208  return null;
209  }
210  $this->version = (int) $data;
211  }
212 
213  return $this->version;
214  }
215 
222  public function getCreatedAt()
223  {
224  if (is_null($this->createdAt)) {
226  $data = $this->raw(self::FIELD_CREATED_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->createdAt = $data;
235  }
236 
237  return $this->createdAt;
238  }
239 
246  public function getLastModifiedAt()
247  {
248  if (is_null($this->lastModifiedAt)) {
250  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
251  if (is_null($data)) {
252  return null;
253  }
254  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
255  if (false === $data) {
256  return null;
257  }
258  $this->lastModifiedAt = $data;
259  }
260 
261  return $this->lastModifiedAt;
262  }
263 
270  public function getLastModifiedBy()
271  {
272  if (is_null($this->lastModifiedBy)) {
274  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
275  if (is_null($data)) {
276  return null;
277  }
278 
279  $this->lastModifiedBy = LastModifiedByModel::of($data);
280  }
281 
282  return $this->lastModifiedBy;
283  }
284 
291  public function getCreatedBy()
292  {
293  if (is_null($this->createdBy)) {
295  $data = $this->raw(self::FIELD_CREATED_BY);
296  if (is_null($data)) {
297  return null;
298  }
299 
300  $this->createdBy = CreatedByModel::of($data);
301  }
302 
303  return $this->createdBy;
304  }
305 
313  public function getSequenceNumber()
314  {
315  if (is_null($this->sequenceNumber)) {
317  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
318  if (is_null($data)) {
319  return null;
320  }
321  $this->sequenceNumber = (int) $data;
322  }
323 
324  return $this->sequenceNumber;
325  }
326 
333  public function getResource()
334  {
335  if (is_null($this->resource)) {
337  $data = $this->raw(self::FIELD_RESOURCE);
338  if (is_null($data)) {
339  return null;
340  }
341  $className = ReferenceModel::resolveDiscriminatorClass($data);
342  $this->resource = $className::of($data);
343  }
344 
345  return $this->resource;
346  }
347 
354  public function getResourceVersion()
355  {
356  if (is_null($this->resourceVersion)) {
358  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
359  if (is_null($data)) {
360  return null;
361  }
362  $this->resourceVersion = (int) $data;
363  }
364 
365  return $this->resourceVersion;
366  }
367 
374  public function getType()
375  {
376  if (is_null($this->type)) {
378  $data = $this->raw(self::FIELD_TYPE);
379  if (is_null($data)) {
380  return null;
381  }
382  $this->type = (string) $data;
383  }
384 
385  return $this->type;
386  }
387 
395  {
396  if (is_null($this->resourceUserProvidedIdentifiers)) {
398  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
399  if (is_null($data)) {
400  return null;
401  }
402 
403  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
404  }
405 
407  }
408 
415  public function getLineItemId()
416  {
417  if (is_null($this->lineItemId)) {
419  $data = $this->raw(self::FIELD_LINE_ITEM_ID);
420  if (is_null($data)) {
421  return null;
422  }
423  $this->lineItemId = (string) $data;
424  }
425 
426  return $this->lineItemId;
427  }
428 
435  public function getLineItemKey()
436  {
437  if (is_null($this->lineItemKey)) {
439  $data = $this->raw(self::FIELD_LINE_ITEM_KEY);
440  if (is_null($data)) {
441  return null;
442  }
443  $this->lineItemKey = (string) $data;
444  }
445 
446  return $this->lineItemKey;
447  }
448 
455  public function getTransitionDate()
456  {
457  if (is_null($this->transitionDate)) {
459  $data = $this->raw(self::FIELD_TRANSITION_DATE);
460  if (is_null($data)) {
461  return null;
462  }
463  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
464  if (false === $data) {
465  return null;
466  }
467  $this->transitionDate = $data;
468  }
469 
470  return $this->transitionDate;
471  }
472 
479  public function getQuantity()
480  {
481  if (is_null($this->quantity)) {
483  $data = $this->raw(self::FIELD_QUANTITY);
484  if (is_null($data)) {
485  return null;
486  }
487  $this->quantity = (int) $data;
488  }
489 
490  return $this->quantity;
491  }
492 
499  public function getFromState()
500  {
501  if (is_null($this->fromState)) {
503  $data = $this->raw(self::FIELD_FROM_STATE);
504  if (is_null($data)) {
505  return null;
506  }
507 
508  $this->fromState = StateReferenceModel::of($data);
509  }
510 
511  return $this->fromState;
512  }
513 
520  public function getToState()
521  {
522  if (is_null($this->toState)) {
524  $data = $this->raw(self::FIELD_TO_STATE);
525  if (is_null($data)) {
526  return null;
527  }
528 
529  $this->toState = StateReferenceModel::of($data);
530  }
531 
532  return $this->toState;
533  }
534 
535 
539  public function setId(?string $id): void
540  {
541  $this->id = $id;
542  }
543 
547  public function setVersion(?int $version): void
548  {
549  $this->version = $version;
550  }
551 
555  public function setCreatedAt(?DateTimeImmutable $createdAt): void
556  {
557  $this->createdAt = $createdAt;
558  }
559 
563  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
564  {
565  $this->lastModifiedAt = $lastModifiedAt;
566  }
567 
572  {
573  $this->lastModifiedBy = $lastModifiedBy;
574  }
575 
579  public function setCreatedBy(?CreatedBy $createdBy): void
580  {
581  $this->createdBy = $createdBy;
582  }
583 
587  public function setSequenceNumber(?int $sequenceNumber): void
588  {
589  $this->sequenceNumber = $sequenceNumber;
590  }
591 
595  public function setResource(?Reference $resource): void
596  {
597  $this->resource = $resource;
598  }
599 
603  public function setResourceVersion(?int $resourceVersion): void
604  {
605  $this->resourceVersion = $resourceVersion;
606  }
607 
612  {
613  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
614  }
615 
619  public function setLineItemId(?string $lineItemId): void
620  {
621  $this->lineItemId = $lineItemId;
622  }
623 
627  public function setLineItemKey(?string $lineItemKey): void
628  {
629  $this->lineItemKey = $lineItemKey;
630  }
631 
635  public function setTransitionDate(?DateTimeImmutable $transitionDate): void
636  {
637  $this->transitionDate = $transitionDate;
638  }
639 
643  public function setQuantity(?int $quantity): void
644  {
645  $this->quantity = $quantity;
646  }
647 
651  public function setFromState(?StateReference $fromState): void
652  {
653  $this->fromState = $fromState;
654  }
655 
659  public function setToState(?StateReference $toState): void
660  {
661  $this->toState = $toState;
662  }
663 
664 
665  #[\ReturnTypeWillChange]
666  public function jsonSerialize()
667  {
668  $data = $this->toArray();
669  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
670  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
671  }
672 
673  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
674  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
675  }
676 
678  $data[LineItemStateTransitionMessage::FIELD_TRANSITION_DATE] = $data[LineItemStateTransitionMessage::FIELD_TRANSITION_DATE]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
679  }
680  return (object) $data;
681  }
682 }
__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 $lineItemId=null, ?string $lineItemKey=null, ?DateTimeImmutable $transitionDate=null, ?int $quantity=null, ?StateReference $fromState=null, ?StateReference $toState=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)