commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApprovalRuleStatusSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
21 use DateTimeImmutable;
22 use stdClass;
23 
28 {
29  public const DISCRIMINATOR_VALUE = 'ApprovalRuleStatusSet';
34  protected $id;
35 
40  protected $version;
41 
46  protected $createdAt;
47 
52  protected $lastModifiedAt;
53 
58  protected $lastModifiedBy;
59 
64  protected $createdBy;
65 
70  protected $sequenceNumber;
71 
76  protected $resource;
77 
82  protected $resourceVersion;
83 
88  protected $type;
89 
95 
100  protected $status;
101 
106  protected $oldStatus;
107 
108 
112  public function __construct(
113  ?string $id = null,
114  ?int $version = null,
115  ?DateTimeImmutable $createdAt = null,
116  ?DateTimeImmutable $lastModifiedAt = null,
118  ?CreatedBy $createdBy = null,
119  ?int $sequenceNumber = null,
120  ?Reference $resource = null,
121  ?int $resourceVersion = null,
123  ?string $status = null,
124  ?string $oldStatus = null,
125  ?string $type = null
126  ) {
127  $this->id = $id;
128  $this->version = $version;
129  $this->createdAt = $createdAt;
130  $this->lastModifiedAt = $lastModifiedAt;
131  $this->lastModifiedBy = $lastModifiedBy;
132  $this->createdBy = $createdBy;
133  $this->sequenceNumber = $sequenceNumber;
134  $this->resource = $resource;
135  $this->resourceVersion = $resourceVersion;
136  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
137  $this->status = $status;
138  $this->oldStatus = $oldStatus;
139  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
140  }
141 
148  public function getId()
149  {
150  if (is_null($this->id)) {
152  $data = $this->raw(self::FIELD_ID);
153  if (is_null($data)) {
154  return null;
155  }
156  $this->id = (string) $data;
157  }
158 
159  return $this->id;
160  }
161 
168  public function getVersion()
169  {
170  if (is_null($this->version)) {
172  $data = $this->raw(self::FIELD_VERSION);
173  if (is_null($data)) {
174  return null;
175  }
176  $this->version = (int) $data;
177  }
178 
179  return $this->version;
180  }
181 
188  public function getCreatedAt()
189  {
190  if (is_null($this->createdAt)) {
192  $data = $this->raw(self::FIELD_CREATED_AT);
193  if (is_null($data)) {
194  return null;
195  }
196  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
197  if (false === $data) {
198  return null;
199  }
200  $this->createdAt = $data;
201  }
202 
203  return $this->createdAt;
204  }
205 
212  public function getLastModifiedAt()
213  {
214  if (is_null($this->lastModifiedAt)) {
216  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
217  if (is_null($data)) {
218  return null;
219  }
220  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
221  if (false === $data) {
222  return null;
223  }
224  $this->lastModifiedAt = $data;
225  }
226 
227  return $this->lastModifiedAt;
228  }
229 
236  public function getLastModifiedBy()
237  {
238  if (is_null($this->lastModifiedBy)) {
240  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
241  if (is_null($data)) {
242  return null;
243  }
244 
245  $this->lastModifiedBy = LastModifiedByModel::of($data);
246  }
247 
248  return $this->lastModifiedBy;
249  }
250 
257  public function getCreatedBy()
258  {
259  if (is_null($this->createdBy)) {
261  $data = $this->raw(self::FIELD_CREATED_BY);
262  if (is_null($data)) {
263  return null;
264  }
265 
266  $this->createdBy = CreatedByModel::of($data);
267  }
268 
269  return $this->createdBy;
270  }
271 
279  public function getSequenceNumber()
280  {
281  if (is_null($this->sequenceNumber)) {
283  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
284  if (is_null($data)) {
285  return null;
286  }
287  $this->sequenceNumber = (int) $data;
288  }
289 
290  return $this->sequenceNumber;
291  }
292 
299  public function getResource()
300  {
301  if (is_null($this->resource)) {
303  $data = $this->raw(self::FIELD_RESOURCE);
304  if (is_null($data)) {
305  return null;
306  }
307  $className = ReferenceModel::resolveDiscriminatorClass($data);
308  $this->resource = $className::of($data);
309  }
310 
311  return $this->resource;
312  }
313 
320  public function getResourceVersion()
321  {
322  if (is_null($this->resourceVersion)) {
324  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
325  if (is_null($data)) {
326  return null;
327  }
328  $this->resourceVersion = (int) $data;
329  }
330 
331  return $this->resourceVersion;
332  }
333 
340  public function getType()
341  {
342  if (is_null($this->type)) {
344  $data = $this->raw(self::FIELD_TYPE);
345  if (is_null($data)) {
346  return null;
347  }
348  $this->type = (string) $data;
349  }
350 
351  return $this->type;
352  }
353 
361  {
362  if (is_null($this->resourceUserProvidedIdentifiers)) {
364  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
365  if (is_null($data)) {
366  return null;
367  }
368 
369  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
370  }
371 
373  }
374 
381  public function getStatus()
382  {
383  if (is_null($this->status)) {
385  $data = $this->raw(self::FIELD_STATUS);
386  if (is_null($data)) {
387  return null;
388  }
389  $this->status = (string) $data;
390  }
391 
392  return $this->status;
393  }
394 
401  public function getOldStatus()
402  {
403  if (is_null($this->oldStatus)) {
405  $data = $this->raw(self::FIELD_OLD_STATUS);
406  if (is_null($data)) {
407  return null;
408  }
409  $this->oldStatus = (string) $data;
410  }
411 
412  return $this->oldStatus;
413  }
414 
415 
419  public function setId(?string $id): void
420  {
421  $this->id = $id;
422  }
423 
427  public function setVersion(?int $version): void
428  {
429  $this->version = $version;
430  }
431 
435  public function setCreatedAt(?DateTimeImmutable $createdAt): void
436  {
437  $this->createdAt = $createdAt;
438  }
439 
443  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
444  {
445  $this->lastModifiedAt = $lastModifiedAt;
446  }
447 
452  {
453  $this->lastModifiedBy = $lastModifiedBy;
454  }
455 
459  public function setCreatedBy(?CreatedBy $createdBy): void
460  {
461  $this->createdBy = $createdBy;
462  }
463 
467  public function setSequenceNumber(?int $sequenceNumber): void
468  {
469  $this->sequenceNumber = $sequenceNumber;
470  }
471 
475  public function setResource(?Reference $resource): void
476  {
477  $this->resource = $resource;
478  }
479 
483  public function setResourceVersion(?int $resourceVersion): void
484  {
485  $this->resourceVersion = $resourceVersion;
486  }
487 
492  {
493  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
494  }
495 
499  public function setStatus(?string $status): void
500  {
501  $this->status = $status;
502  }
503 
507  public function setOldStatus(?string $oldStatus): void
508  {
509  $this->oldStatus = $oldStatus;
510  }
511 
512 
513  #[\ReturnTypeWillChange]
514  public function jsonSerialize()
515  {
516  $data = $this->toArray();
517  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
518  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
519  }
520 
521  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
522  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
523  }
524  return (object) $data;
525  }
526 }
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__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 $status=null, ?string $oldStatus=null, ?string $type=null)