commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
OrderEditModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
26 use DateTimeImmutable;
27 use stdClass;
28 
32 final class OrderEditModel extends JsonObjectModel implements OrderEdit
33 {
38  protected $id;
39 
44  protected $version;
45 
50  protected $createdAt;
51 
56  protected $lastModifiedAt;
57 
62  protected $key;
63 
68  protected $resource;
69 
74  protected $stagedActions;
75 
80  protected $result;
81 
86  protected $comment;
87 
92  protected $custom;
93 
98  protected $lastModifiedBy;
99 
104  protected $createdBy;
105 
106 
110  public function __construct(
111  ?string $id = null,
112  ?int $version = null,
113  ?DateTimeImmutable $createdAt = null,
114  ?DateTimeImmutable $lastModifiedAt = null,
115  ?string $key = null,
116  ?OrderReference $resource = null,
118  ?OrderEditResult $result = null,
119  ?string $comment = null,
120  ?CustomFields $custom = null,
122  ?CreatedBy $createdBy = null
123  ) {
124  $this->id = $id;
125  $this->version = $version;
126  $this->createdAt = $createdAt;
127  $this->lastModifiedAt = $lastModifiedAt;
128  $this->key = $key;
129  $this->resource = $resource;
130  $this->stagedActions = $stagedActions;
131  $this->result = $result;
132  $this->comment = $comment;
133  $this->custom = $custom;
134  $this->lastModifiedBy = $lastModifiedBy;
135  $this->createdBy = $createdBy;
136  }
137 
144  public function getId()
145  {
146  if (is_null($this->id)) {
148  $data = $this->raw(self::FIELD_ID);
149  if (is_null($data)) {
150  return null;
151  }
152  $this->id = (string) $data;
153  }
154 
155  return $this->id;
156  }
157 
164  public function getVersion()
165  {
166  if (is_null($this->version)) {
168  $data = $this->raw(self::FIELD_VERSION);
169  if (is_null($data)) {
170  return null;
171  }
172  $this->version = (int) $data;
173  }
174 
175  return $this->version;
176  }
177 
184  public function getCreatedAt()
185  {
186  if (is_null($this->createdAt)) {
188  $data = $this->raw(self::FIELD_CREATED_AT);
189  if (is_null($data)) {
190  return null;
191  }
192  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
193  if (false === $data) {
194  return null;
195  }
196  $this->createdAt = $data;
197  }
198 
199  return $this->createdAt;
200  }
201 
208  public function getLastModifiedAt()
209  {
210  if (is_null($this->lastModifiedAt)) {
212  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
213  if (is_null($data)) {
214  return null;
215  }
216  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
217  if (false === $data) {
218  return null;
219  }
220  $this->lastModifiedAt = $data;
221  }
222 
223  return $this->lastModifiedAt;
224  }
225 
232  public function getKey()
233  {
234  if (is_null($this->key)) {
236  $data = $this->raw(self::FIELD_KEY);
237  if (is_null($data)) {
238  return null;
239  }
240  $this->key = (string) $data;
241  }
242 
243  return $this->key;
244  }
245 
252  public function getResource()
253  {
254  if (is_null($this->resource)) {
256  $data = $this->raw(self::FIELD_RESOURCE);
257  if (is_null($data)) {
258  return null;
259  }
260 
261  $this->resource = OrderReferenceModel::of($data);
262  }
263 
264  return $this->resource;
265  }
266 
273  public function getStagedActions()
274  {
275  if (is_null($this->stagedActions)) {
277  $data = $this->raw(self::FIELD_STAGED_ACTIONS);
278  if (is_null($data)) {
279  return null;
280  }
281  $this->stagedActions = StagedOrderUpdateActionCollection::fromArray($data);
282  }
283 
284  return $this->stagedActions;
285  }
286 
294  public function getResult()
295  {
296  if (is_null($this->result)) {
298  $data = $this->raw(self::FIELD_RESULT);
299  if (is_null($data)) {
300  return null;
301  }
303  $this->result = $className::of($data);
304  }
305 
306  return $this->result;
307  }
308 
315  public function getComment()
316  {
317  if (is_null($this->comment)) {
319  $data = $this->raw(self::FIELD_COMMENT);
320  if (is_null($data)) {
321  return null;
322  }
323  $this->comment = (string) $data;
324  }
325 
326  return $this->comment;
327  }
328 
335  public function getCustom()
336  {
337  if (is_null($this->custom)) {
339  $data = $this->raw(self::FIELD_CUSTOM);
340  if (is_null($data)) {
341  return null;
342  }
343 
344  $this->custom = CustomFieldsModel::of($data);
345  }
346 
347  return $this->custom;
348  }
349 
356  public function getLastModifiedBy()
357  {
358  if (is_null($this->lastModifiedBy)) {
360  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
361  if (is_null($data)) {
362  return null;
363  }
364 
365  $this->lastModifiedBy = LastModifiedByModel::of($data);
366  }
367 
368  return $this->lastModifiedBy;
369  }
370 
377  public function getCreatedBy()
378  {
379  if (is_null($this->createdBy)) {
381  $data = $this->raw(self::FIELD_CREATED_BY);
382  if (is_null($data)) {
383  return null;
384  }
385 
386  $this->createdBy = CreatedByModel::of($data);
387  }
388 
389  return $this->createdBy;
390  }
391 
392 
396  public function setId(?string $id): void
397  {
398  $this->id = $id;
399  }
400 
404  public function setVersion(?int $version): void
405  {
406  $this->version = $version;
407  }
408 
412  public function setCreatedAt(?DateTimeImmutable $createdAt): void
413  {
414  $this->createdAt = $createdAt;
415  }
416 
420  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
421  {
422  $this->lastModifiedAt = $lastModifiedAt;
423  }
424 
428  public function setKey(?string $key): void
429  {
430  $this->key = $key;
431  }
432 
436  public function setResource(?OrderReference $resource): void
437  {
438  $this->resource = $resource;
439  }
440 
445  {
446  $this->stagedActions = $stagedActions;
447  }
448 
452  public function setResult(?OrderEditResult $result): void
453  {
454  $this->result = $result;
455  }
456 
460  public function setComment(?string $comment): void
461  {
462  $this->comment = $comment;
463  }
464 
468  public function setCustom(?CustomFields $custom): void
469  {
470  $this->custom = $custom;
471  }
472 
477  {
478  $this->lastModifiedBy = $lastModifiedBy;
479  }
480 
484  public function setCreatedBy(?CreatedBy $createdBy): void
485  {
486  $this->createdBy = $createdBy;
487  }
488 
489 
490  #[\ReturnTypeWillChange]
491  public function jsonSerialize()
492  {
493  $data = $this->toArray();
494  if (isset($data[OrderEdit::FIELD_CREATED_AT]) && $data[OrderEdit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
495  $data[OrderEdit::FIELD_CREATED_AT] = $data[OrderEdit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
496  }
497 
498  if (isset($data[OrderEdit::FIELD_LAST_MODIFIED_AT]) && $data[OrderEdit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
499  $data[OrderEdit::FIELD_LAST_MODIFIED_AT] = $data[OrderEdit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
500  }
501  return (object) $data;
502  }
503 }
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?OrderReference $resource=null, ?StagedOrderUpdateActionCollection $stagedActions=null, ?OrderEditResult $result=null, ?string $comment=null, ?CustomFields $custom=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null)
setStagedActions(?StagedOrderUpdateActionCollection $stagedActions)