commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ResourceUpdatedDeliveryPayloadModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
27 public const DISCRIMINATOR_VALUE = 'ResourceUpdated';
32 protected $projectKey;
33
39
44 protected $resource;
45
51
56 protected $version;
57
62 protected $oldVersion;
63
68 protected $modifiedAt;
69
70
74 public function __construct(
75 ?string $projectKey = null,
76 ?Reference $resource = null,
78 ?int $version = null,
79 ?int $oldVersion = null,
80 ?DateTimeImmutable $modifiedAt = null,
81 ?string $notificationType = null
82 ) {
83 $this->projectKey = $projectKey;
84 $this->resource = $resource;
85 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
86 $this->version = $version;
87 $this->oldVersion = $oldVersion;
88 $this->modifiedAt = $modifiedAt;
89 $this->notificationType = $notificationType ?? self::DISCRIMINATOR_VALUE;
90 }
91
99 public function getProjectKey()
100 {
101 if (is_null($this->projectKey)) {
103 $data = $this->raw(self::FIELD_PROJECT_KEY);
104 if (is_null($data)) {
105 return null;
106 }
107 $this->projectKey = (string) $data;
108 }
109
110 return $this->projectKey;
111 }
112
119 public function getNotificationType()
120 {
121 if (is_null($this->notificationType)) {
123 $data = $this->raw(self::FIELD_NOTIFICATION_TYPE);
124 if (is_null($data)) {
125 return null;
126 }
127 $this->notificationType = (string) $data;
128 }
129
131 }
132
139 public function getResource()
140 {
141 if (is_null($this->resource)) {
143 $data = $this->raw(self::FIELD_RESOURCE);
144 if (is_null($data)) {
145 return null;
146 }
147 $className = ReferenceModel::resolveDiscriminatorClass($data);
148 $this->resource = $className::of($data);
149 }
150
151 return $this->resource;
152 }
153
161 {
162 if (is_null($this->resourceUserProvidedIdentifiers)) {
164 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
165 if (is_null($data)) {
166 return null;
167 }
168
169 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
170 }
171
173 }
174
181 public function getVersion()
182 {
183 if (is_null($this->version)) {
185 $data = $this->raw(self::FIELD_VERSION);
186 if (is_null($data)) {
187 return null;
188 }
189 $this->version = (int) $data;
190 }
191
192 return $this->version;
193 }
194
201 public function getOldVersion()
202 {
203 if (is_null($this->oldVersion)) {
205 $data = $this->raw(self::FIELD_OLD_VERSION);
206 if (is_null($data)) {
207 return null;
208 }
209 $this->oldVersion = (int) $data;
210 }
211
212 return $this->oldVersion;
213 }
214
221 public function getModifiedAt()
222 {
223 if (is_null($this->modifiedAt)) {
225 $data = $this->raw(self::FIELD_MODIFIED_AT);
226 if (is_null($data)) {
227 return null;
228 }
229 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
230 if (false === $data) {
231 return null;
232 }
233 $this->modifiedAt = $data;
234 }
235
236 return $this->modifiedAt;
237 }
238
239
243 public function setProjectKey(?string $projectKey): void
244 {
245 $this->projectKey = $projectKey;
246 }
247
251 public function setResource(?Reference $resource): void
252 {
253 $this->resource = $resource;
254 }
255
260 {
261 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
262 }
263
267 public function setVersion(?int $version): void
268 {
269 $this->version = $version;
270 }
271
275 public function setOldVersion(?int $oldVersion): void
276 {
277 $this->oldVersion = $oldVersion;
278 }
279
283 public function setModifiedAt(?DateTimeImmutable $modifiedAt): void
284 {
285 $this->modifiedAt = $modifiedAt;
286 }
287
288
289 #[\ReturnTypeWillChange]
290 public function jsonSerialize()
291 {
292 $data = $this->toArray();
293 if (isset($data[ResourceUpdatedDeliveryPayload::FIELD_MODIFIED_AT]) && $data[ResourceUpdatedDeliveryPayload::FIELD_MODIFIED_AT] instanceof \DateTimeImmutable) {
294 $data[ResourceUpdatedDeliveryPayload::FIELD_MODIFIED_AT] = $data[ResourceUpdatedDeliveryPayload::FIELD_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
295 }
296 return (object) $data;
297 }
298}
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__construct(?string $projectKey=null, ?Reference $resource=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?int $version=null, ?int $oldVersion=null, ?DateTimeImmutable $modifiedAt=null, ?string $notificationType=null)