commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StandalonePriceTiersSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
22 use DateTimeImmutable;
23 use stdClass;
24 
29 {
30  public const DISCRIMINATOR_VALUE = 'StandalonePriceTiersSet';
35  protected $id;
36 
41  protected $version;
42 
47  protected $createdAt;
48 
53  protected $lastModifiedAt;
54 
59  protected $lastModifiedBy;
60 
65  protected $createdBy;
66 
71  protected $sequenceNumber;
72 
77  protected $resource;
78 
83  protected $resourceVersion;
84 
89  protected $type;
90 
96 
101  protected $tiers;
102 
107  protected $previousTiers;
108 
109 
113  public function __construct(
114  ?string $id = null,
115  ?int $version = null,
116  ?DateTimeImmutable $createdAt = null,
117  ?DateTimeImmutable $lastModifiedAt = null,
119  ?CreatedBy $createdBy = null,
120  ?int $sequenceNumber = null,
121  ?Reference $resource = null,
122  ?int $resourceVersion = null,
124  ?PriceTierCollection $tiers = null,
126  ?string $type = null
127  ) {
128  $this->id = $id;
129  $this->version = $version;
130  $this->createdAt = $createdAt;
131  $this->lastModifiedAt = $lastModifiedAt;
132  $this->lastModifiedBy = $lastModifiedBy;
133  $this->createdBy = $createdBy;
134  $this->sequenceNumber = $sequenceNumber;
135  $this->resource = $resource;
136  $this->resourceVersion = $resourceVersion;
137  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
138  $this->tiers = $tiers;
139  $this->previousTiers = $previousTiers;
140  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
141  }
142 
149  public function getId()
150  {
151  if (is_null($this->id)) {
153  $data = $this->raw(self::FIELD_ID);
154  if (is_null($data)) {
155  return null;
156  }
157  $this->id = (string) $data;
158  }
159 
160  return $this->id;
161  }
162 
169  public function getVersion()
170  {
171  if (is_null($this->version)) {
173  $data = $this->raw(self::FIELD_VERSION);
174  if (is_null($data)) {
175  return null;
176  }
177  $this->version = (int) $data;
178  }
179 
180  return $this->version;
181  }
182 
189  public function getCreatedAt()
190  {
191  if (is_null($this->createdAt)) {
193  $data = $this->raw(self::FIELD_CREATED_AT);
194  if (is_null($data)) {
195  return null;
196  }
197  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
198  if (false === $data) {
199  return null;
200  }
201  $this->createdAt = $data;
202  }
203 
204  return $this->createdAt;
205  }
206 
213  public function getLastModifiedAt()
214  {
215  if (is_null($this->lastModifiedAt)) {
217  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
218  if (is_null($data)) {
219  return null;
220  }
221  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
222  if (false === $data) {
223  return null;
224  }
225  $this->lastModifiedAt = $data;
226  }
227 
228  return $this->lastModifiedAt;
229  }
230 
237  public function getLastModifiedBy()
238  {
239  if (is_null($this->lastModifiedBy)) {
241  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
242  if (is_null($data)) {
243  return null;
244  }
245 
246  $this->lastModifiedBy = LastModifiedByModel::of($data);
247  }
248 
249  return $this->lastModifiedBy;
250  }
251 
258  public function getCreatedBy()
259  {
260  if (is_null($this->createdBy)) {
262  $data = $this->raw(self::FIELD_CREATED_BY);
263  if (is_null($data)) {
264  return null;
265  }
266 
267  $this->createdBy = CreatedByModel::of($data);
268  }
269 
270  return $this->createdBy;
271  }
272 
280  public function getSequenceNumber()
281  {
282  if (is_null($this->sequenceNumber)) {
284  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
285  if (is_null($data)) {
286  return null;
287  }
288  $this->sequenceNumber = (int) $data;
289  }
290 
291  return $this->sequenceNumber;
292  }
293 
300  public function getResource()
301  {
302  if (is_null($this->resource)) {
304  $data = $this->raw(self::FIELD_RESOURCE);
305  if (is_null($data)) {
306  return null;
307  }
308  $className = ReferenceModel::resolveDiscriminatorClass($data);
309  $this->resource = $className::of($data);
310  }
311 
312  return $this->resource;
313  }
314 
321  public function getResourceVersion()
322  {
323  if (is_null($this->resourceVersion)) {
325  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
326  if (is_null($data)) {
327  return null;
328  }
329  $this->resourceVersion = (int) $data;
330  }
331 
332  return $this->resourceVersion;
333  }
334 
341  public function getType()
342  {
343  if (is_null($this->type)) {
345  $data = $this->raw(self::FIELD_TYPE);
346  if (is_null($data)) {
347  return null;
348  }
349  $this->type = (string) $data;
350  }
351 
352  return $this->type;
353  }
354 
362  {
363  if (is_null($this->resourceUserProvidedIdentifiers)) {
365  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
366  if (is_null($data)) {
367  return null;
368  }
369 
370  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
371  }
372 
374  }
375 
382  public function getTiers()
383  {
384  if (is_null($this->tiers)) {
386  $data = $this->raw(self::FIELD_TIERS);
387  if (is_null($data)) {
388  return null;
389  }
390  $this->tiers = PriceTierCollection::fromArray($data);
391  }
392 
393  return $this->tiers;
394  }
395 
402  public function getPreviousTiers()
403  {
404  if (is_null($this->previousTiers)) {
406  $data = $this->raw(self::FIELD_PREVIOUS_TIERS);
407  if (is_null($data)) {
408  return null;
409  }
410  $this->previousTiers = PriceTierCollection::fromArray($data);
411  }
412 
413  return $this->previousTiers;
414  }
415 
416 
420  public function setId(?string $id): void
421  {
422  $this->id = $id;
423  }
424 
428  public function setVersion(?int $version): void
429  {
430  $this->version = $version;
431  }
432 
436  public function setCreatedAt(?DateTimeImmutable $createdAt): void
437  {
438  $this->createdAt = $createdAt;
439  }
440 
444  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
445  {
446  $this->lastModifiedAt = $lastModifiedAt;
447  }
448 
453  {
454  $this->lastModifiedBy = $lastModifiedBy;
455  }
456 
460  public function setCreatedBy(?CreatedBy $createdBy): void
461  {
462  $this->createdBy = $createdBy;
463  }
464 
468  public function setSequenceNumber(?int $sequenceNumber): void
469  {
470  $this->sequenceNumber = $sequenceNumber;
471  }
472 
476  public function setResource(?Reference $resource): void
477  {
478  $this->resource = $resource;
479  }
480 
484  public function setResourceVersion(?int $resourceVersion): void
485  {
486  $this->resourceVersion = $resourceVersion;
487  }
488 
493  {
494  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
495  }
496 
500  public function setTiers(?PriceTierCollection $tiers): void
501  {
502  $this->tiers = $tiers;
503  }
504 
509  {
510  $this->previousTiers = $previousTiers;
511  }
512 
513 
514  #[\ReturnTypeWillChange]
515  public function jsonSerialize()
516  {
517  $data = $this->toArray();
518  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
519  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
520  }
521 
522  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
523  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
524  }
525  return (object) $data;
526  }
527 }
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, ?PriceTierCollection $tiers=null, ?PriceTierCollection $previousTiers=null, ?string $type=null)