<?php

/*
 * This file was automatically generated.
 */
namespace Worldline\Vendor\OnlinePayments\Sdk\Domain;

use UnexpectedValueException;
/**
 * @package OnlinePayments\Sdk\Domain
 */
class OrderStatusOutput extends DataObject
{
    /**
     * @var APIError[]|null
     */
    public ?array $errors = null;
    /**
     * @var bool|null
     */
    public ?bool $isCancellable = null;
    /**
     * @var string|null
     */
    public ?string $statusCategory = null;
    /**
     * @var int|null
     */
    public ?int $statusCode = null;
    /**
     * @var string|null
     */
    public ?string $statusCodeChangeDateTime = null;
    /**
     * @return APIError[]|null
     */
    public function getErrors() : ?array
    {
        return $this->errors;
    }
    /**
     * @param APIError[]|null $value
     */
    public function setErrors(?array $value) : void
    {
        $this->errors = $value;
    }
    /**
     * @return bool|null
     */
    public function getIsCancellable() : ?bool
    {
        return $this->isCancellable;
    }
    /**
     * @param bool|null $value
     */
    public function setIsCancellable(?bool $value) : void
    {
        $this->isCancellable = $value;
    }
    /**
     * @return string|null
     */
    public function getStatusCategory() : ?string
    {
        return $this->statusCategory;
    }
    /**
     * @param string|null $value
     */
    public function setStatusCategory(?string $value) : void
    {
        $this->statusCategory = $value;
    }
    /**
     * @return int|null
     */
    public function getStatusCode() : ?int
    {
        return $this->statusCode;
    }
    /**
     * @param int|null $value
     */
    public function setStatusCode(?int $value) : void
    {
        $this->statusCode = $value;
    }
    /**
     * @return string|null
     */
    public function getStatusCodeChangeDateTime() : ?string
    {
        return $this->statusCodeChangeDateTime;
    }
    /**
     * @param string|null $value
     */
    public function setStatusCodeChangeDateTime(?string $value) : void
    {
        $this->statusCodeChangeDateTime = $value;
    }
    /**
     * @return object
     */
    public function toObject() : object
    {
        $object = parent::toObject();
        if (!\is_null($this->errors)) {
            $object->errors = [];
            foreach ($this->errors as $element) {
                if (!\is_null($element)) {
                    $object->errors[] = $element->toObject();
                }
            }
        }
        if (!\is_null($this->isCancellable)) {
            $object->isCancellable = $this->isCancellable;
        }
        if (!\is_null($this->statusCategory)) {
            $object->statusCategory = $this->statusCategory;
        }
        if (!\is_null($this->statusCode)) {
            $object->statusCode = $this->statusCode;
        }
        if (!\is_null($this->statusCodeChangeDateTime)) {
            $object->statusCodeChangeDateTime = $this->statusCodeChangeDateTime;
        }
        return $object;
    }
    /**
     * @param object $object
     * @return $this
     * @throws UnexpectedValueException
     */
    public function fromObject(object $object) : OrderStatusOutput
    {
        parent::fromObject($object);
        if (\property_exists($object, 'errors')) {
            if (!\is_array($object->errors) && !\is_object($object->errors)) {
                throw new UnexpectedValueException('value \'' . \print_r($object->errors, \true) . '\' is not an array or object');
            }
            $this->errors = [];
            foreach ($object->errors as $element) {
                $value = new APIError();
                $this->errors[] = $value->fromObject($element);
            }
        }
        if (\property_exists($object, 'isCancellable')) {
            $this->isCancellable = $object->isCancellable;
        }
        if (\property_exists($object, 'statusCategory')) {
            $this->statusCategory = $object->statusCategory;
        }
        if (\property_exists($object, 'statusCode')) {
            $this->statusCode = $object->statusCode;
        }
        if (\property_exists($object, 'statusCodeChangeDateTime')) {
            $this->statusCodeChangeDateTime = $object->statusCodeChangeDateTime;
        }
        return $this;
    }
}
