commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
OrderCustomerSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
25 use DateTimeImmutable;
26 use stdClass;
27 
32 {
33  public const DISCRIMINATOR_VALUE = 'OrderCustomerSet';
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 $customer;
105 
110  protected $customerGroup;
111 
116  protected $oldCustomer;
117 
122  protected $oldCustomerGroup;
123 
124 
128  public function __construct(
129  ?string $id = null,
130  ?int $version = null,
131  ?DateTimeImmutable $createdAt = null,
132  ?DateTimeImmutable $lastModifiedAt = null,
134  ?CreatedBy $createdBy = null,
135  ?int $sequenceNumber = null,
136  ?Reference $resource = null,
137  ?int $resourceVersion = null,
143  ?string $type = null
144  ) {
145  $this->id = $id;
146  $this->version = $version;
147  $this->createdAt = $createdAt;
148  $this->lastModifiedAt = $lastModifiedAt;
149  $this->lastModifiedBy = $lastModifiedBy;
150  $this->createdBy = $createdBy;
151  $this->sequenceNumber = $sequenceNumber;
152  $this->resource = $resource;
153  $this->resourceVersion = $resourceVersion;
154  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
155  $this->customer = $customer;
156  $this->customerGroup = $customerGroup;
157  $this->oldCustomer = $oldCustomer;
158  $this->oldCustomerGroup = $oldCustomerGroup;
159  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
160  }
161 
168  public function getId()
169  {
170  if (is_null($this->id)) {
172  $data = $this->raw(self::FIELD_ID);
173  if (is_null($data)) {
174  return null;
175  }
176  $this->id = (string) $data;
177  }
178 
179  return $this->id;
180  }
181 
188  public function getVersion()
189  {
190  if (is_null($this->version)) {
192  $data = $this->raw(self::FIELD_VERSION);
193  if (is_null($data)) {
194  return null;
195  }
196  $this->version = (int) $data;
197  }
198 
199  return $this->version;
200  }
201 
208  public function getCreatedAt()
209  {
210  if (is_null($this->createdAt)) {
212  $data = $this->raw(self::FIELD_CREATED_AT);
213  if (is_null($data)) {
214  return null;
215  }
216  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
217  if (false === $data) {
218  return null;
219  }
220  $this->createdAt = $data;
221  }
222 
223  return $this->createdAt;
224  }
225 
232  public function getLastModifiedAt()
233  {
234  if (is_null($this->lastModifiedAt)) {
236  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
237  if (is_null($data)) {
238  return null;
239  }
240  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
241  if (false === $data) {
242  return null;
243  }
244  $this->lastModifiedAt = $data;
245  }
246 
247  return $this->lastModifiedAt;
248  }
249 
256  public function getLastModifiedBy()
257  {
258  if (is_null($this->lastModifiedBy)) {
260  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
261  if (is_null($data)) {
262  return null;
263  }
264 
265  $this->lastModifiedBy = LastModifiedByModel::of($data);
266  }
267 
268  return $this->lastModifiedBy;
269  }
270 
277  public function getCreatedBy()
278  {
279  if (is_null($this->createdBy)) {
281  $data = $this->raw(self::FIELD_CREATED_BY);
282  if (is_null($data)) {
283  return null;
284  }
285 
286  $this->createdBy = CreatedByModel::of($data);
287  }
288 
289  return $this->createdBy;
290  }
291 
299  public function getSequenceNumber()
300  {
301  if (is_null($this->sequenceNumber)) {
303  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
304  if (is_null($data)) {
305  return null;
306  }
307  $this->sequenceNumber = (int) $data;
308  }
309 
310  return $this->sequenceNumber;
311  }
312 
319  public function getResource()
320  {
321  if (is_null($this->resource)) {
323  $data = $this->raw(self::FIELD_RESOURCE);
324  if (is_null($data)) {
325  return null;
326  }
327  $className = ReferenceModel::resolveDiscriminatorClass($data);
328  $this->resource = $className::of($data);
329  }
330 
331  return $this->resource;
332  }
333 
340  public function getResourceVersion()
341  {
342  if (is_null($this->resourceVersion)) {
344  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
345  if (is_null($data)) {
346  return null;
347  }
348  $this->resourceVersion = (int) $data;
349  }
350 
351  return $this->resourceVersion;
352  }
353 
360  public function getType()
361  {
362  if (is_null($this->type)) {
364  $data = $this->raw(self::FIELD_TYPE);
365  if (is_null($data)) {
366  return null;
367  }
368  $this->type = (string) $data;
369  }
370 
371  return $this->type;
372  }
373 
381  {
382  if (is_null($this->resourceUserProvidedIdentifiers)) {
384  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
385  if (is_null($data)) {
386  return null;
387  }
388 
389  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
390  }
391 
393  }
394 
401  public function getCustomer()
402  {
403  if (is_null($this->customer)) {
405  $data = $this->raw(self::FIELD_CUSTOMER);
406  if (is_null($data)) {
407  return null;
408  }
409 
410  $this->customer = CustomerReferenceModel::of($data);
411  }
412 
413  return $this->customer;
414  }
415 
422  public function getCustomerGroup()
423  {
424  if (is_null($this->customerGroup)) {
426  $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
427  if (is_null($data)) {
428  return null;
429  }
430 
431  $this->customerGroup = CustomerGroupReferenceModel::of($data);
432  }
433 
434  return $this->customerGroup;
435  }
436 
443  public function getOldCustomer()
444  {
445  if (is_null($this->oldCustomer)) {
447  $data = $this->raw(self::FIELD_OLD_CUSTOMER);
448  if (is_null($data)) {
449  return null;
450  }
451 
452  $this->oldCustomer = CustomerReferenceModel::of($data);
453  }
454 
455  return $this->oldCustomer;
456  }
457 
464  public function getOldCustomerGroup()
465  {
466  if (is_null($this->oldCustomerGroup)) {
468  $data = $this->raw(self::FIELD_OLD_CUSTOMER_GROUP);
469  if (is_null($data)) {
470  return null;
471  }
472 
473  $this->oldCustomerGroup = CustomerGroupReferenceModel::of($data);
474  }
475 
477  }
478 
479 
483  public function setId(?string $id): void
484  {
485  $this->id = $id;
486  }
487 
491  public function setVersion(?int $version): void
492  {
493  $this->version = $version;
494  }
495 
499  public function setCreatedAt(?DateTimeImmutable $createdAt): void
500  {
501  $this->createdAt = $createdAt;
502  }
503 
507  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
508  {
509  $this->lastModifiedAt = $lastModifiedAt;
510  }
511 
516  {
517  $this->lastModifiedBy = $lastModifiedBy;
518  }
519 
523  public function setCreatedBy(?CreatedBy $createdBy): void
524  {
525  $this->createdBy = $createdBy;
526  }
527 
531  public function setSequenceNumber(?int $sequenceNumber): void
532  {
533  $this->sequenceNumber = $sequenceNumber;
534  }
535 
539  public function setResource(?Reference $resource): void
540  {
541  $this->resource = $resource;
542  }
543 
547  public function setResourceVersion(?int $resourceVersion): void
548  {
549  $this->resourceVersion = $resourceVersion;
550  }
551 
556  {
557  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
558  }
559 
563  public function setCustomer(?CustomerReference $customer): void
564  {
565  $this->customer = $customer;
566  }
567 
572  {
573  $this->customerGroup = $customerGroup;
574  }
575 
580  {
581  $this->oldCustomer = $oldCustomer;
582  }
583 
588  {
589  $this->oldCustomerGroup = $oldCustomerGroup;
590  }
591 
592 
593  #[\ReturnTypeWillChange]
594  public function jsonSerialize()
595  {
596  $data = $this->toArray();
597  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
598  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
599  }
600 
601  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
602  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
603  }
604  return (object) $data;
605  }
606 }
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, ?CustomerReference $customer=null, ?CustomerGroupReference $customerGroup=null, ?CustomerReference $oldCustomer=null, ?CustomerGroupReference $oldCustomerGroup=null, ?string $type=null)