commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MyTransactionDraftModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
31 protected $timestamp;
32
37 protected $type;
38
43 protected $amount;
44
49 protected $interactionId;
50
55 protected $custom;
56
61 protected $interfaceId;
62
63
67 public function __construct(
68 ?DateTimeImmutable $timestamp = null,
69 ?string $type = null,
70 ?Money $amount = null,
71 ?string $interactionId = null,
73 ?string $interfaceId = null
74 ) {
75 $this->timestamp = $timestamp;
76 $this->type = $type;
77 $this->amount = $amount;
78 $this->interactionId = $interactionId;
79 $this->custom = $custom;
80 $this->interfaceId = $interfaceId;
81 }
82
89 public function getTimestamp()
90 {
91 if (is_null($this->timestamp)) {
93 $data = $this->raw(self::FIELD_TIMESTAMP);
94 if (is_null($data)) {
95 return null;
96 }
97 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
98 if (false === $data) {
99 return null;
100 }
101 $this->timestamp = $data;
102 }
103
104 return $this->timestamp;
105 }
106
114 public function getType()
115 {
116 if (is_null($this->type)) {
118 $data = $this->raw(self::FIELD_TYPE);
119 if (is_null($data)) {
120 return null;
121 }
122 $this->type = (string) $data;
123 }
124
125 return $this->type;
126 }
127
134 public function getAmount()
135 {
136 if (is_null($this->amount)) {
138 $data = $this->raw(self::FIELD_AMOUNT);
139 if (is_null($data)) {
140 return null;
141 }
142
143 $this->amount = MoneyModel::of($data);
144 }
145
146 return $this->amount;
147 }
148
156 public function getInteractionId()
157 {
158 if (is_null($this->interactionId)) {
160 $data = $this->raw(self::FIELD_INTERACTION_ID);
161 if (is_null($data)) {
162 return null;
163 }
164 $this->interactionId = (string) $data;
165 }
166
168 }
169
176 public function getCustom()
177 {
178 if (is_null($this->custom)) {
180 $data = $this->raw(self::FIELD_CUSTOM);
181 if (is_null($data)) {
182 return null;
183 }
184
185 $this->custom = CustomFieldsDraftModel::of($data);
186 }
187
188 return $this->custom;
189 }
190
197 public function getInterfaceId()
198 {
199 if (is_null($this->interfaceId)) {
201 $data = $this->raw(self::FIELD_INTERFACE_ID);
202 if (is_null($data)) {
203 return null;
204 }
205 $this->interfaceId = (string) $data;
206 }
207
208 return $this->interfaceId;
209 }
210
211
215 public function setTimestamp(?DateTimeImmutable $timestamp): void
216 {
217 $this->timestamp = $timestamp;
218 }
219
223 public function setType(?string $type): void
224 {
225 $this->type = $type;
226 }
227
231 public function setAmount(?Money $amount): void
232 {
233 $this->amount = $amount;
234 }
235
239 public function setInteractionId(?string $interactionId): void
240 {
241 $this->interactionId = $interactionId;
242 }
243
247 public function setCustom(?CustomFieldsDraft $custom): void
248 {
249 $this->custom = $custom;
250 }
251
255 public function setInterfaceId(?string $interfaceId): void
256 {
257 $this->interfaceId = $interfaceId;
258 }
259
260
261 #[\ReturnTypeWillChange]
262 public function jsonSerialize()
263 {
264 $data = $this->toArray();
265 if (isset($data[MyTransactionDraft::FIELD_TIMESTAMP]) && $data[MyTransactionDraft::FIELD_TIMESTAMP] instanceof \DateTimeImmutable) {
266 $data[MyTransactionDraft::FIELD_TIMESTAMP] = $data[MyTransactionDraft::FIELD_TIMESTAMP]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
267 }
268 return (object) $data;
269 }
270}
__construct(?DateTimeImmutable $timestamp=null, ?string $type=null, ?Money $amount=null, ?string $interactionId=null, ?CustomFieldsDraft $custom=null, ?string $interfaceId=null)