commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
EventDeliveryPayloadModel.php
1<?php
2
3declare(strict_types=1);
10
15use DateTimeImmutable;
16use stdClass;
17
22{
23 public const DISCRIMINATOR_VALUE = 'Event';
29
34 protected $id;
35
40 protected $type;
41
46 protected $resourceType;
47
52 protected $data;
53
58 protected $createdAt;
59
60
64 public function __construct(
65 ?string $id = null,
66 ?string $type = null,
67 ?string $resourceType = null,
68 ?JsonObject $data = null,
69 ?DateTimeImmutable $createdAt = null,
70 ?string $notificationType = null
71 ) {
72 $this->id = $id;
73 $this->type = $type;
74 $this->resourceType = $resourceType;
75 $this->data = $data;
76 $this->createdAt = $createdAt;
77 $this->notificationType = $notificationType ?? self::DISCRIMINATOR_VALUE;
78 }
79
86 public function getNotificationType()
87 {
88 if (is_null($this->notificationType)) {
90 $data = $this->raw(self::FIELD_NOTIFICATION_TYPE);
91 if (is_null($data)) {
92 return null;
93 }
94 $this->notificationType = (string) $data;
95 }
96
98 }
99
106 public function getId()
107 {
108 if (is_null($this->id)) {
110 $data = $this->raw(self::FIELD_ID);
111 if (is_null($data)) {
112 return null;
113 }
114 $this->id = (string) $data;
115 }
116
117 return $this->id;
118 }
119
126 public function getType()
127 {
128 if (is_null($this->type)) {
130 $data = $this->raw(self::FIELD_TYPE);
131 if (is_null($data)) {
132 return null;
133 }
134 $this->type = (string) $data;
135 }
136
137 return $this->type;
138 }
139
146 public function getResourceType()
147 {
148 if (is_null($this->resourceType)) {
150 $data = $this->raw(self::FIELD_RESOURCE_TYPE);
151 if (is_null($data)) {
152 return null;
153 }
154 $this->resourceType = (string) $data;
155 }
156
157 return $this->resourceType;
158 }
159
166 public function getData()
167 {
168 if (is_null($this->data)) {
170 $data = $this->raw(self::FIELD_DATA);
171 if (is_null($data)) {
172 return null;
173 }
174 $this->data = JsonObjectModel::of($data);
175 }
176
177 return $this->data;
178 }
179
186 public function getCreatedAt()
187 {
188 if (is_null($this->createdAt)) {
190 $data = $this->raw(self::FIELD_CREATED_AT);
191 if (is_null($data)) {
192 return null;
193 }
194 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
195 if (false === $data) {
196 return null;
197 }
198 $this->createdAt = $data;
199 }
200
201 return $this->createdAt;
202 }
203
204
208 public function setId(?string $id): void
209 {
210 $this->id = $id;
211 }
212
216 public function setType(?string $type): void
217 {
218 $this->type = $type;
219 }
220
224 public function setResourceType(?string $resourceType): void
225 {
226 $this->resourceType = $resourceType;
227 }
228
232 public function setData(?JsonObject $data): void
233 {
234 $this->data = $data;
235 }
236
240 public function setCreatedAt(?DateTimeImmutable $createdAt): void
241 {
242 $this->createdAt = $createdAt;
243 }
244
245
246 #[\ReturnTypeWillChange]
247 public function jsonSerialize()
248 {
249 $data = $this->toArray();
251 $data[EventDeliveryPayload::FIELD_CREATED_AT] = $data[EventDeliveryPayload::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
252 }
253 return (object) $data;
254 }
255}
__construct(?string $id=null, ?string $type=null, ?string $resourceType=null, ?JsonObject $data=null, ?DateTimeImmutable $createdAt=null, ?string $notificationType=null)