commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ShippingMethodModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
27 use DateTimeImmutable;
28 use stdClass;
29 
33 final class ShippingMethodModel extends JsonObjectModel implements ShippingMethod
34 {
39  protected $id;
40 
45  protected $version;
46 
51  protected $createdAt;
52 
57  protected $lastModifiedAt;
58 
63  protected $lastModifiedBy;
64 
69  protected $createdBy;
70 
75  protected $key;
76 
81  protected $name;
82 
87  protected $localizedName;
88 
93  protected $description;
94 
100 
105  protected $taxCategory;
106 
111  protected $zoneRates;
112 
117  protected $active;
118 
123  protected $isDefault;
124 
129  protected $predicate;
130 
135  protected $custom;
136 
137 
141  public function __construct(
142  ?string $id = null,
143  ?int $version = null,
144  ?DateTimeImmutable $createdAt = null,
145  ?DateTimeImmutable $lastModifiedAt = null,
147  ?CreatedBy $createdBy = null,
148  ?string $key = null,
149  ?string $name = null,
151  ?string $description = null,
155  ?bool $active = null,
156  ?bool $isDefault = null,
157  ?string $predicate = null,
158  ?CustomFields $custom = null
159  ) {
160  $this->id = $id;
161  $this->version = $version;
162  $this->createdAt = $createdAt;
163  $this->lastModifiedAt = $lastModifiedAt;
164  $this->lastModifiedBy = $lastModifiedBy;
165  $this->createdBy = $createdBy;
166  $this->key = $key;
167  $this->name = $name;
168  $this->localizedName = $localizedName;
169  $this->description = $description;
170  $this->localizedDescription = $localizedDescription;
171  $this->taxCategory = $taxCategory;
172  $this->zoneRates = $zoneRates;
173  $this->active = $active;
174  $this->isDefault = $isDefault;
175  $this->predicate = $predicate;
176  $this->custom = $custom;
177  }
178 
185  public function getId()
186  {
187  if (is_null($this->id)) {
189  $data = $this->raw(self::FIELD_ID);
190  if (is_null($data)) {
191  return null;
192  }
193  $this->id = (string) $data;
194  }
195 
196  return $this->id;
197  }
198 
205  public function getVersion()
206  {
207  if (is_null($this->version)) {
209  $data = $this->raw(self::FIELD_VERSION);
210  if (is_null($data)) {
211  return null;
212  }
213  $this->version = (int) $data;
214  }
215 
216  return $this->version;
217  }
218 
225  public function getCreatedAt()
226  {
227  if (is_null($this->createdAt)) {
229  $data = $this->raw(self::FIELD_CREATED_AT);
230  if (is_null($data)) {
231  return null;
232  }
233  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
234  if (false === $data) {
235  return null;
236  }
237  $this->createdAt = $data;
238  }
239 
240  return $this->createdAt;
241  }
242 
249  public function getLastModifiedAt()
250  {
251  if (is_null($this->lastModifiedAt)) {
253  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
254  if (is_null($data)) {
255  return null;
256  }
257  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
258  if (false === $data) {
259  return null;
260  }
261  $this->lastModifiedAt = $data;
262  }
263 
264  return $this->lastModifiedAt;
265  }
266 
273  public function getLastModifiedBy()
274  {
275  if (is_null($this->lastModifiedBy)) {
277  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
278  if (is_null($data)) {
279  return null;
280  }
281 
282  $this->lastModifiedBy = LastModifiedByModel::of($data);
283  }
284 
285  return $this->lastModifiedBy;
286  }
287 
294  public function getCreatedBy()
295  {
296  if (is_null($this->createdBy)) {
298  $data = $this->raw(self::FIELD_CREATED_BY);
299  if (is_null($data)) {
300  return null;
301  }
302 
303  $this->createdBy = CreatedByModel::of($data);
304  }
305 
306  return $this->createdBy;
307  }
308 
315  public function getKey()
316  {
317  if (is_null($this->key)) {
319  $data = $this->raw(self::FIELD_KEY);
320  if (is_null($data)) {
321  return null;
322  }
323  $this->key = (string) $data;
324  }
325 
326  return $this->key;
327  }
328 
335  public function getName()
336  {
337  if (is_null($this->name)) {
339  $data = $this->raw(self::FIELD_NAME);
340  if (is_null($data)) {
341  return null;
342  }
343  $this->name = (string) $data;
344  }
345 
346  return $this->name;
347  }
348 
355  public function getLocalizedName()
356  {
357  if (is_null($this->localizedName)) {
359  $data = $this->raw(self::FIELD_LOCALIZED_NAME);
360  if (is_null($data)) {
361  return null;
362  }
363 
364  $this->localizedName = LocalizedStringModel::of($data);
365  }
366 
367  return $this->localizedName;
368  }
369 
376  public function getDescription()
377  {
378  if (is_null($this->description)) {
380  $data = $this->raw(self::FIELD_DESCRIPTION);
381  if (is_null($data)) {
382  return null;
383  }
384  $this->description = (string) $data;
385  }
386 
387  return $this->description;
388  }
389 
396  public function getLocalizedDescription()
397  {
398  if (is_null($this->localizedDescription)) {
400  $data = $this->raw(self::FIELD_LOCALIZED_DESCRIPTION);
401  if (is_null($data)) {
402  return null;
403  }
404 
405  $this->localizedDescription = LocalizedStringModel::of($data);
406  }
407 
409  }
410 
417  public function getTaxCategory()
418  {
419  if (is_null($this->taxCategory)) {
421  $data = $this->raw(self::FIELD_TAX_CATEGORY);
422  if (is_null($data)) {
423  return null;
424  }
425 
426  $this->taxCategory = TaxCategoryReferenceModel::of($data);
427  }
428 
429  return $this->taxCategory;
430  }
431 
438  public function getZoneRates()
439  {
440  if (is_null($this->zoneRates)) {
442  $data = $this->raw(self::FIELD_ZONE_RATES);
443  if (is_null($data)) {
444  return null;
445  }
446  $this->zoneRates = ZoneRateCollection::fromArray($data);
447  }
448 
449  return $this->zoneRates;
450  }
451 
459  public function getActive()
460  {
461  if (is_null($this->active)) {
463  $data = $this->raw(self::FIELD_ACTIVE);
464  if (is_null($data)) {
465  return null;
466  }
467  $this->active = (bool) $data;
468  }
469 
470  return $this->active;
471  }
472 
479  public function getIsDefault()
480  {
481  if (is_null($this->isDefault)) {
483  $data = $this->raw(self::FIELD_IS_DEFAULT);
484  if (is_null($data)) {
485  return null;
486  }
487  $this->isDefault = (bool) $data;
488  }
489 
490  return $this->isDefault;
491  }
492 
499  public function getPredicate()
500  {
501  if (is_null($this->predicate)) {
503  $data = $this->raw(self::FIELD_PREDICATE);
504  if (is_null($data)) {
505  return null;
506  }
507  $this->predicate = (string) $data;
508  }
509 
510  return $this->predicate;
511  }
512 
519  public function getCustom()
520  {
521  if (is_null($this->custom)) {
523  $data = $this->raw(self::FIELD_CUSTOM);
524  if (is_null($data)) {
525  return null;
526  }
527 
528  $this->custom = CustomFieldsModel::of($data);
529  }
530 
531  return $this->custom;
532  }
533 
534 
538  public function setId(?string $id): void
539  {
540  $this->id = $id;
541  }
542 
546  public function setVersion(?int $version): void
547  {
548  $this->version = $version;
549  }
550 
554  public function setCreatedAt(?DateTimeImmutable $createdAt): void
555  {
556  $this->createdAt = $createdAt;
557  }
558 
562  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
563  {
564  $this->lastModifiedAt = $lastModifiedAt;
565  }
566 
571  {
572  $this->lastModifiedBy = $lastModifiedBy;
573  }
574 
578  public function setCreatedBy(?CreatedBy $createdBy): void
579  {
580  $this->createdBy = $createdBy;
581  }
582 
586  public function setKey(?string $key): void
587  {
588  $this->key = $key;
589  }
590 
594  public function setName(?string $name): void
595  {
596  $this->name = $name;
597  }
598 
603  {
604  $this->localizedName = $localizedName;
605  }
606 
610  public function setDescription(?string $description): void
611  {
612  $this->description = $description;
613  }
614 
619  {
620  $this->localizedDescription = $localizedDescription;
621  }
622 
627  {
628  $this->taxCategory = $taxCategory;
629  }
630 
635  {
636  $this->zoneRates = $zoneRates;
637  }
638 
642  public function setActive(?bool $active): void
643  {
644  $this->active = $active;
645  }
646 
650  public function setIsDefault(?bool $isDefault): void
651  {
652  $this->isDefault = $isDefault;
653  }
654 
658  public function setPredicate(?string $predicate): void
659  {
660  $this->predicate = $predicate;
661  }
662 
666  public function setCustom(?CustomFields $custom): void
667  {
668  $this->custom = $custom;
669  }
670 
671 
672  #[\ReturnTypeWillChange]
673  public function jsonSerialize()
674  {
675  $data = $this->toArray();
676  if (isset($data[ShippingMethod::FIELD_CREATED_AT]) && $data[ShippingMethod::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
677  $data[ShippingMethod::FIELD_CREATED_AT] = $data[ShippingMethod::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
678  }
679 
680  if (isset($data[ShippingMethod::FIELD_LAST_MODIFIED_AT]) && $data[ShippingMethod::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
681  $data[ShippingMethod::FIELD_LAST_MODIFIED_AT] = $data[ShippingMethod::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
682  }
683  return (object) $data;
684  }
685 }
setLocalizedDescription(?LocalizedString $localizedDescription)
__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)
static of($data=null)
Definition: MapperMap.php:45