commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
OrderStateTransitionMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'OrderStateTransition';
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 $state;
103 
108  protected $oldState;
109 
114  protected $force;
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  ?StateReference $state = null,
132  ?StateReference $oldState = null,
133  ?bool $force = 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->state = $state;
147  $this->oldState = $oldState;
148  $this->force = $force;
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 getState()
392  {
393  if (is_null($this->state)) {
395  $data = $this->raw(self::FIELD_STATE);
396  if (is_null($data)) {
397  return null;
398  }
399 
400  $this->state = StateReferenceModel::of($data);
401  }
402 
403  return $this->state;
404  }
405 
412  public function getOldState()
413  {
414  if (is_null($this->oldState)) {
416  $data = $this->raw(self::FIELD_OLD_STATE);
417  if (is_null($data)) {
418  return null;
419  }
420 
421  $this->oldState = StateReferenceModel::of($data);
422  }
423 
424  return $this->oldState;
425  }
426 
433  public function getForce()
434  {
435  if (is_null($this->force)) {
437  $data = $this->raw(self::FIELD_FORCE);
438  if (is_null($data)) {
439  return null;
440  }
441  $this->force = (bool) $data;
442  }
443 
444  return $this->force;
445  }
446 
447 
451  public function setId(?string $id): void
452  {
453  $this->id = $id;
454  }
455 
459  public function setVersion(?int $version): void
460  {
461  $this->version = $version;
462  }
463 
467  public function setCreatedAt(?DateTimeImmutable $createdAt): void
468  {
469  $this->createdAt = $createdAt;
470  }
471 
475  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
476  {
477  $this->lastModifiedAt = $lastModifiedAt;
478  }
479 
484  {
485  $this->lastModifiedBy = $lastModifiedBy;
486  }
487 
491  public function setCreatedBy(?CreatedBy $createdBy): void
492  {
493  $this->createdBy = $createdBy;
494  }
495 
499  public function setSequenceNumber(?int $sequenceNumber): void
500  {
501  $this->sequenceNumber = $sequenceNumber;
502  }
503 
507  public function setResource(?Reference $resource): void
508  {
509  $this->resource = $resource;
510  }
511 
515  public function setResourceVersion(?int $resourceVersion): void
516  {
517  $this->resourceVersion = $resourceVersion;
518  }
519 
524  {
525  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
526  }
527 
531  public function setState(?StateReference $state): void
532  {
533  $this->state = $state;
534  }
535 
539  public function setOldState(?StateReference $oldState): void
540  {
541  $this->oldState = $oldState;
542  }
543 
547  public function setForce(?bool $force): void
548  {
549  $this->force = $force;
550  }
551 
552 
553  #[\ReturnTypeWillChange]
554  public function jsonSerialize()
555  {
556  $data = $this->toArray();
557  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
558  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
559  }
560 
561  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
562  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
563  }
564  return (object) $data;
565  }
566 }
__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, ?StateReference $state=null, ?StateReference $oldState=null, ?bool $force=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)