commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApprovalFlowApprovedMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
25 use DateTimeImmutable;
26 use stdClass;
27 
32 {
33  public const DISCRIMINATOR_VALUE = 'ApprovalFlowApproved';
38  protected $id;
39 
44  protected $version;
45 
50  protected $createdAt;
51 
56  protected $lastModifiedAt;
57 
62  protected $lastModifiedBy;
63 
68  protected $createdBy;
69 
74  protected $sequenceNumber;
75 
80  protected $resource;
81 
86  protected $resourceVersion;
87 
92  protected $type;
93 
99 
104  protected $associate;
105 
110  protected $order;
111 
112 
116  public function __construct(
117  ?string $id = null,
118  ?int $version = null,
119  ?DateTimeImmutable $createdAt = null,
120  ?DateTimeImmutable $lastModifiedAt = null,
122  ?CreatedBy $createdBy = null,
123  ?int $sequenceNumber = null,
124  ?Reference $resource = null,
125  ?int $resourceVersion = null,
128  ?OrderReference $order = null,
129  ?string $type = null
130  ) {
131  $this->id = $id;
132  $this->version = $version;
133  $this->createdAt = $createdAt;
134  $this->lastModifiedAt = $lastModifiedAt;
135  $this->lastModifiedBy = $lastModifiedBy;
136  $this->createdBy = $createdBy;
137  $this->sequenceNumber = $sequenceNumber;
138  $this->resource = $resource;
139  $this->resourceVersion = $resourceVersion;
140  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
141  $this->associate = $associate;
142  $this->order = $order;
143  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
144  }
145 
152  public function getId()
153  {
154  if (is_null($this->id)) {
156  $data = $this->raw(self::FIELD_ID);
157  if (is_null($data)) {
158  return null;
159  }
160  $this->id = (string) $data;
161  }
162 
163  return $this->id;
164  }
165 
172  public function getVersion()
173  {
174  if (is_null($this->version)) {
176  $data = $this->raw(self::FIELD_VERSION);
177  if (is_null($data)) {
178  return null;
179  }
180  $this->version = (int) $data;
181  }
182 
183  return $this->version;
184  }
185 
192  public function getCreatedAt()
193  {
194  if (is_null($this->createdAt)) {
196  $data = $this->raw(self::FIELD_CREATED_AT);
197  if (is_null($data)) {
198  return null;
199  }
200  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
201  if (false === $data) {
202  return null;
203  }
204  $this->createdAt = $data;
205  }
206 
207  return $this->createdAt;
208  }
209 
216  public function getLastModifiedAt()
217  {
218  if (is_null($this->lastModifiedAt)) {
220  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
221  if (is_null($data)) {
222  return null;
223  }
224  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
225  if (false === $data) {
226  return null;
227  }
228  $this->lastModifiedAt = $data;
229  }
230 
231  return $this->lastModifiedAt;
232  }
233 
240  public function getLastModifiedBy()
241  {
242  if (is_null($this->lastModifiedBy)) {
244  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
245  if (is_null($data)) {
246  return null;
247  }
248 
249  $this->lastModifiedBy = LastModifiedByModel::of($data);
250  }
251 
252  return $this->lastModifiedBy;
253  }
254 
261  public function getCreatedBy()
262  {
263  if (is_null($this->createdBy)) {
265  $data = $this->raw(self::FIELD_CREATED_BY);
266  if (is_null($data)) {
267  return null;
268  }
269 
270  $this->createdBy = CreatedByModel::of($data);
271  }
272 
273  return $this->createdBy;
274  }
275 
283  public function getSequenceNumber()
284  {
285  if (is_null($this->sequenceNumber)) {
287  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
288  if (is_null($data)) {
289  return null;
290  }
291  $this->sequenceNumber = (int) $data;
292  }
293 
294  return $this->sequenceNumber;
295  }
296 
303  public function getResource()
304  {
305  if (is_null($this->resource)) {
307  $data = $this->raw(self::FIELD_RESOURCE);
308  if (is_null($data)) {
309  return null;
310  }
311  $className = ReferenceModel::resolveDiscriminatorClass($data);
312  $this->resource = $className::of($data);
313  }
314 
315  return $this->resource;
316  }
317 
324  public function getResourceVersion()
325  {
326  if (is_null($this->resourceVersion)) {
328  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
329  if (is_null($data)) {
330  return null;
331  }
332  $this->resourceVersion = (int) $data;
333  }
334 
335  return $this->resourceVersion;
336  }
337 
344  public function getType()
345  {
346  if (is_null($this->type)) {
348  $data = $this->raw(self::FIELD_TYPE);
349  if (is_null($data)) {
350  return null;
351  }
352  $this->type = (string) $data;
353  }
354 
355  return $this->type;
356  }
357 
365  {
366  if (is_null($this->resourceUserProvidedIdentifiers)) {
368  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
369  if (is_null($data)) {
370  return null;
371  }
372 
373  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
374  }
375 
377  }
378 
385  public function getAssociate()
386  {
387  if (is_null($this->associate)) {
389  $data = $this->raw(self::FIELD_ASSOCIATE);
390  if (is_null($data)) {
391  return null;
392  }
393 
394  $this->associate = CustomerReferenceModel::of($data);
395  }
396 
397  return $this->associate;
398  }
399 
406  public function getOrder()
407  {
408  if (is_null($this->order)) {
410  $data = $this->raw(self::FIELD_ORDER);
411  if (is_null($data)) {
412  return null;
413  }
414 
415  $this->order = OrderReferenceModel::of($data);
416  }
417 
418  return $this->order;
419  }
420 
421 
425  public function setId(?string $id): void
426  {
427  $this->id = $id;
428  }
429 
433  public function setVersion(?int $version): void
434  {
435  $this->version = $version;
436  }
437 
441  public function setCreatedAt(?DateTimeImmutable $createdAt): void
442  {
443  $this->createdAt = $createdAt;
444  }
445 
449  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
450  {
451  $this->lastModifiedAt = $lastModifiedAt;
452  }
453 
458  {
459  $this->lastModifiedBy = $lastModifiedBy;
460  }
461 
465  public function setCreatedBy(?CreatedBy $createdBy): void
466  {
467  $this->createdBy = $createdBy;
468  }
469 
473  public function setSequenceNumber(?int $sequenceNumber): void
474  {
475  $this->sequenceNumber = $sequenceNumber;
476  }
477 
481  public function setResource(?Reference $resource): void
482  {
483  $this->resource = $resource;
484  }
485 
489  public function setResourceVersion(?int $resourceVersion): void
490  {
491  $this->resourceVersion = $resourceVersion;
492  }
493 
498  {
499  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
500  }
501 
505  public function setAssociate(?CustomerReference $associate): void
506  {
507  $this->associate = $associate;
508  }
509 
513  public function setOrder(?OrderReference $order): void
514  {
515  $this->order = $order;
516  }
517 
518 
519  #[\ReturnTypeWillChange]
520  public function jsonSerialize()
521  {
522  $data = $this->toArray();
523  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
524  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
525  }
526 
527  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
528  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
529  }
530  return (object) $data;
531  }
532 }
__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, ?CustomerReference $associate=null, ?OrderReference $order=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)