commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
PaymentMethodModel.php
1<?php
2
3declare(strict_types=1);
10
29use DateTimeImmutable;
30use stdClass;
31
35final class PaymentMethodModel extends JsonObjectModel implements PaymentMethod
36{
41 protected $id;
42
47 protected $version;
48
53 protected $createdAt;
54
59 protected $lastModifiedAt;
60
65 protected $key;
66
71 protected $name;
72
77 protected $customer;
78
83 protected $businessUnit;
84
89 protected $method;
90
96
102
107 protected $token;
108
114
119 protected $default;
120
125 protected $custom;
126
132
137 protected $createdBy;
138
139
143 public function __construct(
144 ?string $id = null,
145 ?int $version = null,
146 ?DateTimeImmutable $createdAt = null,
147 ?DateTimeImmutable $lastModifiedAt = null,
148 ?string $key = null,
149 ?LocalizedString $name = null,
152 ?string $method = null,
153 ?string $paymentInterface = null,
154 ?string $interfaceAccount = null,
156 ?string $paymentMethodStatus = null,
157 ?bool $default = null,
158 ?CustomFields $custom = null,
160 ?CreatedBy $createdBy = null
161 ) {
162 $this->id = $id;
163 $this->version = $version;
164 $this->createdAt = $createdAt;
165 $this->lastModifiedAt = $lastModifiedAt;
166 $this->key = $key;
167 $this->name = $name;
168 $this->customer = $customer;
169 $this->businessUnit = $businessUnit;
170 $this->method = $method;
171 $this->paymentInterface = $paymentInterface;
172 $this->interfaceAccount = $interfaceAccount;
173 $this->token = $token;
174 $this->paymentMethodStatus = $paymentMethodStatus;
175 $this->default = $default;
176 $this->custom = $custom;
177 $this->lastModifiedBy = $lastModifiedBy;
178 $this->createdBy = $createdBy;
179 }
180
187 public function getId()
188 {
189 if (is_null($this->id)) {
191 $data = $this->raw(self::FIELD_ID);
192 if (is_null($data)) {
193 return null;
194 }
195 $this->id = (string) $data;
196 }
197
198 return $this->id;
199 }
200
207 public function getVersion()
208 {
209 if (is_null($this->version)) {
211 $data = $this->raw(self::FIELD_VERSION);
212 if (is_null($data)) {
213 return null;
214 }
215 $this->version = (int) $data;
216 }
217
218 return $this->version;
219 }
220
227 public function getCreatedAt()
228 {
229 if (is_null($this->createdAt)) {
231 $data = $this->raw(self::FIELD_CREATED_AT);
232 if (is_null($data)) {
233 return null;
234 }
235 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
236 if (false === $data) {
237 return null;
238 }
239 $this->createdAt = $data;
240 }
241
242 return $this->createdAt;
243 }
244
251 public function getLastModifiedAt()
252 {
253 if (is_null($this->lastModifiedAt)) {
255 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
256 if (is_null($data)) {
257 return null;
258 }
259 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
260 if (false === $data) {
261 return null;
262 }
263 $this->lastModifiedAt = $data;
264 }
265
267 }
268
275 public function getKey()
276 {
277 if (is_null($this->key)) {
279 $data = $this->raw(self::FIELD_KEY);
280 if (is_null($data)) {
281 return null;
282 }
283 $this->key = (string) $data;
284 }
285
286 return $this->key;
287 }
288
295 public function getName()
296 {
297 if (is_null($this->name)) {
299 $data = $this->raw(self::FIELD_NAME);
300 if (is_null($data)) {
301 return null;
302 }
303
304 $this->name = LocalizedStringModel::of($data);
305 }
306
307 return $this->name;
308 }
309
317 public function getCustomer()
318 {
319 if (is_null($this->customer)) {
321 $data = $this->raw(self::FIELD_CUSTOMER);
322 if (is_null($data)) {
323 return null;
324 }
325
326 $this->customer = CustomerReferenceModel::of($data);
327 }
328
329 return $this->customer;
330 }
331
339 public function getBusinessUnit()
340 {
341 if (is_null($this->businessUnit)) {
343 $data = $this->raw(self::FIELD_BUSINESS_UNIT);
344 if (is_null($data)) {
345 return null;
346 }
347
348 $this->businessUnit = BusinessUnitKeyReferenceModel::of($data);
349 }
350
351 return $this->businessUnit;
352 }
353
360 public function getMethod()
361 {
362 if (is_null($this->method)) {
364 $data = $this->raw(self::FIELD_METHOD);
365 if (is_null($data)) {
366 return null;
367 }
368 $this->method = (string) $data;
369 }
370
371 return $this->method;
372 }
373
380 public function getPaymentInterface()
381 {
382 if (is_null($this->paymentInterface)) {
384 $data = $this->raw(self::FIELD_PAYMENT_INTERFACE);
385 if (is_null($data)) {
386 return null;
387 }
388 $this->paymentInterface = (string) $data;
389 }
390
392 }
393
400 public function getInterfaceAccount()
401 {
402 if (is_null($this->interfaceAccount)) {
404 $data = $this->raw(self::FIELD_INTERFACE_ACCOUNT);
405 if (is_null($data)) {
406 return null;
407 }
408 $this->interfaceAccount = (string) $data;
409 }
410
412 }
413
420 public function getToken()
421 {
422 if (is_null($this->token)) {
424 $data = $this->raw(self::FIELD_TOKEN);
425 if (is_null($data)) {
426 return null;
427 }
428
429 $this->token = PaymentMethodTokenModel::of($data);
430 }
431
432 return $this->token;
433 }
434
441 public function getPaymentMethodStatus()
442 {
443 if (is_null($this->paymentMethodStatus)) {
445 $data = $this->raw(self::FIELD_PAYMENT_METHOD_STATUS);
446 if (is_null($data)) {
447 return null;
448 }
449 $this->paymentMethodStatus = (string) $data;
450 }
451
453 }
454
462 public function getDefault()
463 {
464 if (is_null($this->default)) {
466 $data = $this->raw(self::FIELD_DEFAULT);
467 if (is_null($data)) {
468 return null;
469 }
470 $this->default = (bool) $data;
471 }
472
473 return $this->default;
474 }
475
482 public function getCustom()
483 {
484 if (is_null($this->custom)) {
486 $data = $this->raw(self::FIELD_CUSTOM);
487 if (is_null($data)) {
488 return null;
489 }
490
491 $this->custom = CustomFieldsModel::of($data);
492 }
493
494 return $this->custom;
495 }
496
503 public function getLastModifiedBy()
504 {
505 if (is_null($this->lastModifiedBy)) {
507 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
508 if (is_null($data)) {
509 return null;
510 }
511
512 $this->lastModifiedBy = LastModifiedByModel::of($data);
513 }
514
516 }
517
524 public function getCreatedBy()
525 {
526 if (is_null($this->createdBy)) {
528 $data = $this->raw(self::FIELD_CREATED_BY);
529 if (is_null($data)) {
530 return null;
531 }
532
533 $this->createdBy = CreatedByModel::of($data);
534 }
535
536 return $this->createdBy;
537 }
538
539
543 public function setId(?string $id): void
544 {
545 $this->id = $id;
546 }
547
551 public function setVersion(?int $version): void
552 {
553 $this->version = $version;
554 }
555
559 public function setCreatedAt(?DateTimeImmutable $createdAt): void
560 {
561 $this->createdAt = $createdAt;
562 }
563
567 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
568 {
569 $this->lastModifiedAt = $lastModifiedAt;
570 }
571
575 public function setKey(?string $key): void
576 {
577 $this->key = $key;
578 }
579
583 public function setName(?LocalizedString $name): void
584 {
585 $this->name = $name;
586 }
587
592 {
593 $this->customer = $customer;
594 }
595
600 {
601 $this->businessUnit = $businessUnit;
602 }
603
607 public function setMethod(?string $method): void
608 {
609 $this->method = $method;
610 }
611
615 public function setPaymentInterface(?string $paymentInterface): void
616 {
617 $this->paymentInterface = $paymentInterface;
618 }
619
623 public function setInterfaceAccount(?string $interfaceAccount): void
624 {
625 $this->interfaceAccount = $interfaceAccount;
626 }
627
631 public function setToken(?PaymentMethodToken $token): void
632 {
633 $this->token = $token;
634 }
635
639 public function setPaymentMethodStatus(?string $paymentMethodStatus): void
640 {
641 $this->paymentMethodStatus = $paymentMethodStatus;
642 }
643
647 public function setDefault(?bool $default): void
648 {
649 $this->default = $default;
650 }
651
655 public function setCustom(?CustomFields $custom): void
656 {
657 $this->custom = $custom;
658 }
659
664 {
665 $this->lastModifiedBy = $lastModifiedBy;
666 }
667
671 public function setCreatedBy(?CreatedBy $createdBy): void
672 {
673 $this->createdBy = $createdBy;
674 }
675
676
677 #[\ReturnTypeWillChange]
678 public function jsonSerialize()
679 {
680 $data = $this->toArray();
681 if (isset($data[PaymentMethod::FIELD_CREATED_AT]) && $data[PaymentMethod::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
682 $data[PaymentMethod::FIELD_CREATED_AT] = $data[PaymentMethod::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
683 }
684
685 if (isset($data[PaymentMethod::FIELD_LAST_MODIFIED_AT]) && $data[PaymentMethod::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
686 $data[PaymentMethod::FIELD_LAST_MODIFIED_AT] = $data[PaymentMethod::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
687 }
688 return (object) $data;
689 }
690}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?LocalizedString $name=null, ?CustomerReference $customer=null, ?BusinessUnitKeyReference $businessUnit=null, ?string $method=null, ?string $paymentInterface=null, ?string $interfaceAccount=null, ?PaymentMethodToken $token=null, ?string $paymentMethodStatus=null, ?bool $default=null, ?CustomFields $custom=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null)
setBusinessUnit(?BusinessUnitKeyReference $businessUnit)