commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
OrderMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
21 use DateTimeImmutable;
22 use stdClass;
23 
27 final class OrderMessageModel extends JsonObjectModel implements OrderMessage
28 {
33  protected $id;
34 
39  protected $version;
40 
45  protected $createdAt;
46 
51  protected $lastModifiedAt;
52 
57  protected $lastModifiedBy;
58 
63  protected $createdBy;
64 
69  protected $sequenceNumber;
70 
75  protected $resource;
76 
81  protected $resourceVersion;
82 
87  protected $type;
88 
94 
95 
99  public function __construct(
100  ?string $id = null,
101  ?int $version = null,
102  ?DateTimeImmutable $createdAt = null,
103  ?DateTimeImmutable $lastModifiedAt = null,
105  ?CreatedBy $createdBy = null,
106  ?int $sequenceNumber = null,
107  ?Reference $resource = null,
108  ?int $resourceVersion = null,
110  ?string $type = null
111  ) {
112  $this->id = $id;
113  $this->version = $version;
114  $this->createdAt = $createdAt;
115  $this->lastModifiedAt = $lastModifiedAt;
116  $this->lastModifiedBy = $lastModifiedBy;
117  $this->createdBy = $createdBy;
118  $this->sequenceNumber = $sequenceNumber;
119  $this->resource = $resource;
120  $this->resourceVersion = $resourceVersion;
121  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
122  $this->type = $type;
123  }
124 
131  public function getId()
132  {
133  if (is_null($this->id)) {
135  $data = $this->raw(self::FIELD_ID);
136  if (is_null($data)) {
137  return null;
138  }
139  $this->id = (string) $data;
140  }
141 
142  return $this->id;
143  }
144 
151  public function getVersion()
152  {
153  if (is_null($this->version)) {
155  $data = $this->raw(self::FIELD_VERSION);
156  if (is_null($data)) {
157  return null;
158  }
159  $this->version = (int) $data;
160  }
161 
162  return $this->version;
163  }
164 
171  public function getCreatedAt()
172  {
173  if (is_null($this->createdAt)) {
175  $data = $this->raw(self::FIELD_CREATED_AT);
176  if (is_null($data)) {
177  return null;
178  }
179  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
180  if (false === $data) {
181  return null;
182  }
183  $this->createdAt = $data;
184  }
185 
186  return $this->createdAt;
187  }
188 
195  public function getLastModifiedAt()
196  {
197  if (is_null($this->lastModifiedAt)) {
199  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
200  if (is_null($data)) {
201  return null;
202  }
203  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
204  if (false === $data) {
205  return null;
206  }
207  $this->lastModifiedAt = $data;
208  }
209 
210  return $this->lastModifiedAt;
211  }
212 
219  public function getLastModifiedBy()
220  {
221  if (is_null($this->lastModifiedBy)) {
223  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
224  if (is_null($data)) {
225  return null;
226  }
227 
228  $this->lastModifiedBy = LastModifiedByModel::of($data);
229  }
230 
231  return $this->lastModifiedBy;
232  }
233 
240  public function getCreatedBy()
241  {
242  if (is_null($this->createdBy)) {
244  $data = $this->raw(self::FIELD_CREATED_BY);
245  if (is_null($data)) {
246  return null;
247  }
248 
249  $this->createdBy = CreatedByModel::of($data);
250  }
251 
252  return $this->createdBy;
253  }
254 
262  public function getSequenceNumber()
263  {
264  if (is_null($this->sequenceNumber)) {
266  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
267  if (is_null($data)) {
268  return null;
269  }
270  $this->sequenceNumber = (int) $data;
271  }
272 
273  return $this->sequenceNumber;
274  }
275 
282  public function getResource()
283  {
284  if (is_null($this->resource)) {
286  $data = $this->raw(self::FIELD_RESOURCE);
287  if (is_null($data)) {
288  return null;
289  }
290  $className = ReferenceModel::resolveDiscriminatorClass($data);
291  $this->resource = $className::of($data);
292  }
293 
294  return $this->resource;
295  }
296 
303  public function getResourceVersion()
304  {
305  if (is_null($this->resourceVersion)) {
307  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
308  if (is_null($data)) {
309  return null;
310  }
311  $this->resourceVersion = (int) $data;
312  }
313 
314  return $this->resourceVersion;
315  }
316 
323  public function getType()
324  {
325  if (is_null($this->type)) {
327  $data = $this->raw(self::FIELD_TYPE);
328  if (is_null($data)) {
329  return null;
330  }
331  $this->type = (string) $data;
332  }
333 
334  return $this->type;
335  }
336 
344  {
345  if (is_null($this->resourceUserProvidedIdentifiers)) {
347  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
348  if (is_null($data)) {
349  return null;
350  }
351 
352  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
353  }
354 
356  }
357 
358 
362  public function setId(?string $id): void
363  {
364  $this->id = $id;
365  }
366 
370  public function setVersion(?int $version): void
371  {
372  $this->version = $version;
373  }
374 
378  public function setCreatedAt(?DateTimeImmutable $createdAt): void
379  {
380  $this->createdAt = $createdAt;
381  }
382 
386  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
387  {
388  $this->lastModifiedAt = $lastModifiedAt;
389  }
390 
395  {
396  $this->lastModifiedBy = $lastModifiedBy;
397  }
398 
402  public function setCreatedBy(?CreatedBy $createdBy): void
403  {
404  $this->createdBy = $createdBy;
405  }
406 
410  public function setSequenceNumber(?int $sequenceNumber): void
411  {
412  $this->sequenceNumber = $sequenceNumber;
413  }
414 
418  public function setResource(?Reference $resource): void
419  {
420  $this->resource = $resource;
421  }
422 
426  public function setResourceVersion(?int $resourceVersion): void
427  {
428  $this->resourceVersion = $resourceVersion;
429  }
430 
435  {
436  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
437  }
438 
439 
440  #[\ReturnTypeWillChange]
441  public function jsonSerialize()
442  {
443  $data = $this->toArray();
444  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
445  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
446  }
447 
448  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
449  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
450  }
451  return (object) $data;
452  }
453 }
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
__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 $type=null)