commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StandalonePriceValueChangedMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'StandalonePriceValueChanged';
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 $value;
103 
108  protected $staged;
109 
114  protected $oldValue;
115 
116 
120  public function __construct(
121  ?string $id = null,
122  ?int $version = null,
123  ?DateTimeImmutable $createdAt = null,
124  ?DateTimeImmutable $lastModifiedAt = null,
126  ?CreatedBy $createdBy = null,
127  ?int $sequenceNumber = null,
128  ?Reference $resource = null,
129  ?int $resourceVersion = null,
131  ?TypedMoney $value = null,
132  ?bool $staged = null,
133  ?TypedMoney $oldValue = null,
134  ?string $type = null
135  ) {
136  $this->id = $id;
137  $this->version = $version;
138  $this->createdAt = $createdAt;
139  $this->lastModifiedAt = $lastModifiedAt;
140  $this->lastModifiedBy = $lastModifiedBy;
141  $this->createdBy = $createdBy;
142  $this->sequenceNumber = $sequenceNumber;
143  $this->resource = $resource;
144  $this->resourceVersion = $resourceVersion;
145  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
146  $this->value = $value;
147  $this->staged = $staged;
148  $this->oldValue = $oldValue;
149  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
150  }
151 
158  public function getId()
159  {
160  if (is_null($this->id)) {
162  $data = $this->raw(self::FIELD_ID);
163  if (is_null($data)) {
164  return null;
165  }
166  $this->id = (string) $data;
167  }
168 
169  return $this->id;
170  }
171 
178  public function getVersion()
179  {
180  if (is_null($this->version)) {
182  $data = $this->raw(self::FIELD_VERSION);
183  if (is_null($data)) {
184  return null;
185  }
186  $this->version = (int) $data;
187  }
188 
189  return $this->version;
190  }
191 
198  public function getCreatedAt()
199  {
200  if (is_null($this->createdAt)) {
202  $data = $this->raw(self::FIELD_CREATED_AT);
203  if (is_null($data)) {
204  return null;
205  }
206  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
207  if (false === $data) {
208  return null;
209  }
210  $this->createdAt = $data;
211  }
212 
213  return $this->createdAt;
214  }
215 
222  public function getLastModifiedAt()
223  {
224  if (is_null($this->lastModifiedAt)) {
226  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
227  if (is_null($data)) {
228  return null;
229  }
230  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
231  if (false === $data) {
232  return null;
233  }
234  $this->lastModifiedAt = $data;
235  }
236 
237  return $this->lastModifiedAt;
238  }
239 
246  public function getLastModifiedBy()
247  {
248  if (is_null($this->lastModifiedBy)) {
250  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
251  if (is_null($data)) {
252  return null;
253  }
254 
255  $this->lastModifiedBy = LastModifiedByModel::of($data);
256  }
257 
258  return $this->lastModifiedBy;
259  }
260 
267  public function getCreatedBy()
268  {
269  if (is_null($this->createdBy)) {
271  $data = $this->raw(self::FIELD_CREATED_BY);
272  if (is_null($data)) {
273  return null;
274  }
275 
276  $this->createdBy = CreatedByModel::of($data);
277  }
278 
279  return $this->createdBy;
280  }
281 
289  public function getSequenceNumber()
290  {
291  if (is_null($this->sequenceNumber)) {
293  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
294  if (is_null($data)) {
295  return null;
296  }
297  $this->sequenceNumber = (int) $data;
298  }
299 
300  return $this->sequenceNumber;
301  }
302 
309  public function getResource()
310  {
311  if (is_null($this->resource)) {
313  $data = $this->raw(self::FIELD_RESOURCE);
314  if (is_null($data)) {
315  return null;
316  }
317  $className = ReferenceModel::resolveDiscriminatorClass($data);
318  $this->resource = $className::of($data);
319  }
320 
321  return $this->resource;
322  }
323 
330  public function getResourceVersion()
331  {
332  if (is_null($this->resourceVersion)) {
334  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
335  if (is_null($data)) {
336  return null;
337  }
338  $this->resourceVersion = (int) $data;
339  }
340 
341  return $this->resourceVersion;
342  }
343 
350  public function getType()
351  {
352  if (is_null($this->type)) {
354  $data = $this->raw(self::FIELD_TYPE);
355  if (is_null($data)) {
356  return null;
357  }
358  $this->type = (string) $data;
359  }
360 
361  return $this->type;
362  }
363 
371  {
372  if (is_null($this->resourceUserProvidedIdentifiers)) {
374  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
375  if (is_null($data)) {
376  return null;
377  }
378 
379  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
380  }
381 
383  }
384 
391  public function getValue()
392  {
393  if (is_null($this->value)) {
395  $data = $this->raw(self::FIELD_VALUE);
396  if (is_null($data)) {
397  return null;
398  }
399  $className = TypedMoneyModel::resolveDiscriminatorClass($data);
400  $this->value = $className::of($data);
401  }
402 
403  return $this->value;
404  }
405 
412  public function getStaged()
413  {
414  if (is_null($this->staged)) {
416  $data = $this->raw(self::FIELD_STAGED);
417  if (is_null($data)) {
418  return null;
419  }
420  $this->staged = (bool) $data;
421  }
422 
423  return $this->staged;
424  }
425 
433  public function getOldValue()
434  {
435  if (is_null($this->oldValue)) {
437  $data = $this->raw(self::FIELD_OLD_VALUE);
438  if (is_null($data)) {
439  return null;
440  }
441  $className = TypedMoneyModel::resolveDiscriminatorClass($data);
442  $this->oldValue = $className::of($data);
443  }
444 
445  return $this->oldValue;
446  }
447 
448 
452  public function setId(?string $id): void
453  {
454  $this->id = $id;
455  }
456 
460  public function setVersion(?int $version): void
461  {
462  $this->version = $version;
463  }
464 
468  public function setCreatedAt(?DateTimeImmutable $createdAt): void
469  {
470  $this->createdAt = $createdAt;
471  }
472 
476  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
477  {
478  $this->lastModifiedAt = $lastModifiedAt;
479  }
480 
485  {
486  $this->lastModifiedBy = $lastModifiedBy;
487  }
488 
492  public function setCreatedBy(?CreatedBy $createdBy): void
493  {
494  $this->createdBy = $createdBy;
495  }
496 
500  public function setSequenceNumber(?int $sequenceNumber): void
501  {
502  $this->sequenceNumber = $sequenceNumber;
503  }
504 
508  public function setResource(?Reference $resource): void
509  {
510  $this->resource = $resource;
511  }
512 
516  public function setResourceVersion(?int $resourceVersion): void
517  {
518  $this->resourceVersion = $resourceVersion;
519  }
520 
525  {
526  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
527  }
528 
532  public function setValue(?TypedMoney $value): void
533  {
534  $this->value = $value;
535  }
536 
540  public function setStaged(?bool $staged): void
541  {
542  $this->staged = $staged;
543  }
544 
548  public function setOldValue(?TypedMoney $oldValue): void
549  {
550  $this->oldValue = $oldValue;
551  }
552 
553 
554  #[\ReturnTypeWillChange]
555  public function jsonSerialize()
556  {
557  $data = $this->toArray();
558  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
559  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
560  }
561 
562  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
563  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
564  }
565  return (object) $data;
566  }
567 }
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, ?TypedMoney $value=null, ?bool $staged=null, ?TypedMoney $oldValue=null, ?string $type=null)