<?php

/**
 * Management API
 *
 * The version of the OpenAPI document: 3
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.0.1
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


namespace Adyen\Model\Management;

use \ArrayAccess;
use Adyen\Model\Management\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'cardholderReceipt' => '\Adyen\Model\Management\CardholderReceipt',
        'connectivity' => '\Adyen\Model\Management\Connectivity',
        'gratuities' => '\Adyen\Model\Management\Gratuity[]',
        'hardware' => '\Adyen\Model\Management\Hardware',
        'localization' => '\Adyen\Model\Management\Localization',
        'nexo' => '\Adyen\Model\Management\Nexo',
        'offlineProcessing' => '\Adyen\Model\Management\OfflineProcessing',
        'opi' => '\Adyen\Model\Management\Opi',
        'passcodes' => '\Adyen\Model\Management\Passcodes',
        'payAtTable' => '\Adyen\Model\Management\PayAtTable',
        'payment' => '\Adyen\Model\Management\Payment',
        'receiptOptions' => '\Adyen\Model\Management\ReceiptOptions',
        'receiptPrinting' => '\Adyen\Model\Management\ReceiptPrinting',
        'refunds' => '\Adyen\Model\Management\Refunds',
        'signature' => '\Adyen\Model\Management\Signature',
        'standalone' => '\Adyen\Model\Management\Standalone',
        'storeAndForward' => '\Adyen\Model\Management\StoreAndForward',
        'surcharge' => '\Adyen\Model\Management\Surcharge',
        'tapToPay' => '\Adyen\Model\Management\TapToPay',
        'terminalInstructions' => '\Adyen\Model\Management\TerminalInstructions',
        'timeouts' => '\Adyen\Model\Management\Timeouts',
        'wifiProfiles' => '\Adyen\Model\Management\WifiProfiles'
    ];

    /**
      * 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 = [
        'cardholderReceipt' => null,
        'connectivity' => null,
        'gratuities' => null,
        'hardware' => null,
        'localization' => null,
        'nexo' => null,
        'offlineProcessing' => null,
        'opi' => null,
        'passcodes' => null,
        'payAtTable' => null,
        'payment' => null,
        'receiptOptions' => null,
        'receiptPrinting' => null,
        'refunds' => null,
        'signature' => null,
        'standalone' => null,
        'storeAndForward' => null,
        'surcharge' => null,
        'tapToPay' => null,
        'terminalInstructions' => null,
        'timeouts' => null,
        'wifiProfiles' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static $openAPINullables = [
        'cardholderReceipt' => false,
        'connectivity' => false,
        'gratuities' => true,
        'hardware' => false,
        'localization' => false,
        'nexo' => false,
        'offlineProcessing' => false,
        'opi' => false,
        'passcodes' => false,
        'payAtTable' => false,
        'payment' => false,
        'receiptOptions' => false,
        'receiptPrinting' => false,
        'refunds' => false,
        'signature' => false,
        'standalone' => false,
        'storeAndForward' => false,
        'surcharge' => false,
        'tapToPay' => false,
        'terminalInstructions' => false,
        'timeouts' => false,
        'wifiProfiles' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected $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 = [
        'cardholderReceipt' => 'cardholderReceipt',
        'connectivity' => 'connectivity',
        'gratuities' => 'gratuities',
        'hardware' => 'hardware',
        'localization' => 'localization',
        'nexo' => 'nexo',
        'offlineProcessing' => 'offlineProcessing',
        'opi' => 'opi',
        'passcodes' => 'passcodes',
        'payAtTable' => 'payAtTable',
        'payment' => 'payment',
        'receiptOptions' => 'receiptOptions',
        'receiptPrinting' => 'receiptPrinting',
        'refunds' => 'refunds',
        'signature' => 'signature',
        'standalone' => 'standalone',
        'storeAndForward' => 'storeAndForward',
        'surcharge' => 'surcharge',
        'tapToPay' => 'tapToPay',
        'terminalInstructions' => 'terminalInstructions',
        'timeouts' => 'timeouts',
        'wifiProfiles' => 'wifiProfiles'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'cardholderReceipt' => 'setCardholderReceipt',
        'connectivity' => 'setConnectivity',
        'gratuities' => 'setGratuities',
        'hardware' => 'setHardware',
        'localization' => 'setLocalization',
        'nexo' => 'setNexo',
        'offlineProcessing' => 'setOfflineProcessing',
        'opi' => 'setOpi',
        'passcodes' => 'setPasscodes',
        'payAtTable' => 'setPayAtTable',
        'payment' => 'setPayment',
        'receiptOptions' => 'setReceiptOptions',
        'receiptPrinting' => 'setReceiptPrinting',
        'refunds' => 'setRefunds',
        'signature' => 'setSignature',
        'standalone' => 'setStandalone',
        'storeAndForward' => 'setStoreAndForward',
        'surcharge' => 'setSurcharge',
        'tapToPay' => 'setTapToPay',
        'terminalInstructions' => 'setTerminalInstructions',
        'timeouts' => 'setTimeouts',
        'wifiProfiles' => 'setWifiProfiles'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'cardholderReceipt' => 'getCardholderReceipt',
        'connectivity' => 'getConnectivity',
        'gratuities' => 'getGratuities',
        'hardware' => 'getHardware',
        'localization' => 'getLocalization',
        'nexo' => 'getNexo',
        'offlineProcessing' => 'getOfflineProcessing',
        'opi' => 'getOpi',
        'passcodes' => 'getPasscodes',
        'payAtTable' => 'getPayAtTable',
        'payment' => 'getPayment',
        'receiptOptions' => 'getReceiptOptions',
        'receiptPrinting' => 'getReceiptPrinting',
        'refunds' => 'getRefunds',
        'signature' => 'getSignature',
        'standalone' => 'getStandalone',
        'storeAndForward' => 'getStoreAndForward',
        'surcharge' => 'getSurcharge',
        'tapToPay' => 'getTapToPay',
        'terminalInstructions' => 'getTerminalInstructions',
        'timeouts' => 'getTimeouts',
        'wifiProfiles' => 'getWifiProfiles'
    ];

    /**
     * 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[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->setIfExists('cardholderReceipt', $data ?? [], null);
        $this->setIfExists('connectivity', $data ?? [], null);
        $this->setIfExists('gratuities', $data ?? [], null);
        $this->setIfExists('hardware', $data ?? [], null);
        $this->setIfExists('localization', $data ?? [], null);
        $this->setIfExists('nexo', $data ?? [], null);
        $this->setIfExists('offlineProcessing', $data ?? [], null);
        $this->setIfExists('opi', $data ?? [], null);
        $this->setIfExists('passcodes', $data ?? [], null);
        $this->setIfExists('payAtTable', $data ?? [], null);
        $this->setIfExists('payment', $data ?? [], null);
        $this->setIfExists('receiptOptions', $data ?? [], null);
        $this->setIfExists('receiptPrinting', $data ?? [], null);
        $this->setIfExists('refunds', $data ?? [], null);
        $this->setIfExists('signature', $data ?? [], null);
        $this->setIfExists('standalone', $data ?? [], null);
        $this->setIfExists('storeAndForward', $data ?? [], null);
        $this->setIfExists('surcharge', $data ?? [], null);
        $this->setIfExists('tapToPay', $data ?? [], null);
        $this->setIfExists('terminalInstructions', $data ?? [], null);
        $this->setIfExists('timeouts', $data ?? [], null);
        $this->setIfExists('wifiProfiles', $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 = [];

        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 cardholderReceipt
     *
     * @return \Adyen\Model\Management\CardholderReceipt|null
     */
    public function getCardholderReceipt()
    {
        return $this->container['cardholderReceipt'];
    }

    /**
     * Sets cardholderReceipt
     *
     * @param \Adyen\Model\Management\CardholderReceipt|null $cardholderReceipt cardholderReceipt
     *
     * @return self
     */
    public function setCardholderReceipt($cardholderReceipt)
    {
        $this->container['cardholderReceipt'] = $cardholderReceipt;

        return $this;
    }

    /**
     * Gets connectivity
     *
     * @return \Adyen\Model\Management\Connectivity|null
     */
    public function getConnectivity()
    {
        return $this->container['connectivity'];
    }

    /**
     * Sets connectivity
     *
     * @param \Adyen\Model\Management\Connectivity|null $connectivity connectivity
     *
     * @return self
     */
    public function setConnectivity($connectivity)
    {
        $this->container['connectivity'] = $connectivity;

        return $this;
    }

    /**
     * Gets gratuities
     *
     * @return \Adyen\Model\Management\Gratuity[]|null
     */
    public function getGratuities()
    {
        return $this->container['gratuities'];
    }

    /**
     * Sets gratuities
     *
     * @param \Adyen\Model\Management\Gratuity[]|null $gratuities Settings for tipping with or without predefined options to choose from. The maximum number of predefined options is four, or three plus the option to enter a custom tip.
     *
     * @return self
     */
    public function setGratuities($gratuities)
    {
        if (is_null($gratuities)) {
            array_push($this->openAPINullablesSetToNull, 'gratuities');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('gratuities', $nullablesSetToNull);
            if ($index !== false) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['gratuities'] = $gratuities;

        return $this;
    }

    /**
     * Gets hardware
     *
     * @return \Adyen\Model\Management\Hardware|null
     */
    public function getHardware()
    {
        return $this->container['hardware'];
    }

    /**
     * Sets hardware
     *
     * @param \Adyen\Model\Management\Hardware|null $hardware hardware
     *
     * @return self
     */
    public function setHardware($hardware)
    {
        $this->container['hardware'] = $hardware;

        return $this;
    }

    /**
     * Gets localization
     *
     * @return \Adyen\Model\Management\Localization|null
     */
    public function getLocalization()
    {
        return $this->container['localization'];
    }

    /**
     * Sets localization
     *
     * @param \Adyen\Model\Management\Localization|null $localization localization
     *
     * @return self
     */
    public function setLocalization($localization)
    {
        $this->container['localization'] = $localization;

        return $this;
    }

    /**
     * Gets nexo
     *
     * @return \Adyen\Model\Management\Nexo|null
     */
    public function getNexo()
    {
        return $this->container['nexo'];
    }

    /**
     * Sets nexo
     *
     * @param \Adyen\Model\Management\Nexo|null $nexo nexo
     *
     * @return self
     */
    public function setNexo($nexo)
    {
        $this->container['nexo'] = $nexo;

        return $this;
    }

    /**
     * Gets offlineProcessing
     *
     * @return \Adyen\Model\Management\OfflineProcessing|null
     */
    public function getOfflineProcessing()
    {
        return $this->container['offlineProcessing'];
    }

    /**
     * Sets offlineProcessing
     *
     * @param \Adyen\Model\Management\OfflineProcessing|null $offlineProcessing offlineProcessing
     *
     * @return self
     */
    public function setOfflineProcessing($offlineProcessing)
    {
        $this->container['offlineProcessing'] = $offlineProcessing;

        return $this;
    }

    /**
     * Gets opi
     *
     * @return \Adyen\Model\Management\Opi|null
     */
    public function getOpi()
    {
        return $this->container['opi'];
    }

    /**
     * Sets opi
     *
     * @param \Adyen\Model\Management\Opi|null $opi opi
     *
     * @return self
     */
    public function setOpi($opi)
    {
        $this->container['opi'] = $opi;

        return $this;
    }

    /**
     * Gets passcodes
     *
     * @return \Adyen\Model\Management\Passcodes|null
     */
    public function getPasscodes()
    {
        return $this->container['passcodes'];
    }

    /**
     * Sets passcodes
     *
     * @param \Adyen\Model\Management\Passcodes|null $passcodes passcodes
     *
     * @return self
     */
    public function setPasscodes($passcodes)
    {
        $this->container['passcodes'] = $passcodes;

        return $this;
    }

    /**
     * Gets payAtTable
     *
     * @return \Adyen\Model\Management\PayAtTable|null
     */
    public function getPayAtTable()
    {
        return $this->container['payAtTable'];
    }

    /**
     * Sets payAtTable
     *
     * @param \Adyen\Model\Management\PayAtTable|null $payAtTable payAtTable
     *
     * @return self
     */
    public function setPayAtTable($payAtTable)
    {
        $this->container['payAtTable'] = $payAtTable;

        return $this;
    }

    /**
     * Gets payment
     *
     * @return \Adyen\Model\Management\Payment|null
     */
    public function getPayment()
    {
        return $this->container['payment'];
    }

    /**
     * Sets payment
     *
     * @param \Adyen\Model\Management\Payment|null $payment payment
     *
     * @return self
     */
    public function setPayment($payment)
    {
        $this->container['payment'] = $payment;

        return $this;
    }

    /**
     * Gets receiptOptions
     *
     * @return \Adyen\Model\Management\ReceiptOptions|null
     */
    public function getReceiptOptions()
    {
        return $this->container['receiptOptions'];
    }

    /**
     * Sets receiptOptions
     *
     * @param \Adyen\Model\Management\ReceiptOptions|null $receiptOptions receiptOptions
     *
     * @return self
     */
    public function setReceiptOptions($receiptOptions)
    {
        $this->container['receiptOptions'] = $receiptOptions;

        return $this;
    }

    /**
     * Gets receiptPrinting
     *
     * @return \Adyen\Model\Management\ReceiptPrinting|null
     */
    public function getReceiptPrinting()
    {
        return $this->container['receiptPrinting'];
    }

    /**
     * Sets receiptPrinting
     *
     * @param \Adyen\Model\Management\ReceiptPrinting|null $receiptPrinting receiptPrinting
     *
     * @return self
     */
    public function setReceiptPrinting($receiptPrinting)
    {
        $this->container['receiptPrinting'] = $receiptPrinting;

        return $this;
    }

    /**
     * Gets refunds
     *
     * @return \Adyen\Model\Management\Refunds|null
     */
    public function getRefunds()
    {
        return $this->container['refunds'];
    }

    /**
     * Sets refunds
     *
     * @param \Adyen\Model\Management\Refunds|null $refunds refunds
     *
     * @return self
     */
    public function setRefunds($refunds)
    {
        $this->container['refunds'] = $refunds;

        return $this;
    }

    /**
     * Gets signature
     *
     * @return \Adyen\Model\Management\Signature|null
     */
    public function getSignature()
    {
        return $this->container['signature'];
    }

    /**
     * Sets signature
     *
     * @param \Adyen\Model\Management\Signature|null $signature signature
     *
     * @return self
     */
    public function setSignature($signature)
    {
        $this->container['signature'] = $signature;

        return $this;
    }

    /**
     * Gets standalone
     *
     * @return \Adyen\Model\Management\Standalone|null
     */
    public function getStandalone()
    {
        return $this->container['standalone'];
    }

    /**
     * Sets standalone
     *
     * @param \Adyen\Model\Management\Standalone|null $standalone standalone
     *
     * @return self
     */
    public function setStandalone($standalone)
    {
        $this->container['standalone'] = $standalone;

        return $this;
    }

    /**
     * Gets storeAndForward
     *
     * @return \Adyen\Model\Management\StoreAndForward|null
     */
    public function getStoreAndForward()
    {
        return $this->container['storeAndForward'];
    }

    /**
     * Sets storeAndForward
     *
     * @param \Adyen\Model\Management\StoreAndForward|null $storeAndForward storeAndForward
     *
     * @return self
     */
    public function setStoreAndForward($storeAndForward)
    {
        $this->container['storeAndForward'] = $storeAndForward;

        return $this;
    }

    /**
     * Gets surcharge
     *
     * @return \Adyen\Model\Management\Surcharge|null
     */
    public function getSurcharge()
    {
        return $this->container['surcharge'];
    }

    /**
     * Sets surcharge
     *
     * @param \Adyen\Model\Management\Surcharge|null $surcharge surcharge
     *
     * @return self
     */
    public function setSurcharge($surcharge)
    {
        $this->container['surcharge'] = $surcharge;

        return $this;
    }

    /**
     * Gets tapToPay
     *
     * @return \Adyen\Model\Management\TapToPay|null
     */
    public function getTapToPay()
    {
        return $this->container['tapToPay'];
    }

    /**
     * Sets tapToPay
     *
     * @param \Adyen\Model\Management\TapToPay|null $tapToPay tapToPay
     *
     * @return self
     */
    public function setTapToPay($tapToPay)
    {
        $this->container['tapToPay'] = $tapToPay;

        return $this;
    }

    /**
     * Gets terminalInstructions
     *
     * @return \Adyen\Model\Management\TerminalInstructions|null
     */
    public function getTerminalInstructions()
    {
        return $this->container['terminalInstructions'];
    }

    /**
     * Sets terminalInstructions
     *
     * @param \Adyen\Model\Management\TerminalInstructions|null $terminalInstructions terminalInstructions
     *
     * @return self
     */
    public function setTerminalInstructions($terminalInstructions)
    {
        $this->container['terminalInstructions'] = $terminalInstructions;

        return $this;
    }

    /**
     * Gets timeouts
     *
     * @return \Adyen\Model\Management\Timeouts|null
     */
    public function getTimeouts()
    {
        return $this->container['timeouts'];
    }

    /**
     * Sets timeouts
     *
     * @param \Adyen\Model\Management\Timeouts|null $timeouts timeouts
     *
     * @return self
     */
    public function setTimeouts($timeouts)
    {
        $this->container['timeouts'] = $timeouts;

        return $this;
    }

    /**
     * Gets wifiProfiles
     *
     * @return \Adyen\Model\Management\WifiProfiles|null
     */
    public function getWifiProfiles()
    {
        return $this->container['wifiProfiles'];
    }

    /**
     * Sets wifiProfiles
     *
     * @param \Adyen\Model\Management\WifiProfiles|null $wifiProfiles wifiProfiles
     *
     * @return self
     */
    public function setWifiProfiles($wifiProfiles)
    {
        $this->container['wifiProfiles'] = $wifiProfiles;

        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);
    }

    public function toArray(): array
    {
        $array = [];
        foreach (self::$openAPITypes as $propertyName => $propertyType) {
            $propertyValue = $this[$propertyName];
            if ($propertyValue !== null) {
                // Check if the property value is an object and has a toArray() method
                if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
                    $array[$propertyName] = $propertyValue->toArray();
                // Check if it's type datetime
                } elseif ($propertyValue instanceof \DateTime) {
                    $array[$propertyName] = $propertyValue->format(DATE_ATOM);
                // If it's an array type we should check whether it contains objects and if so call toArray method
                } elseif (is_array($propertyValue)) {
                    $array[$propertyName] = array_map(function ($item) {
                        return $item instanceof ModelInterface ? $item->toArray() : $item;
                    }, $propertyValue);
                } else {
                    // Otherwise, directly assign the property value to the array
                    $array[$propertyName] = $propertyValue;
                }
            }
        }
        return $array;
    }

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