<?php
/**
 * GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  StevenBuehner\ChurchTools
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * ChurchTools REST API
 *
 * The ChurchTools REST API is the best entry point for developers to access ChurchTools. <br><br> **Authentication:** You need to be authorized to use some endpoints. Those endpoints are marked by a gray lock symbol. If you view the documentation, while you are logged into ChurchTools, all requests are already authorized. If you want to authorized a request, you need to provide a `Login Token` as `Authorization` header in the format `Authorization: Login<token>` or send a valid cookie. You can use the green \"Authorize\" dialog to enter those details and see how a request would look like in detail. <br><br> **Missing Endpoints:** Not all features are yet available by our new REST API. This documentation will grow in the future. We are working hard to add new endpoints with every ChurchTools version. The documentation will always show only those endpoints you can use with your ChurchTools installation.
 *
 * The version of the OpenAPI document: 0.1.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.21.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 StevenBuehner\ChurchTools\Model;

use \ArrayAccess;
use \StevenBuehner\ChurchTools\ObjectSerializer;

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'api_url' => 'string',
        'domain_attributes' => '\StevenBuehner\ChurchTools\Model\GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroupDomainAttributes',
        'domain_identifier' => 'string',
        'domain_type' => 'string',
        'frontend_url' => 'string',
        'icon' => 'string',
        'image_url' => 'mixed',
        'title' => 'string'
    ];

    /**
     * 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 = [
        'api_url' => null,
        'domain_attributes' => null,
        'domain_identifier' => null,
        'domain_type' => null,
        'frontend_url' => null,
        'icon' => null,
        'image_url' => null,
        'title' => null
    ];

    /**
     * Array of nullable properties. Used for (de)serialization
     *
     * @var boolean[]
     */
    protected static array $openAPINullables = [
        'api_url' => false,
        'domain_attributes' => false,
        'domain_identifier' => false,
        'domain_type' => false,
        'frontend_url' => false,
        'icon' => false,
        'image_url' => true,
        'title' => 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 = [
        'api_url' => 'apiUrl',
        'domain_attributes' => 'domainAttributes',
        'domain_identifier' => 'domainIdentifier',
        'domain_type' => 'domainType',
        'frontend_url' => 'frontendUrl',
        'icon' => 'icon',
        'image_url' => 'imageUrl',
        'title' => 'title'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'api_url' => 'setApiUrl',
        'domain_attributes' => 'setDomainAttributes',
        'domain_identifier' => 'setDomainIdentifier',
        'domain_type' => 'setDomainType',
        'frontend_url' => 'setFrontendUrl',
        'icon' => 'setIcon',
        'image_url' => 'setImageUrl',
        'title' => 'setTitle'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'api_url' => 'getApiUrl',
        'domain_attributes' => 'getDomainAttributes',
        'domain_identifier' => 'getDomainIdentifier',
        'domain_type' => 'getDomainType',
        'frontend_url' => 'getFrontendUrl',
        'icon' => 'getIcon',
        'image_url' => 'getImageUrl',
        'title' => 'getTitle'
    ];

    /**
     * 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;
    }


    /**
     * 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('api_url', $data ?? [], null);
        $this->setIfExists('domain_attributes', $data ?? [], null);
        $this->setIfExists('domain_identifier', $data ?? [], null);
        $this->setIfExists('domain_type', $data ?? [], null);
        $this->setIfExists('frontend_url', $data ?? [], null);
        $this->setIfExists('icon', $data ?? [], null);
        $this->setIfExists('image_url', $data ?? [], null);
        $this->setIfExists('title', $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 = [];

        if ($this->container['api_url'] === null) {
            $invalidProperties[] = "'api_url' can't be null";
        }
        if ((mb_strlen($this->container['api_url']) < 1)) {
            $invalidProperties[] = "invalid value for 'api_url', the character length must be bigger than or equal to 1.";
        }

        if ($this->container['domain_attributes'] === null) {
            $invalidProperties[] = "'domain_attributes' can't be null";
        }
        if ($this->container['domain_identifier'] === null) {
            $invalidProperties[] = "'domain_identifier' can't be null";
        }
        if ((mb_strlen($this->container['domain_identifier']) < 1)) {
            $invalidProperties[] = "invalid value for 'domain_identifier', the character length must be bigger than or equal to 1.";
        }

        if ($this->container['domain_type'] === null) {
            $invalidProperties[] = "'domain_type' can't be null";
        }
        if ((mb_strlen($this->container['domain_type']) < 1)) {
            $invalidProperties[] = "invalid value for 'domain_type', the character length must be bigger than or equal to 1.";
        }

        if ($this->container['frontend_url'] === null) {
            $invalidProperties[] = "'frontend_url' can't be null";
        }
        if ((mb_strlen($this->container['frontend_url']) < 1)) {
            $invalidProperties[] = "invalid value for 'frontend_url', the character length must be bigger than or equal to 1.";
        }

        if ($this->container['icon'] === null) {
            $invalidProperties[] = "'icon' can't be null";
        }
        if ((mb_strlen($this->container['icon']) < 1)) {
            $invalidProperties[] = "invalid value for 'icon', the character length must be bigger than or equal to 1.";
        }

        if ($this->container['title'] === null) {
            $invalidProperties[] = "'title' can't be null";
        }
        if ((mb_strlen($this->container['title']) < 1)) {
            $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 1.";
        }

        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 api_url
     *
     * @return string
     */
    public function getApiUrl()
    {
        return $this->container['api_url'];
    }

    /**
     * Sets api_url
     *
     * @param string $api_url api_url
     *
     * @return self
     */
    public function setApiUrl($api_url)
    {
        if (is_null($api_url)) {
            throw new \InvalidArgumentException('non-nullable api_url cannot be null');
        }

        if ((mb_strlen($api_url) < 1)) {
            throw new \InvalidArgumentException('invalid length for $api_url when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['api_url'] = $api_url;

        return $this;
    }

    /**
     * Gets domain_attributes
     *
     * @return \StevenBuehner\ChurchTools\Model\GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroupDomainAttributes
     */
    public function getDomainAttributes()
    {
        return $this->container['domain_attributes'];
    }

    /**
     * Sets domain_attributes
     *
     * @param \StevenBuehner\ChurchTools\Model\GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroupDomainAttributes $domain_attributes domain_attributes
     *
     * @return self
     */
    public function setDomainAttributes($domain_attributes)
    {
        if (is_null($domain_attributes)) {
            throw new \InvalidArgumentException('non-nullable domain_attributes cannot be null');
        }
        $this->container['domain_attributes'] = $domain_attributes;

        return $this;
    }

    /**
     * Gets domain_identifier
     *
     * @return string
     */
    public function getDomainIdentifier()
    {
        return $this->container['domain_identifier'];
    }

    /**
     * Sets domain_identifier
     *
     * @param string $domain_identifier domain_identifier
     *
     * @return self
     */
    public function setDomainIdentifier($domain_identifier)
    {
        if (is_null($domain_identifier)) {
            throw new \InvalidArgumentException('non-nullable domain_identifier cannot be null');
        }

        if ((mb_strlen($domain_identifier) < 1)) {
            throw new \InvalidArgumentException('invalid length for $domain_identifier when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['domain_identifier'] = $domain_identifier;

        return $this;
    }

    /**
     * Gets domain_type
     *
     * @return string
     */
    public function getDomainType()
    {
        return $this->container['domain_type'];
    }

    /**
     * Sets domain_type
     *
     * @param string $domain_type domain_type
     *
     * @return self
     */
    public function setDomainType($domain_type)
    {
        if (is_null($domain_type)) {
            throw new \InvalidArgumentException('non-nullable domain_type cannot be null');
        }

        if ((mb_strlen($domain_type) < 1)) {
            throw new \InvalidArgumentException('invalid length for $domain_type when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['domain_type'] = $domain_type;

        return $this;
    }

    /**
     * Gets frontend_url
     *
     * @return string
     */
    public function getFrontendUrl()
    {
        return $this->container['frontend_url'];
    }

    /**
     * Sets frontend_url
     *
     * @param string $frontend_url frontend_url
     *
     * @return self
     */
    public function setFrontendUrl($frontend_url)
    {
        if (is_null($frontend_url)) {
            throw new \InvalidArgumentException('non-nullable frontend_url cannot be null');
        }

        if ((mb_strlen($frontend_url) < 1)) {
            throw new \InvalidArgumentException('invalid length for $frontend_url when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['frontend_url'] = $frontend_url;

        return $this;
    }

    /**
     * Gets icon
     *
     * @return string
     */
    public function getIcon()
    {
        return $this->container['icon'];
    }

    /**
     * Sets icon
     *
     * @param string $icon icon
     *
     * @return self
     */
    public function setIcon($icon)
    {
        if (is_null($icon)) {
            throw new \InvalidArgumentException('non-nullable icon cannot be null');
        }

        if ((mb_strlen($icon) < 1)) {
            throw new \InvalidArgumentException('invalid length for $icon when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['icon'] = $icon;

        return $this;
    }

    /**
     * Gets image_url
     *
     * @return mixed|null
     */
    public function getImageUrl()
    {
        return $this->container['image_url'];
    }

    /**
     * Sets image_url
     *
     * @param mixed|null $image_url image_url
     *
     * @return self
     */
    public function setImageUrl($image_url)
    {
        if (is_null($image_url)) {
            array_push($this->openAPINullablesSetToNull, 'image_url');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('image_url', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['image_url'] = $image_url;

        return $this;
    }

    /**
     * Gets title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->container['title'];
    }

    /**
     * Sets title
     *
     * @param string $title title
     *
     * @return self
     */
    public function setTitle($title)
    {
        if (is_null($title)) {
            throw new \InvalidArgumentException('non-nullable title cannot be null');
        }

        if ((mb_strlen($title) < 1)) {
            throw new \InvalidArgumentException('invalid length for $title when calling GetCalendarsCalendarIdAppointmentsAppointmentIdStartDate200ResponseDataGroup., must be bigger than or equal to 1.');
        }

        $this->container['title'] = $title;

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

    /**
     * Gets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet(mixed $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|string $offset Offset
     *
     * @return void
     */
    public function offsetUnset(mixed $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));
    }
}


