commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApprovalFlowModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
29 use DateTimeImmutable;
30 use stdClass;
31 
35 final class ApprovalFlowModel extends JsonObjectModel implements ApprovalFlow
36 {
41  protected $id;
42 
47  protected $version;
48 
53  protected $createdAt;
54 
59  protected $lastModifiedAt;
60 
65  protected $createdBy;
66 
71  protected $lastModifiedBy;
72 
77  protected $order;
78 
83  protected $businessUnit;
84 
89  protected $rules;
90 
95  protected $status;
96 
101  protected $rejection;
102 
107  protected $approvals;
108 
114 
119  protected $pendingApprovers;
120 
126 
131  protected $custom;
132 
133 
137  public function __construct(
138  ?string $id = null,
139  ?int $version = null,
140  ?DateTimeImmutable $createdAt = null,
141  ?DateTimeImmutable $lastModifiedAt = null,
142  ?CreatedBy $createdBy = null,
144  ?OrderReference $order = null,
147  ?string $status = null,
153  ?CustomFields $custom = null
154  ) {
155  $this->id = $id;
156  $this->version = $version;
157  $this->createdAt = $createdAt;
158  $this->lastModifiedAt = $lastModifiedAt;
159  $this->createdBy = $createdBy;
160  $this->lastModifiedBy = $lastModifiedBy;
161  $this->order = $order;
162  $this->businessUnit = $businessUnit;
163  $this->rules = $rules;
164  $this->status = $status;
165  $this->rejection = $rejection;
166  $this->approvals = $approvals;
167  $this->eligibleApprovers = $eligibleApprovers;
168  $this->pendingApprovers = $pendingApprovers;
169  $this->currentTierPendingApprovers = $currentTierPendingApprovers;
170  $this->custom = $custom;
171  }
172 
179  public function getId()
180  {
181  if (is_null($this->id)) {
183  $data = $this->raw(self::FIELD_ID);
184  if (is_null($data)) {
185  return null;
186  }
187  $this->id = (string) $data;
188  }
189 
190  return $this->id;
191  }
192 
199  public function getVersion()
200  {
201  if (is_null($this->version)) {
203  $data = $this->raw(self::FIELD_VERSION);
204  if (is_null($data)) {
205  return null;
206  }
207  $this->version = (int) $data;
208  }
209 
210  return $this->version;
211  }
212 
219  public function getCreatedAt()
220  {
221  if (is_null($this->createdAt)) {
223  $data = $this->raw(self::FIELD_CREATED_AT);
224  if (is_null($data)) {
225  return null;
226  }
227  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
228  if (false === $data) {
229  return null;
230  }
231  $this->createdAt = $data;
232  }
233 
234  return $this->createdAt;
235  }
236 
243  public function getLastModifiedAt()
244  {
245  if (is_null($this->lastModifiedAt)) {
247  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
248  if (is_null($data)) {
249  return null;
250  }
251  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
252  if (false === $data) {
253  return null;
254  }
255  $this->lastModifiedAt = $data;
256  }
257 
258  return $this->lastModifiedAt;
259  }
260 
267  public function getCreatedBy()
268  {
269  if (is_null($this->createdBy)) {
271  $data = $this->raw(self::FIELD_CREATED_BY);
272  if (is_null($data)) {
273  return null;
274  }
275 
276  $this->createdBy = CreatedByModel::of($data);
277  }
278 
279  return $this->createdBy;
280  }
281 
288  public function getLastModifiedBy()
289  {
290  if (is_null($this->lastModifiedBy)) {
292  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
293  if (is_null($data)) {
294  return null;
295  }
296 
297  $this->lastModifiedBy = LastModifiedByModel::of($data);
298  }
299 
300  return $this->lastModifiedBy;
301  }
302 
309  public function getOrder()
310  {
311  if (is_null($this->order)) {
313  $data = $this->raw(self::FIELD_ORDER);
314  if (is_null($data)) {
315  return null;
316  }
317 
318  $this->order = OrderReferenceModel::of($data);
319  }
320 
321  return $this->order;
322  }
323 
330  public function getBusinessUnit()
331  {
332  if (is_null($this->businessUnit)) {
334  $data = $this->raw(self::FIELD_BUSINESS_UNIT);
335  if (is_null($data)) {
336  return null;
337  }
338 
339  $this->businessUnit = BusinessUnitKeyReferenceModel::of($data);
340  }
341 
342  return $this->businessUnit;
343  }
344 
351  public function getRules()
352  {
353  if (is_null($this->rules)) {
355  $data = $this->raw(self::FIELD_RULES);
356  if (is_null($data)) {
357  return null;
358  }
359  $this->rules = ApprovalRuleCollection::fromArray($data);
360  }
361 
362  return $this->rules;
363  }
364 
371  public function getStatus()
372  {
373  if (is_null($this->status)) {
375  $data = $this->raw(self::FIELD_STATUS);
376  if (is_null($data)) {
377  return null;
378  }
379  $this->status = (string) $data;
380  }
381 
382  return $this->status;
383  }
384 
391  public function getRejection()
392  {
393  if (is_null($this->rejection)) {
395  $data = $this->raw(self::FIELD_REJECTION);
396  if (is_null($data)) {
397  return null;
398  }
399 
400  $this->rejection = ApprovalFlowRejectionModel::of($data);
401  }
402 
403  return $this->rejection;
404  }
405 
412  public function getApprovals()
413  {
414  if (is_null($this->approvals)) {
416  $data = $this->raw(self::FIELD_APPROVALS);
417  if (is_null($data)) {
418  return null;
419  }
420  $this->approvals = ApprovalFlowApprovalCollection::fromArray($data);
421  }
422 
423  return $this->approvals;
424  }
425 
433  public function getEligibleApprovers()
434  {
435  if (is_null($this->eligibleApprovers)) {
437  $data = $this->raw(self::FIELD_ELIGIBLE_APPROVERS);
438  if (is_null($data)) {
439  return null;
440  }
441  $this->eligibleApprovers = RuleApproverCollection::fromArray($data);
442  }
443 
445  }
446 
453  public function getPendingApprovers()
454  {
455  if (is_null($this->pendingApprovers)) {
457  $data = $this->raw(self::FIELD_PENDING_APPROVERS);
458  if (is_null($data)) {
459  return null;
460  }
461  $this->pendingApprovers = RuleApproverCollection::fromArray($data);
462  }
463 
465  }
466 
474  {
475  if (is_null($this->currentTierPendingApprovers)) {
477  $data = $this->raw(self::FIELD_CURRENT_TIER_PENDING_APPROVERS);
478  if (is_null($data)) {
479  return null;
480  }
481  $this->currentTierPendingApprovers = RuleApproverCollection::fromArray($data);
482  }
483 
485  }
486 
493  public function getCustom()
494  {
495  if (is_null($this->custom)) {
497  $data = $this->raw(self::FIELD_CUSTOM);
498  if (is_null($data)) {
499  return null;
500  }
501 
502  $this->custom = CustomFieldsModel::of($data);
503  }
504 
505  return $this->custom;
506  }
507 
508 
512  public function setId(?string $id): void
513  {
514  $this->id = $id;
515  }
516 
520  public function setVersion(?int $version): void
521  {
522  $this->version = $version;
523  }
524 
528  public function setCreatedAt(?DateTimeImmutable $createdAt): void
529  {
530  $this->createdAt = $createdAt;
531  }
532 
536  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
537  {
538  $this->lastModifiedAt = $lastModifiedAt;
539  }
540 
544  public function setCreatedBy(?CreatedBy $createdBy): void
545  {
546  $this->createdBy = $createdBy;
547  }
548 
553  {
554  $this->lastModifiedBy = $lastModifiedBy;
555  }
556 
560  public function setOrder(?OrderReference $order): void
561  {
562  $this->order = $order;
563  }
564 
569  {
570  $this->businessUnit = $businessUnit;
571  }
572 
576  public function setRules(?ApprovalRuleCollection $rules): void
577  {
578  $this->rules = $rules;
579  }
580 
584  public function setStatus(?string $status): void
585  {
586  $this->status = $status;
587  }
588 
593  {
594  $this->rejection = $rejection;
595  }
596 
601  {
602  $this->approvals = $approvals;
603  }
604 
609  {
610  $this->eligibleApprovers = $eligibleApprovers;
611  }
612 
617  {
618  $this->pendingApprovers = $pendingApprovers;
619  }
620 
625  {
626  $this->currentTierPendingApprovers = $currentTierPendingApprovers;
627  }
628 
632  public function setCustom(?CustomFields $custom): void
633  {
634  $this->custom = $custom;
635  }
636 
637 
638  #[\ReturnTypeWillChange]
639  public function jsonSerialize()
640  {
641  $data = $this->toArray();
642  if (isset($data[ApprovalFlow::FIELD_CREATED_AT]) && $data[ApprovalFlow::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
643  $data[ApprovalFlow::FIELD_CREATED_AT] = $data[ApprovalFlow::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
644  }
645 
646  if (isset($data[ApprovalFlow::FIELD_LAST_MODIFIED_AT]) && $data[ApprovalFlow::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
647  $data[ApprovalFlow::FIELD_LAST_MODIFIED_AT] = $data[ApprovalFlow::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
648  }
649  return (object) $data;
650  }
651 }
setBusinessUnit(?BusinessUnitKeyReference $businessUnit)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?CreatedBy $createdBy=null, ?LastModifiedBy $lastModifiedBy=null, ?OrderReference $order=null, ?BusinessUnitKeyReference $businessUnit=null, ?ApprovalRuleCollection $rules=null, ?string $status=null, ?ApprovalFlowRejection $rejection=null, ?ApprovalFlowApprovalCollection $approvals=null, ?RuleApproverCollection $eligibleApprovers=null, ?RuleApproverCollection $pendingApprovers=null, ?RuleApproverCollection $currentTierPendingApprovers=null, ?CustomFields $custom=null)
setPendingApprovers(?RuleApproverCollection $pendingApprovers)
setCurrentTierPendingApprovers(?RuleApproverCollection $currentTierPendingApprovers)
setEligibleApprovers(?RuleApproverCollection $eligibleApprovers)
setApprovals(?ApprovalFlowApprovalCollection $approvals)