commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ResourceDeletedDeliveryPayloadModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
19 use DateTimeImmutable;
20 use stdClass;
21 
26 {
27  public const DISCRIMINATOR_VALUE = 'ResourceDeleted';
32  protected $projectKey;
33 
38  protected $notificationType;
39 
44  protected $resource;
45 
51 
56  protected $version;
57 
62  protected $modifiedAt;
63 
68  protected $dataErasure;
69 
70 
74  public function __construct(
75  ?string $projectKey = null,
76  ?Reference $resource = null,
78  ?int $version = null,
79  ?DateTimeImmutable $modifiedAt = null,
80  ?bool $dataErasure = null,
81  ?string $notificationType = null
82  ) {
83  $this->projectKey = $projectKey;
84  $this->resource = $resource;
85  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
86  $this->version = $version;
87  $this->modifiedAt = $modifiedAt;
88  $this->dataErasure = $dataErasure;
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 getModifiedAt()
202  {
203  if (is_null($this->modifiedAt)) {
205  $data = $this->raw(self::FIELD_MODIFIED_AT);
206  if (is_null($data)) {
207  return null;
208  }
209  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
210  if (false === $data) {
211  return null;
212  }
213  $this->modifiedAt = $data;
214  }
215 
216  return $this->modifiedAt;
217  }
218 
225  public function getDataErasure()
226  {
227  if (is_null($this->dataErasure)) {
229  $data = $this->raw(self::FIELD_DATA_ERASURE);
230  if (is_null($data)) {
231  return null;
232  }
233  $this->dataErasure = (bool) $data;
234  }
235 
236  return $this->dataErasure;
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 setModifiedAt(?DateTimeImmutable $modifiedAt): void
276  {
277  $this->modifiedAt = $modifiedAt;
278  }
279 
283  public function setDataErasure(?bool $dataErasure): void
284  {
285  $this->dataErasure = $dataErasure;
286  }
287 
288 
289  #[\ReturnTypeWillChange]
290  public function jsonSerialize()
291  {
292  $data = $this->toArray();
293  if (isset($data[ResourceDeletedDeliveryPayload::FIELD_MODIFIED_AT]) && $data[ResourceDeletedDeliveryPayload::FIELD_MODIFIED_AT] instanceof \DateTimeImmutable) {
294  $data[ResourceDeletedDeliveryPayload::FIELD_MODIFIED_AT] = $data[ResourceDeletedDeliveryPayload::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, ?DateTimeImmutable $modifiedAt=null, ?bool $dataErasure=null, ?string $notificationType=null)