commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
PaymentChangeTransactionTimestampActionModel.php
1<?php
2
3declare(strict_types=1);
10
15use DateTimeImmutable;
16use stdClass;
17
22{
23 public const DISCRIMINATOR_VALUE = 'changeTransactionTimestamp';
28 protected $action;
29
34 protected $transactionId;
35
40 protected $timestamp;
41
42
46 public function __construct(
47 ?string $transactionId = null,
48 ?DateTimeImmutable $timestamp = null,
49 ?string $action = null
50 ) {
51 $this->transactionId = $transactionId;
52 $this->timestamp = $timestamp;
53 $this->action = $action ?? self::DISCRIMINATOR_VALUE;
54 }
55
60 public function getAction()
61 {
62 if (is_null($this->action)) {
64 $data = $this->raw(self::FIELD_ACTION);
65 if (is_null($data)) {
66 return null;
67 }
68 $this->action = (string) $data;
69 }
70
71 return $this->action;
72 }
73
80 public function getTransactionId()
81 {
82 if (is_null($this->transactionId)) {
84 $data = $this->raw(self::FIELD_TRANSACTION_ID);
85 if (is_null($data)) {
86 return null;
87 }
88 $this->transactionId = (string) $data;
89 }
90
92 }
93
100 public function getTimestamp()
101 {
102 if (is_null($this->timestamp)) {
104 $data = $this->raw(self::FIELD_TIMESTAMP);
105 if (is_null($data)) {
106 return null;
107 }
108 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
109 if (false === $data) {
110 return null;
111 }
112 $this->timestamp = $data;
113 }
114
115 return $this->timestamp;
116 }
117
118
122 public function setTransactionId(?string $transactionId): void
123 {
124 $this->transactionId = $transactionId;
125 }
126
130 public function setTimestamp(?DateTimeImmutable $timestamp): void
131 {
132 $this->timestamp = $timestamp;
133 }
134
135
136 #[\ReturnTypeWillChange]
137 public function jsonSerialize()
138 {
139 $data = $this->toArray();
141 $data[PaymentChangeTransactionTimestampAction::FIELD_TIMESTAMP] = $data[PaymentChangeTransactionTimestampAction::FIELD_TIMESTAMP]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
142 }
143 return (object) $data;
144 }
145}
__construct(?string $transactionId=null, ?DateTimeImmutable $timestamp=null, ?string $action=null)