<?php
/**
 * RefundScreenOptions
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Linnworks\ProcessedOrders
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Processed Orders API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: processedorders
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.11.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Linnworks\ProcessedOrders\Model;

use \ArrayAccess;
use \Linnworks\ProcessedOrders\ObjectSerializer;

/**
 * RefundScreenOptions Class Doc Comment
 *
 * @category Class
 * @package  Linnworks\ProcessedOrders
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class RefundScreenOptions implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $openAPIModelName = 'RefundScreenOptions';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'free_text_option' => 'string',
        'can_refund_shipping' => 'bool',
        'order_has_service_items' => 'bool',
        'is_shipping_refund_automated' => 'bool',
        'is_service_refund_automated' => 'bool',
        'supports_automated_refunds' => 'bool'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string|null>
      * @psalm-var array<string, string|null>
      */
    protected static $openAPIFormats = [
        'free_text_option' => null,
        'can_refund_shipping' => null,
        'order_has_service_items' => null,
        'is_shipping_refund_automated' => null,
        'is_service_refund_automated' => null,
        'supports_automated_refunds' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'free_text_option' => false,
        'can_refund_shipping' => false,
        'order_has_service_items' => false,
        'is_shipping_refund_automated' => false,
        'is_service_refund_automated' => false,
        'supports_automated_refunds' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of nullable properties
     *
     * @return array
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null
     *
     * @return boolean[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'free_text_option' => 'FreeTextOption',
        'can_refund_shipping' => 'CanRefundShipping',
        'order_has_service_items' => 'OrderHasServiceItems',
        'is_shipping_refund_automated' => 'IsShippingRefundAutomated',
        'is_service_refund_automated' => 'IsServiceRefundAutomated',
        'supports_automated_refunds' => 'SupportsAutomatedRefunds'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'free_text_option' => 'setFreeTextOption',
        'can_refund_shipping' => 'setCanRefundShipping',
        'order_has_service_items' => 'setOrderHasServiceItems',
        'is_shipping_refund_automated' => 'setIsShippingRefundAutomated',
        'is_service_refund_automated' => 'setIsServiceRefundAutomated',
        'supports_automated_refunds' => 'setSupportsAutomatedRefunds'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'free_text_option' => 'getFreeTextOption',
        'can_refund_shipping' => 'getCanRefundShipping',
        'order_has_service_items' => 'getOrderHasServiceItems',
        'is_shipping_refund_automated' => 'getIsShippingRefundAutomated',
        'is_service_refund_automated' => 'getIsServiceRefundAutomated',
        'supports_automated_refunds' => 'getSupportsAutomatedRefunds'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    public const FREE_TEXT_OPTION_OK = 'OK';
    public const FREE_TEXT_OPTION_CHANNEL_REFUND_FUNCTIONALITY_NOT_IMPLEMENTED = 'ChannelRefundFunctionalityNotImplemented';
    public const FREE_TEXT_OPTION_CHANNEL_REFUNDS_DISABLED = 'ChannelRefundsDisabled';
    public const FREE_TEXT_OPTION_NOT_ALLOWED = 'NotAllowed';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getFreeTextOptionAllowableValues()
    {
        return [
            self::FREE_TEXT_OPTION_OK,
            self::FREE_TEXT_OPTION_CHANNEL_REFUND_FUNCTIONALITY_NOT_IMPLEMENTED,
            self::FREE_TEXT_OPTION_CHANNEL_REFUNDS_DISABLED,
            self::FREE_TEXT_OPTION_NOT_ALLOWED,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('free_text_option', $data ?? [], null);
        $this->setIfExists('can_refund_shipping', $data ?? [], null);
        $this->setIfExists('order_has_service_items', $data ?? [], null);
        $this->setIfExists('is_shipping_refund_automated', $data ?? [], null);
        $this->setIfExists('is_service_refund_automated', $data ?? [], null);
        $this->setIfExists('supports_automated_refunds', $data ?? [], null);
    }

    /**
    * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
    * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
    * $this->openAPINullablesSetToNull array
    *
    * @param string $variableName
    * @param array  $fields
    * @param mixed  $defaultValue
    */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getFreeTextOptionAllowableValues();
        if (!is_null($this->container['free_text_option']) && !in_array($this->container['free_text_option'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'free_text_option', must be one of '%s'",
                $this->container['free_text_option'],
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets free_text_option
     *
     * @return string|null
     */
    public function getFreeTextOption()
    {
        return $this->container['free_text_option'];
    }

    /**
     * Sets free_text_option
     *
     * @param string|null $free_text_option Information about channel refund functionality
     *
     * @return self
     */
    public function setFreeTextOption($free_text_option)
    {
        if (is_null($free_text_option)) {
            throw new \InvalidArgumentException('non-nullable free_text_option cannot be null');
        }
        $allowedValues = $this->getFreeTextOptionAllowableValues();
        if (!in_array($free_text_option, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'free_text_option', must be one of '%s'",
                    $free_text_option,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['free_text_option'] = $free_text_option;

        return $this;
    }

    /**
     * Gets can_refund_shipping
     *
     * @return bool|null
     */
    public function getCanRefundShipping()
    {
        return $this->container['can_refund_shipping'];
    }

    /**
     * Sets can_refund_shipping
     *
     * @param bool|null $can_refund_shipping If shipping can be refunded
     *
     * @return self
     */
    public function setCanRefundShipping($can_refund_shipping)
    {
        if (is_null($can_refund_shipping)) {
            throw new \InvalidArgumentException('non-nullable can_refund_shipping cannot be null');
        }
        $this->container['can_refund_shipping'] = $can_refund_shipping;

        return $this;
    }

    /**
     * Gets order_has_service_items
     *
     * @return bool|null
     */
    public function getOrderHasServiceItems()
    {
        return $this->container['order_has_service_items'];
    }

    /**
     * Sets order_has_service_items
     *
     * @param bool|null $order_has_service_items If order got service items
     *
     * @return self
     */
    public function setOrderHasServiceItems($order_has_service_items)
    {
        if (is_null($order_has_service_items)) {
            throw new \InvalidArgumentException('non-nullable order_has_service_items cannot be null');
        }
        $this->container['order_has_service_items'] = $order_has_service_items;

        return $this;
    }

    /**
     * Gets is_shipping_refund_automated
     *
     * @return bool|null
     */
    public function getIsShippingRefundAutomated()
    {
        return $this->container['is_shipping_refund_automated'];
    }

    /**
     * Sets is_shipping_refund_automated
     *
     * @param bool|null $is_shipping_refund_automated If order shipping cost refund automated
     *
     * @return self
     */
    public function setIsShippingRefundAutomated($is_shipping_refund_automated)
    {
        if (is_null($is_shipping_refund_automated)) {
            throw new \InvalidArgumentException('non-nullable is_shipping_refund_automated cannot be null');
        }
        $this->container['is_shipping_refund_automated'] = $is_shipping_refund_automated;

        return $this;
    }

    /**
     * Gets is_service_refund_automated
     *
     * @return bool|null
     */
    public function getIsServiceRefundAutomated()
    {
        return $this->container['is_service_refund_automated'];
    }

    /**
     * Sets is_service_refund_automated
     *
     * @param bool|null $is_service_refund_automated AIf order service refund autoamted
     *
     * @return self
     */
    public function setIsServiceRefundAutomated($is_service_refund_automated)
    {
        if (is_null($is_service_refund_automated)) {
            throw new \InvalidArgumentException('non-nullable is_service_refund_automated cannot be null');
        }
        $this->container['is_service_refund_automated'] = $is_service_refund_automated;

        return $this;
    }

    /**
     * Gets supports_automated_refunds
     *
     * @return bool|null
     */
    public function getSupportsAutomatedRefunds()
    {
        return $this->container['supports_automated_refunds'];
    }

    /**
     * Sets supports_automated_refunds
     *
     * @param bool|null $supports_automated_refunds If automated refund is supported
     *
     * @return self
     */
    public function setSupportsAutomatedRefunds($supports_automated_refunds)
    {
        if (is_null($supports_automated_refunds)) {
            throw new \InvalidArgumentException('non-nullable supports_automated_refunds cannot be null');
        }
        $this->container['supports_automated_refunds'] = $supports_automated_refunds;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed Returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource.
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


