commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ResourceCreatedDeliveryPayloadModel.php
1<?php
2
3declare(strict_types=1);
10
19use DateTimeImmutable;
20use stdClass;
21
26{
27 public const DISCRIMINATOR_VALUE = 'ResourceCreated';
32 protected $projectKey;
33
39
44 protected $resource;
45
51
56 protected $version;
57
62 protected $modifiedAt;
63
64
68 public function __construct(
69 ?string $projectKey = null,
70 ?Reference $resource = null,
72 ?int $version = null,
73 ?DateTimeImmutable $modifiedAt = null,
74 ?string $notificationType = null
75 ) {
76 $this->projectKey = $projectKey;
77 $this->resource = $resource;
78 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
79 $this->version = $version;
80 $this->modifiedAt = $modifiedAt;
81 $this->notificationType = $notificationType ?? self::DISCRIMINATOR_VALUE;
82 }
83
91 public function getProjectKey()
92 {
93 if (is_null($this->projectKey)) {
95 $data = $this->raw(self::FIELD_PROJECT_KEY);
96 if (is_null($data)) {
97 return null;
98 }
99 $this->projectKey = (string) $data;
100 }
101
102 return $this->projectKey;
103 }
104
111 public function getNotificationType()
112 {
113 if (is_null($this->notificationType)) {
115 $data = $this->raw(self::FIELD_NOTIFICATION_TYPE);
116 if (is_null($data)) {
117 return null;
118 }
119 $this->notificationType = (string) $data;
120 }
121
123 }
124
131 public function getResource()
132 {
133 if (is_null($this->resource)) {
135 $data = $this->raw(self::FIELD_RESOURCE);
136 if (is_null($data)) {
137 return null;
138 }
139 $className = ReferenceModel::resolveDiscriminatorClass($data);
140 $this->resource = $className::of($data);
141 }
142
143 return $this->resource;
144 }
145
153 {
154 if (is_null($this->resourceUserProvidedIdentifiers)) {
156 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
157 if (is_null($data)) {
158 return null;
159 }
160
161 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
162 }
163
165 }
166
173 public function getVersion()
174 {
175 if (is_null($this->version)) {
177 $data = $this->raw(self::FIELD_VERSION);
178 if (is_null($data)) {
179 return null;
180 }
181 $this->version = (int) $data;
182 }
183
184 return $this->version;
185 }
186
193 public function getModifiedAt()
194 {
195 if (is_null($this->modifiedAt)) {
197 $data = $this->raw(self::FIELD_MODIFIED_AT);
198 if (is_null($data)) {
199 return null;
200 }
201 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
202 if (false === $data) {
203 return null;
204 }
205 $this->modifiedAt = $data;
206 }
207
208 return $this->modifiedAt;
209 }
210
211
215 public function setProjectKey(?string $projectKey): void
216 {
217 $this->projectKey = $projectKey;
218 }
219
223 public function setResource(?Reference $resource): void
224 {
225 $this->resource = $resource;
226 }
227
232 {
233 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
234 }
235
239 public function setVersion(?int $version): void
240 {
241 $this->version = $version;
242 }
243
247 public function setModifiedAt(?DateTimeImmutable $modifiedAt): void
248 {
249 $this->modifiedAt = $modifiedAt;
250 }
251
252
253 #[\ReturnTypeWillChange]
254 public function jsonSerialize()
255 {
256 $data = $this->toArray();
257 if (isset($data[ResourceCreatedDeliveryPayload::FIELD_MODIFIED_AT]) && $data[ResourceCreatedDeliveryPayload::FIELD_MODIFIED_AT] instanceof \DateTimeImmutable) {
258 $data[ResourceCreatedDeliveryPayload::FIELD_MODIFIED_AT] = $data[ResourceCreatedDeliveryPayload::FIELD_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
259 }
260 return (object) $data;
261 }
262}
__construct(?string $projectKey=null, ?Reference $resource=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?int $version=null, ?DateTimeImmutable $modifiedAt=null, ?string $notificationType=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)