commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
QuoteRequestCustomerChangedMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'QuoteRequestCustomerChanged';
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 $customer;
103 
108  protected $previousCustomer;
109 
110 
114  public function __construct(
115  ?string $id = null,
116  ?int $version = null,
117  ?DateTimeImmutable $createdAt = null,
118  ?DateTimeImmutable $lastModifiedAt = null,
120  ?CreatedBy $createdBy = null,
121  ?int $sequenceNumber = null,
122  ?Reference $resource = null,
123  ?int $resourceVersion = null,
127  ?string $type = null
128  ) {
129  $this->id = $id;
130  $this->version = $version;
131  $this->createdAt = $createdAt;
132  $this->lastModifiedAt = $lastModifiedAt;
133  $this->lastModifiedBy = $lastModifiedBy;
134  $this->createdBy = $createdBy;
135  $this->sequenceNumber = $sequenceNumber;
136  $this->resource = $resource;
137  $this->resourceVersion = $resourceVersion;
138  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
139  $this->customer = $customer;
140  $this->previousCustomer = $previousCustomer;
141  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
142  }
143 
150  public function getId()
151  {
152  if (is_null($this->id)) {
154  $data = $this->raw(self::FIELD_ID);
155  if (is_null($data)) {
156  return null;
157  }
158  $this->id = (string) $data;
159  }
160 
161  return $this->id;
162  }
163 
170  public function getVersion()
171  {
172  if (is_null($this->version)) {
174  $data = $this->raw(self::FIELD_VERSION);
175  if (is_null($data)) {
176  return null;
177  }
178  $this->version = (int) $data;
179  }
180 
181  return $this->version;
182  }
183 
190  public function getCreatedAt()
191  {
192  if (is_null($this->createdAt)) {
194  $data = $this->raw(self::FIELD_CREATED_AT);
195  if (is_null($data)) {
196  return null;
197  }
198  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
199  if (false === $data) {
200  return null;
201  }
202  $this->createdAt = $data;
203  }
204 
205  return $this->createdAt;
206  }
207 
214  public function getLastModifiedAt()
215  {
216  if (is_null($this->lastModifiedAt)) {
218  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
219  if (is_null($data)) {
220  return null;
221  }
222  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
223  if (false === $data) {
224  return null;
225  }
226  $this->lastModifiedAt = $data;
227  }
228 
229  return $this->lastModifiedAt;
230  }
231 
238  public function getLastModifiedBy()
239  {
240  if (is_null($this->lastModifiedBy)) {
242  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
243  if (is_null($data)) {
244  return null;
245  }
246 
247  $this->lastModifiedBy = LastModifiedByModel::of($data);
248  }
249 
250  return $this->lastModifiedBy;
251  }
252 
259  public function getCreatedBy()
260  {
261  if (is_null($this->createdBy)) {
263  $data = $this->raw(self::FIELD_CREATED_BY);
264  if (is_null($data)) {
265  return null;
266  }
267 
268  $this->createdBy = CreatedByModel::of($data);
269  }
270 
271  return $this->createdBy;
272  }
273 
281  public function getSequenceNumber()
282  {
283  if (is_null($this->sequenceNumber)) {
285  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
286  if (is_null($data)) {
287  return null;
288  }
289  $this->sequenceNumber = (int) $data;
290  }
291 
292  return $this->sequenceNumber;
293  }
294 
301  public function getResource()
302  {
303  if (is_null($this->resource)) {
305  $data = $this->raw(self::FIELD_RESOURCE);
306  if (is_null($data)) {
307  return null;
308  }
309  $className = ReferenceModel::resolveDiscriminatorClass($data);
310  $this->resource = $className::of($data);
311  }
312 
313  return $this->resource;
314  }
315 
322  public function getResourceVersion()
323  {
324  if (is_null($this->resourceVersion)) {
326  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
327  if (is_null($data)) {
328  return null;
329  }
330  $this->resourceVersion = (int) $data;
331  }
332 
333  return $this->resourceVersion;
334  }
335 
342  public function getType()
343  {
344  if (is_null($this->type)) {
346  $data = $this->raw(self::FIELD_TYPE);
347  if (is_null($data)) {
348  return null;
349  }
350  $this->type = (string) $data;
351  }
352 
353  return $this->type;
354  }
355 
363  {
364  if (is_null($this->resourceUserProvidedIdentifiers)) {
366  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
367  if (is_null($data)) {
368  return null;
369  }
370 
371  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
372  }
373 
375  }
376 
383  public function getCustomer()
384  {
385  if (is_null($this->customer)) {
387  $data = $this->raw(self::FIELD_CUSTOMER);
388  if (is_null($data)) {
389  return null;
390  }
391 
392  $this->customer = CustomerReferenceModel::of($data);
393  }
394 
395  return $this->customer;
396  }
397 
404  public function getPreviousCustomer()
405  {
406  if (is_null($this->previousCustomer)) {
408  $data = $this->raw(self::FIELD_PREVIOUS_CUSTOMER);
409  if (is_null($data)) {
410  return null;
411  }
412 
413  $this->previousCustomer = CustomerReferenceModel::of($data);
414  }
415 
417  }
418 
419 
423  public function setId(?string $id): void
424  {
425  $this->id = $id;
426  }
427 
431  public function setVersion(?int $version): void
432  {
433  $this->version = $version;
434  }
435 
439  public function setCreatedAt(?DateTimeImmutable $createdAt): void
440  {
441  $this->createdAt = $createdAt;
442  }
443 
447  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
448  {
449  $this->lastModifiedAt = $lastModifiedAt;
450  }
451 
456  {
457  $this->lastModifiedBy = $lastModifiedBy;
458  }
459 
463  public function setCreatedBy(?CreatedBy $createdBy): void
464  {
465  $this->createdBy = $createdBy;
466  }
467 
471  public function setSequenceNumber(?int $sequenceNumber): void
472  {
473  $this->sequenceNumber = $sequenceNumber;
474  }
475 
479  public function setResource(?Reference $resource): void
480  {
481  $this->resource = $resource;
482  }
483 
487  public function setResourceVersion(?int $resourceVersion): void
488  {
489  $this->resourceVersion = $resourceVersion;
490  }
491 
496  {
497  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
498  }
499 
503  public function setCustomer(?CustomerReference $customer): void
504  {
505  $this->customer = $customer;
506  }
507 
512  {
513  $this->previousCustomer = $previousCustomer;
514  }
515 
516 
517  #[\ReturnTypeWillChange]
518  public function jsonSerialize()
519  {
520  $data = $this->toArray();
521  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
522  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
523  }
524 
525  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
526  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
527  }
528  return (object) $data;
529  }
530 }
__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, ?CustomerReference $previousCustomer=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)