commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
StandalonePriceModel.php
1<?php
2
3declare(strict_types=1);
10
34use DateTimeImmutable;
35use stdClass;
36
41{
46 protected $id;
47
52 protected $version;
53
58 protected $createdAt;
59
64 protected $lastModifiedAt;
65
70 protected $lastModifiedBy;
71
76 protected $createdBy;
77
82 protected $key;
83
88 protected $sku;
89
94 protected $value;
95
100 protected $country;
101
106 protected $customerGroup;
107
112 protected $channel;
113
118 protected $validFrom;
119
124 protected $validUntil;
125
130 protected $tiers;
131
136 protected $discounted;
137
142 protected $custom;
143
148 protected $staged;
149
154 protected $active;
155
161
162
166 public function __construct(
167 ?string $id = null,
168 ?int $version = null,
169 ?DateTimeImmutable $createdAt = null,
170 ?DateTimeImmutable $lastModifiedAt = null,
172 ?CreatedBy $createdBy = null,
173 ?string $key = null,
174 ?string $sku = null,
175 ?TypedMoney $value = null,
176 ?string $country = null,
179 ?DateTimeImmutable $validFrom = null,
180 ?DateTimeImmutable $validUntil = null,
183 ?CustomFields $custom = null,
185 ?bool $active = null,
187 ) {
188 $this->id = $id;
189 $this->version = $version;
190 $this->createdAt = $createdAt;
191 $this->lastModifiedAt = $lastModifiedAt;
192 $this->lastModifiedBy = $lastModifiedBy;
193 $this->createdBy = $createdBy;
194 $this->key = $key;
195 $this->sku = $sku;
196 $this->value = $value;
197 $this->country = $country;
198 $this->customerGroup = $customerGroup;
199 $this->channel = $channel;
200 $this->validFrom = $validFrom;
201 $this->validUntil = $validUntil;
202 $this->tiers = $tiers;
203 $this->discounted = $discounted;
204 $this->custom = $custom;
205 $this->staged = $staged;
206 $this->active = $active;
207 $this->recurrencePolicy = $recurrencePolicy;
208 }
209
216 public function getId()
217 {
218 if (is_null($this->id)) {
220 $data = $this->raw(self::FIELD_ID);
221 if (is_null($data)) {
222 return null;
223 }
224 $this->id = (string) $data;
225 }
226
227 return $this->id;
228 }
229
236 public function getVersion()
237 {
238 if (is_null($this->version)) {
240 $data = $this->raw(self::FIELD_VERSION);
241 if (is_null($data)) {
242 return null;
243 }
244 $this->version = (int) $data;
245 }
246
247 return $this->version;
248 }
249
256 public function getCreatedAt()
257 {
258 if (is_null($this->createdAt)) {
260 $data = $this->raw(self::FIELD_CREATED_AT);
261 if (is_null($data)) {
262 return null;
263 }
264 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
265 if (false === $data) {
266 return null;
267 }
268 $this->createdAt = $data;
269 }
270
271 return $this->createdAt;
272 }
273
280 public function getLastModifiedAt()
281 {
282 if (is_null($this->lastModifiedAt)) {
284 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
285 if (is_null($data)) {
286 return null;
287 }
288 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
289 if (false === $data) {
290 return null;
291 }
292 $this->lastModifiedAt = $data;
293 }
294
296 }
297
304 public function getLastModifiedBy()
305 {
306 if (is_null($this->lastModifiedBy)) {
308 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
309 if (is_null($data)) {
310 return null;
311 }
312
313 $this->lastModifiedBy = LastModifiedByModel::of($data);
314 }
315
317 }
318
325 public function getCreatedBy()
326 {
327 if (is_null($this->createdBy)) {
329 $data = $this->raw(self::FIELD_CREATED_BY);
330 if (is_null($data)) {
331 return null;
332 }
333
334 $this->createdBy = CreatedByModel::of($data);
335 }
336
337 return $this->createdBy;
338 }
339
346 public function getKey()
347 {
348 if (is_null($this->key)) {
350 $data = $this->raw(self::FIELD_KEY);
351 if (is_null($data)) {
352 return null;
353 }
354 $this->key = (string) $data;
355 }
356
357 return $this->key;
358 }
359
366 public function getSku()
367 {
368 if (is_null($this->sku)) {
370 $data = $this->raw(self::FIELD_SKU);
371 if (is_null($data)) {
372 return null;
373 }
374 $this->sku = (string) $data;
375 }
376
377 return $this->sku;
378 }
379
386 public function getValue()
387 {
388 if (is_null($this->value)) {
390 $data = $this->raw(self::FIELD_VALUE);
391 if (is_null($data)) {
392 return null;
393 }
394 $className = TypedMoneyModel::resolveDiscriminatorClass($data);
395 $this->value = $className::of($data);
396 }
397
398 return $this->value;
399 }
400
407 public function getCountry()
408 {
409 if (is_null($this->country)) {
411 $data = $this->raw(self::FIELD_COUNTRY);
412 if (is_null($data)) {
413 return null;
414 }
415 $this->country = (string) $data;
416 }
417
418 return $this->country;
419 }
420
427 public function getCustomerGroup()
428 {
429 if (is_null($this->customerGroup)) {
431 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
432 if (is_null($data)) {
433 return null;
434 }
435
436 $this->customerGroup = CustomerGroupReferenceModel::of($data);
437 }
438
440 }
441
448 public function getChannel()
449 {
450 if (is_null($this->channel)) {
452 $data = $this->raw(self::FIELD_CHANNEL);
453 if (is_null($data)) {
454 return null;
455 }
456
457 $this->channel = ChannelReferenceModel::of($data);
458 }
459
460 return $this->channel;
461 }
462
469 public function getValidFrom()
470 {
471 if (is_null($this->validFrom)) {
473 $data = $this->raw(self::FIELD_VALID_FROM);
474 if (is_null($data)) {
475 return null;
476 }
477 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
478 if (false === $data) {
479 return null;
480 }
481 $this->validFrom = $data;
482 }
483
484 return $this->validFrom;
485 }
486
493 public function getValidUntil()
494 {
495 if (is_null($this->validUntil)) {
497 $data = $this->raw(self::FIELD_VALID_UNTIL);
498 if (is_null($data)) {
499 return null;
500 }
501 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
502 if (false === $data) {
503 return null;
504 }
505 $this->validUntil = $data;
506 }
507
508 return $this->validUntil;
509 }
510
518 public function getTiers()
519 {
520 if (is_null($this->tiers)) {
522 $data = $this->raw(self::FIELD_TIERS);
523 if (is_null($data)) {
524 return null;
525 }
526 $this->tiers = PriceTierCollection::fromArray($data);
527 }
528
529 return $this->tiers;
530 }
531
540 public function getDiscounted()
541 {
542 if (is_null($this->discounted)) {
544 $data = $this->raw(self::FIELD_DISCOUNTED);
545 if (is_null($data)) {
546 return null;
547 }
548
549 $this->discounted = DiscountedPriceModel::of($data);
550 }
551
552 return $this->discounted;
553 }
554
561 public function getCustom()
562 {
563 if (is_null($this->custom)) {
565 $data = $this->raw(self::FIELD_CUSTOM);
566 if (is_null($data)) {
567 return null;
568 }
569
570 $this->custom = CustomFieldsModel::of($data);
571 }
572
573 return $this->custom;
574 }
575
582 public function getStaged()
583 {
584 if (is_null($this->staged)) {
586 $data = $this->raw(self::FIELD_STAGED);
587 if (is_null($data)) {
588 return null;
589 }
590
591 $this->staged = StagedStandalonePriceModel::of($data);
592 }
593
594 return $this->staged;
595 }
596
604 public function getActive()
605 {
606 if (is_null($this->active)) {
608 $data = $this->raw(self::FIELD_ACTIVE);
609 if (is_null($data)) {
610 return null;
611 }
612 $this->active = (bool) $data;
613 }
614
615 return $this->active;
616 }
617
624 public function getRecurrencePolicy()
625 {
626 if (is_null($this->recurrencePolicy)) {
628 $data = $this->raw(self::FIELD_RECURRENCE_POLICY);
629 if (is_null($data)) {
630 return null;
631 }
632
633 $this->recurrencePolicy = RecurrencePolicyReferenceModel::of($data);
634 }
635
637 }
638
639
643 public function setId(?string $id): void
644 {
645 $this->id = $id;
646 }
647
651 public function setVersion(?int $version): void
652 {
653 $this->version = $version;
654 }
655
659 public function setCreatedAt(?DateTimeImmutable $createdAt): void
660 {
661 $this->createdAt = $createdAt;
662 }
663
667 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
668 {
669 $this->lastModifiedAt = $lastModifiedAt;
670 }
671
676 {
677 $this->lastModifiedBy = $lastModifiedBy;
678 }
679
683 public function setCreatedBy(?CreatedBy $createdBy): void
684 {
685 $this->createdBy = $createdBy;
686 }
687
691 public function setKey(?string $key): void
692 {
693 $this->key = $key;
694 }
695
699 public function setSku(?string $sku): void
700 {
701 $this->sku = $sku;
702 }
703
707 public function setValue(?TypedMoney $value): void
708 {
709 $this->value = $value;
710 }
711
715 public function setCountry(?string $country): void
716 {
717 $this->country = $country;
718 }
719
724 {
725 $this->customerGroup = $customerGroup;
726 }
727
731 public function setChannel(?ChannelReference $channel): void
732 {
733 $this->channel = $channel;
734 }
735
739 public function setValidFrom(?DateTimeImmutable $validFrom): void
740 {
741 $this->validFrom = $validFrom;
742 }
743
747 public function setValidUntil(?DateTimeImmutable $validUntil): void
748 {
749 $this->validUntil = $validUntil;
750 }
751
755 public function setTiers(?PriceTierCollection $tiers): void
756 {
757 $this->tiers = $tiers;
758 }
759
764 {
765 $this->discounted = $discounted;
766 }
767
771 public function setCustom(?CustomFields $custom): void
772 {
773 $this->custom = $custom;
774 }
775
780 {
781 $this->staged = $staged;
782 }
783
787 public function setActive(?bool $active): void
788 {
789 $this->active = $active;
790 }
791
796 {
797 $this->recurrencePolicy = $recurrencePolicy;
798 }
799
800
801 #[\ReturnTypeWillChange]
802 public function jsonSerialize()
803 {
804 $data = $this->toArray();
805 if (isset($data[StandalonePrice::FIELD_CREATED_AT]) && $data[StandalonePrice::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
806 $data[StandalonePrice::FIELD_CREATED_AT] = $data[StandalonePrice::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
807 }
808
809 if (isset($data[StandalonePrice::FIELD_LAST_MODIFIED_AT]) && $data[StandalonePrice::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
810 $data[StandalonePrice::FIELD_LAST_MODIFIED_AT] = $data[StandalonePrice::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
811 }
812
813 if (isset($data[StandalonePrice::FIELD_VALID_FROM]) && $data[StandalonePrice::FIELD_VALID_FROM] instanceof \DateTimeImmutable) {
814 $data[StandalonePrice::FIELD_VALID_FROM] = $data[StandalonePrice::FIELD_VALID_FROM]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
815 }
816
817 if (isset($data[StandalonePrice::FIELD_VALID_UNTIL]) && $data[StandalonePrice::FIELD_VALID_UNTIL] instanceof \DateTimeImmutable) {
818 $data[StandalonePrice::FIELD_VALID_UNTIL] = $data[StandalonePrice::FIELD_VALID_UNTIL]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
819 }
820 return (object) $data;
821 }
822}
setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?string $sku=null, ?TypedMoney $value=null, ?string $country=null, ?CustomerGroupReference $customerGroup=null, ?ChannelReference $channel=null, ?DateTimeImmutable $validFrom=null, ?DateTimeImmutable $validUntil=null, ?PriceTierCollection $tiers=null, ?DiscountedPrice $discounted=null, ?CustomFields $custom=null, ?StagedStandalonePrice $staged=null, ?bool $active=null, ?RecurrencePolicyReference $recurrencePolicy=null)