commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ShippingMethodModel.php
1<?php
2
3declare(strict_types=1);
10
28use DateTimeImmutable;
29use stdClass;
30
35{
40 protected $id;
41
46 protected $version;
47
52 protected $createdAt;
53
58 protected $lastModifiedAt;
59
64 protected $lastModifiedBy;
65
70 protected $createdBy;
71
76 protected $key;
77
82 protected $name;
83
88 protected $localizedName;
89
94 protected $description;
95
101
106 protected $taxCategory;
107
112 protected $zoneRates;
113
118 protected $active;
119
124 protected $isDefault;
125
130 protected $predicate;
131
136 protected $custom;
137
142 protected $stores;
143
148 protected $carrier;
149
150
154 public function __construct(
155 ?string $id = null,
156 ?int $version = null,
157 ?DateTimeImmutable $createdAt = null,
158 ?DateTimeImmutable $lastModifiedAt = null,
160 ?CreatedBy $createdBy = null,
161 ?string $key = null,
162 ?string $name = null,
164 ?string $description = null,
168 ?bool $active = null,
169 ?bool $isDefault = null,
170 ?string $predicate = null,
171 ?CustomFields $custom = null,
173 ?string $carrier = null
174 ) {
175 $this->id = $id;
176 $this->version = $version;
177 $this->createdAt = $createdAt;
178 $this->lastModifiedAt = $lastModifiedAt;
179 $this->lastModifiedBy = $lastModifiedBy;
180 $this->createdBy = $createdBy;
181 $this->key = $key;
182 $this->name = $name;
183 $this->localizedName = $localizedName;
184 $this->description = $description;
185 $this->localizedDescription = $localizedDescription;
186 $this->taxCategory = $taxCategory;
187 $this->zoneRates = $zoneRates;
188 $this->active = $active;
189 $this->isDefault = $isDefault;
190 $this->predicate = $predicate;
191 $this->custom = $custom;
192 $this->stores = $stores;
193 $this->carrier = $carrier;
194 }
195
202 public function getId()
203 {
204 if (is_null($this->id)) {
206 $data = $this->raw(self::FIELD_ID);
207 if (is_null($data)) {
208 return null;
209 }
210 $this->id = (string) $data;
211 }
212
213 return $this->id;
214 }
215
222 public function getVersion()
223 {
224 if (is_null($this->version)) {
226 $data = $this->raw(self::FIELD_VERSION);
227 if (is_null($data)) {
228 return null;
229 }
230 $this->version = (int) $data;
231 }
232
233 return $this->version;
234 }
235
242 public function getCreatedAt()
243 {
244 if (is_null($this->createdAt)) {
246 $data = $this->raw(self::FIELD_CREATED_AT);
247 if (is_null($data)) {
248 return null;
249 }
250 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
251 if (false === $data) {
252 return null;
253 }
254 $this->createdAt = $data;
255 }
256
257 return $this->createdAt;
258 }
259
266 public function getLastModifiedAt()
267 {
268 if (is_null($this->lastModifiedAt)) {
270 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
271 if (is_null($data)) {
272 return null;
273 }
274 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
275 if (false === $data) {
276 return null;
277 }
278 $this->lastModifiedAt = $data;
279 }
280
282 }
283
290 public function getLastModifiedBy()
291 {
292 if (is_null($this->lastModifiedBy)) {
294 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
295 if (is_null($data)) {
296 return null;
297 }
298
299 $this->lastModifiedBy = LastModifiedByModel::of($data);
300 }
301
303 }
304
311 public function getCreatedBy()
312 {
313 if (is_null($this->createdBy)) {
315 $data = $this->raw(self::FIELD_CREATED_BY);
316 if (is_null($data)) {
317 return null;
318 }
319
320 $this->createdBy = CreatedByModel::of($data);
321 }
322
323 return $this->createdBy;
324 }
325
332 public function getKey()
333 {
334 if (is_null($this->key)) {
336 $data = $this->raw(self::FIELD_KEY);
337 if (is_null($data)) {
338 return null;
339 }
340 $this->key = (string) $data;
341 }
342
343 return $this->key;
344 }
345
352 public function getName()
353 {
354 if (is_null($this->name)) {
356 $data = $this->raw(self::FIELD_NAME);
357 if (is_null($data)) {
358 return null;
359 }
360 $this->name = (string) $data;
361 }
362
363 return $this->name;
364 }
365
372 public function getLocalizedName()
373 {
374 if (is_null($this->localizedName)) {
376 $data = $this->raw(self::FIELD_LOCALIZED_NAME);
377 if (is_null($data)) {
378 return null;
379 }
380
381 $this->localizedName = LocalizedStringModel::of($data);
382 }
383
385 }
386
393 public function getDescription()
394 {
395 if (is_null($this->description)) {
397 $data = $this->raw(self::FIELD_DESCRIPTION);
398 if (is_null($data)) {
399 return null;
400 }
401 $this->description = (string) $data;
402 }
403
404 return $this->description;
405 }
406
413 public function getLocalizedDescription()
414 {
415 if (is_null($this->localizedDescription)) {
417 $data = $this->raw(self::FIELD_LOCALIZED_DESCRIPTION);
418 if (is_null($data)) {
419 return null;
420 }
421
422 $this->localizedDescription = LocalizedStringModel::of($data);
423 }
424
426 }
427
434 public function getTaxCategory()
435 {
436 if (is_null($this->taxCategory)) {
438 $data = $this->raw(self::FIELD_TAX_CATEGORY);
439 if (is_null($data)) {
440 return null;
441 }
442
443 $this->taxCategory = TaxCategoryReferenceModel::of($data);
444 }
445
446 return $this->taxCategory;
447 }
448
455 public function getZoneRates()
456 {
457 if (is_null($this->zoneRates)) {
459 $data = $this->raw(self::FIELD_ZONE_RATES);
460 if (is_null($data)) {
461 return null;
462 }
463 $this->zoneRates = ZoneRateCollection::fromArray($data);
464 }
465
466 return $this->zoneRates;
467 }
468
476 public function getActive()
477 {
478 if (is_null($this->active)) {
480 $data = $this->raw(self::FIELD_ACTIVE);
481 if (is_null($data)) {
482 return null;
483 }
484 $this->active = (bool) $data;
485 }
486
487 return $this->active;
488 }
489
496 public function getIsDefault()
497 {
498 if (is_null($this->isDefault)) {
500 $data = $this->raw(self::FIELD_IS_DEFAULT);
501 if (is_null($data)) {
502 return null;
503 }
504 $this->isDefault = (bool) $data;
505 }
506
507 return $this->isDefault;
508 }
509
516 public function getPredicate()
517 {
518 if (is_null($this->predicate)) {
520 $data = $this->raw(self::FIELD_PREDICATE);
521 if (is_null($data)) {
522 return null;
523 }
524 $this->predicate = (string) $data;
525 }
526
527 return $this->predicate;
528 }
529
536 public function getCustom()
537 {
538 if (is_null($this->custom)) {
540 $data = $this->raw(self::FIELD_CUSTOM);
541 if (is_null($data)) {
542 return null;
543 }
544
545 $this->custom = CustomFieldsModel::of($data);
546 }
547
548 return $this->custom;
549 }
550
560 public function getStores()
561 {
562 if (is_null($this->stores)) {
564 $data = $this->raw(self::FIELD_STORES);
565 if (is_null($data)) {
566 return null;
567 }
568 $this->stores = StoreKeyReferenceCollection::fromArray($data);
569 }
570
571 return $this->stores;
572 }
573
580 public function getCarrier()
581 {
582 if (is_null($this->carrier)) {
584 $data = $this->raw(self::FIELD_CARRIER);
585 if (is_null($data)) {
586 return null;
587 }
588 $this->carrier = (string) $data;
589 }
590
591 return $this->carrier;
592 }
593
594
598 public function setId(?string $id): void
599 {
600 $this->id = $id;
601 }
602
606 public function setVersion(?int $version): void
607 {
608 $this->version = $version;
609 }
610
614 public function setCreatedAt(?DateTimeImmutable $createdAt): void
615 {
616 $this->createdAt = $createdAt;
617 }
618
622 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
623 {
624 $this->lastModifiedAt = $lastModifiedAt;
625 }
626
631 {
632 $this->lastModifiedBy = $lastModifiedBy;
633 }
634
638 public function setCreatedBy(?CreatedBy $createdBy): void
639 {
640 $this->createdBy = $createdBy;
641 }
642
646 public function setKey(?string $key): void
647 {
648 $this->key = $key;
649 }
650
654 public function setName(?string $name): void
655 {
656 $this->name = $name;
657 }
658
663 {
664 $this->localizedName = $localizedName;
665 }
666
670 public function setDescription(?string $description): void
671 {
672 $this->description = $description;
673 }
674
679 {
680 $this->localizedDescription = $localizedDescription;
681 }
682
687 {
688 $this->taxCategory = $taxCategory;
689 }
690
695 {
696 $this->zoneRates = $zoneRates;
697 }
698
702 public function setActive(?bool $active): void
703 {
704 $this->active = $active;
705 }
706
710 public function setIsDefault(?bool $isDefault): void
711 {
712 $this->isDefault = $isDefault;
713 }
714
718 public function setPredicate(?string $predicate): void
719 {
720 $this->predicate = $predicate;
721 }
722
726 public function setCustom(?CustomFields $custom): void
727 {
728 $this->custom = $custom;
729 }
730
735 {
736 $this->stores = $stores;
737 }
738
742 public function setCarrier(?string $carrier): void
743 {
744 $this->carrier = $carrier;
745 }
746
747
748 #[\ReturnTypeWillChange]
749 public function jsonSerialize()
750 {
751 $data = $this->toArray();
752 if (isset($data[ShippingMethod::FIELD_CREATED_AT]) && $data[ShippingMethod::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
753 $data[ShippingMethod::FIELD_CREATED_AT] = $data[ShippingMethod::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
754 }
755
756 if (isset($data[ShippingMethod::FIELD_LAST_MODIFIED_AT]) && $data[ShippingMethod::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
757 $data[ShippingMethod::FIELD_LAST_MODIFIED_AT] = $data[ShippingMethod::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
758 }
759 return (object) $data;
760 }
761}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?string $name=null, ?LocalizedString $localizedName=null, ?string $description=null, ?LocalizedString $localizedDescription=null, ?TaxCategoryReference $taxCategory=null, ?ZoneRateCollection $zoneRates=null, ?bool $active=null, ?bool $isDefault=null, ?string $predicate=null, ?CustomFields $custom=null, ?StoreKeyReferenceCollection $stores=null, ?string $carrier=null)
setLocalizedDescription(?LocalizedString $localizedDescription)
static fromArray(array $data)