commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ImportOperationModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use DateTimeImmutable;
18 use stdClass;
19 
24 {
29  protected $version;
30 
36 
41  protected $resourceKey;
42 
47  protected $id;
48 
53  protected $state;
54 
59  protected $resourceVersion;
60 
65  protected $errors;
66 
72 
77  protected $createdAt;
78 
83  protected $lastModifiedAt;
84 
89  protected $expiresAt;
90 
91 
95  public function __construct(
96  ?int $version = null,
97  ?string $importContainerKey = null,
98  ?string $resourceKey = null,
99  ?string $id = null,
100  ?string $state = null,
101  ?int $resourceVersion = null,
104  ?DateTimeImmutable $createdAt = null,
105  ?DateTimeImmutable $lastModifiedAt = null,
106  ?DateTimeImmutable $expiresAt = null
107  ) {
108  $this->version = $version;
109  $this->importContainerKey = $importContainerKey;
110  $this->resourceKey = $resourceKey;
111  $this->id = $id;
112  $this->state = $state;
113  $this->resourceVersion = $resourceVersion;
114  $this->errors = $errors;
115  $this->unresolvedReferences = $unresolvedReferences;
116  $this->createdAt = $createdAt;
117  $this->lastModifiedAt = $lastModifiedAt;
118  $this->expiresAt = $expiresAt;
119  }
120 
127  public function getVersion()
128  {
129  if (is_null($this->version)) {
131  $data = $this->raw(self::FIELD_VERSION);
132  if (is_null($data)) {
133  return null;
134  }
135  $this->version = (int) $data;
136  }
137 
138  return $this->version;
139  }
140 
147  public function getImportContainerKey()
148  {
149  if (is_null($this->importContainerKey)) {
151  $data = $this->raw(self::FIELD_IMPORT_CONTAINER_KEY);
152  if (is_null($data)) {
153  return null;
154  }
155  $this->importContainerKey = (string) $data;
156  }
157 
159  }
160 
167  public function getResourceKey()
168  {
169  if (is_null($this->resourceKey)) {
171  $data = $this->raw(self::FIELD_RESOURCE_KEY);
172  if (is_null($data)) {
173  return null;
174  }
175  $this->resourceKey = (string) $data;
176  }
177 
178  return $this->resourceKey;
179  }
180 
187  public function getId()
188  {
189  if (is_null($this->id)) {
191  $data = $this->raw(self::FIELD_ID);
192  if (is_null($data)) {
193  return null;
194  }
195  $this->id = (string) $data;
196  }
197 
198  return $this->id;
199  }
200 
207  public function getState()
208  {
209  if (is_null($this->state)) {
211  $data = $this->raw(self::FIELD_STATE);
212  if (is_null($data)) {
213  return null;
214  }
215  $this->state = (string) $data;
216  }
217 
218  return $this->state;
219  }
220 
227  public function getResourceVersion()
228  {
229  if (is_null($this->resourceVersion)) {
231  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
232  if (is_null($data)) {
233  return null;
234  }
235  $this->resourceVersion = (int) $data;
236  }
237 
238  return $this->resourceVersion;
239  }
240 
247  public function getErrors()
248  {
249  if (is_null($this->errors)) {
251  $data = $this->raw(self::FIELD_ERRORS);
252  if (is_null($data)) {
253  return null;
254  }
255  $this->errors = ErrorObjectCollection::fromArray($data);
256  }
257 
258  return $this->errors;
259  }
260 
267  public function getUnresolvedReferences()
268  {
269  if (is_null($this->unresolvedReferences)) {
271  $data = $this->raw(self::FIELD_UNRESOLVED_REFERENCES);
272  if (is_null($data)) {
273  return null;
274  }
275  $this->unresolvedReferences = UnresolvedReferencesCollection::fromArray($data);
276  }
277 
279  }
280 
287  public function getCreatedAt()
288  {
289  if (is_null($this->createdAt)) {
291  $data = $this->raw(self::FIELD_CREATED_AT);
292  if (is_null($data)) {
293  return null;
294  }
295  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
296  if (false === $data) {
297  return null;
298  }
299  $this->createdAt = $data;
300  }
301 
302  return $this->createdAt;
303  }
304 
311  public function getLastModifiedAt()
312  {
313  if (is_null($this->lastModifiedAt)) {
315  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
316  if (is_null($data)) {
317  return null;
318  }
319  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
320  if (false === $data) {
321  return null;
322  }
323  $this->lastModifiedAt = $data;
324  }
325 
326  return $this->lastModifiedAt;
327  }
328 
335  public function getExpiresAt()
336  {
337  if (is_null($this->expiresAt)) {
339  $data = $this->raw(self::FIELD_EXPIRES_AT);
340  if (is_null($data)) {
341  return null;
342  }
343  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
344  if (false === $data) {
345  return null;
346  }
347  $this->expiresAt = $data;
348  }
349 
350  return $this->expiresAt;
351  }
352 
353 
357  public function setVersion(?int $version): void
358  {
359  $this->version = $version;
360  }
361 
365  public function setImportContainerKey(?string $importContainerKey): void
366  {
367  $this->importContainerKey = $importContainerKey;
368  }
369 
373  public function setResourceKey(?string $resourceKey): void
374  {
375  $this->resourceKey = $resourceKey;
376  }
377 
381  public function setId(?string $id): void
382  {
383  $this->id = $id;
384  }
385 
389  public function setState(?string $state): void
390  {
391  $this->state = $state;
392  }
393 
397  public function setResourceVersion(?int $resourceVersion): void
398  {
399  $this->resourceVersion = $resourceVersion;
400  }
401 
405  public function setErrors(?ErrorObjectCollection $errors): void
406  {
407  $this->errors = $errors;
408  }
409 
414  {
415  $this->unresolvedReferences = $unresolvedReferences;
416  }
417 
421  public function setCreatedAt(?DateTimeImmutable $createdAt): void
422  {
423  $this->createdAt = $createdAt;
424  }
425 
429  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
430  {
431  $this->lastModifiedAt = $lastModifiedAt;
432  }
433 
437  public function setExpiresAt(?DateTimeImmutable $expiresAt): void
438  {
439  $this->expiresAt = $expiresAt;
440  }
441 
442 
443  #[\ReturnTypeWillChange]
444  public function jsonSerialize()
445  {
446  $data = $this->toArray();
447  if (isset($data[ImportOperation::FIELD_CREATED_AT]) && $data[ImportOperation::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
448  $data[ImportOperation::FIELD_CREATED_AT] = $data[ImportOperation::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
449  }
450 
451  if (isset($data[ImportOperation::FIELD_LAST_MODIFIED_AT]) && $data[ImportOperation::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
452  $data[ImportOperation::FIELD_LAST_MODIFIED_AT] = $data[ImportOperation::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
453  }
454 
455  if (isset($data[ImportOperation::FIELD_EXPIRES_AT]) && $data[ImportOperation::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
456  $data[ImportOperation::FIELD_EXPIRES_AT] = $data[ImportOperation::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
457  }
458  return (object) $data;
459  }
460 }
setUnresolvedReferences(?UnresolvedReferencesCollection $unresolvedReferences)
__construct(?int $version=null, ?string $importContainerKey=null, ?string $resourceKey=null, ?string $id=null, ?string $state=null, ?int $resourceVersion=null, ?ErrorObjectCollection $errors=null, ?UnresolvedReferencesCollection $unresolvedReferences=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?DateTimeImmutable $expiresAt=null)