<?php
/**
 * PublicActionDefinition
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  HubSpot\Client\Automation\Actions
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Automation Actions V4
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v4
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.19.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 HubSpot\Client\Automation\Actions\Model;

use \ArrayAccess;
use \HubSpot\Client\Automation\Actions\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'action_url' => 'string',
        'archived_at' => 'int',
        'execution_rules' => '\HubSpot\Client\Automation\Actions\Model\PublicExecutionTranslationRule[]',
        'functions' => '\HubSpot\Client\Automation\Actions\Model\PublicActionFunctionIdentifier[]',
        'id' => 'string',
        'input_field_dependencies' => '\HubSpot\Client\Automation\Actions\Model\PublicActionDefinitionInputFieldDependenciesInner[]',
        'input_fields' => '\HubSpot\Client\Automation\Actions\Model\InputFieldDefinition[]',
        'labels' => 'array<string,\HubSpot\Client\Automation\Actions\Model\PublicActionLabels>',
        'object_request_options' => '\HubSpot\Client\Automation\Actions\Model\PublicObjectRequestOptions',
        'object_types' => 'string[]',
        'output_fields' => '\HubSpot\Client\Automation\Actions\Model\OutputFieldDefinition[]',
        'published' => 'bool',
        'revision_id' => '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 = [
        'action_url' => null,
        'archived_at' => 'int64',
        'execution_rules' => null,
        'functions' => null,
        'id' => null,
        'input_field_dependencies' => null,
        'input_fields' => null,
        'labels' => null,
        'object_request_options' => null,
        'object_types' => null,
        'output_fields' => null,
        'published' => null,
        'revision_id' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'action_url' => false,
        'archived_at' => false,
        'execution_rules' => false,
        'functions' => false,
        'id' => false,
        'input_field_dependencies' => false,
        'input_fields' => false,
        'labels' => false,
        'object_request_options' => false,
        'object_types' => false,
        'output_fields' => false,
        'published' => false,
        'revision_id' => 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 = [
        'action_url' => 'actionUrl',
        'archived_at' => 'archivedAt',
        'execution_rules' => 'executionRules',
        'functions' => 'functions',
        'id' => 'id',
        'input_field_dependencies' => 'inputFieldDependencies',
        'input_fields' => 'inputFields',
        'labels' => 'labels',
        'object_request_options' => 'objectRequestOptions',
        'object_types' => 'objectTypes',
        'output_fields' => 'outputFields',
        'published' => 'published',
        'revision_id' => 'revisionId'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'action_url' => 'setActionUrl',
        'archived_at' => 'setArchivedAt',
        'execution_rules' => 'setExecutionRules',
        'functions' => 'setFunctions',
        'id' => 'setId',
        'input_field_dependencies' => 'setInputFieldDependencies',
        'input_fields' => 'setInputFields',
        'labels' => 'setLabels',
        'object_request_options' => 'setObjectRequestOptions',
        'object_types' => 'setObjectTypes',
        'output_fields' => 'setOutputFields',
        'published' => 'setPublished',
        'revision_id' => 'setRevisionId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'action_url' => 'getActionUrl',
        'archived_at' => 'getArchivedAt',
        'execution_rules' => 'getExecutionRules',
        'functions' => 'getFunctions',
        'id' => 'getId',
        'input_field_dependencies' => 'getInputFieldDependencies',
        'input_fields' => 'getInputFields',
        'labels' => 'getLabels',
        'object_request_options' => 'getObjectRequestOptions',
        'object_types' => 'getObjectTypes',
        'output_fields' => 'getOutputFields',
        'published' => 'getPublished',
        'revision_id' => 'getRevisionId'
    ];

    /**
     * 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('action_url', $data ?? [], null);
        $this->setIfExists('archived_at', $data ?? [], null);
        $this->setIfExists('execution_rules', $data ?? [], null);
        $this->setIfExists('functions', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('input_field_dependencies', $data ?? [], null);
        $this->setIfExists('input_fields', $data ?? [], null);
        $this->setIfExists('labels', $data ?? [], null);
        $this->setIfExists('object_request_options', $data ?? [], null);
        $this->setIfExists('object_types', $data ?? [], null);
        $this->setIfExists('output_fields', $data ?? [], null);
        $this->setIfExists('published', $data ?? [], null);
        $this->setIfExists('revision_id', $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['action_url'] === null) {
            $invalidProperties[] = "'action_url' can't be null";
        }
        if ($this->container['functions'] === null) {
            $invalidProperties[] = "'functions' can't be null";
        }
        if ($this->container['id'] === null) {
            $invalidProperties[] = "'id' can't be null";
        }
        if ($this->container['input_fields'] === null) {
            $invalidProperties[] = "'input_fields' can't be null";
        }
        if ($this->container['labels'] === null) {
            $invalidProperties[] = "'labels' can't be null";
        }
        if ($this->container['object_types'] === null) {
            $invalidProperties[] = "'object_types' can't be null";
        }
        if ($this->container['published'] === null) {
            $invalidProperties[] = "'published' can't be null";
        }
        if ($this->container['revision_id'] === null) {
            $invalidProperties[] = "'revision_id' can't be null";
        }
        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 action_url
     *
     * @return string
     */
    public function getActionUrl()
    {
        return $this->container['action_url'];
    }

    /**
     * Sets action_url
     *
     * @param string $action_url action_url
     *
     * @return self
     */
    public function setActionUrl($action_url)
    {
        if (is_null($action_url)) {
            throw new \InvalidArgumentException('non-nullable action_url cannot be null');
        }
        $this->container['action_url'] = $action_url;

        return $this;
    }

    /**
     * Gets archived_at
     *
     * @return int|null
     */
    public function getArchivedAt()
    {
        return $this->container['archived_at'];
    }

    /**
     * Sets archived_at
     *
     * @param int|null $archived_at archived_at
     *
     * @return self
     */
    public function setArchivedAt($archived_at)
    {
        if (is_null($archived_at)) {
            throw new \InvalidArgumentException('non-nullable archived_at cannot be null');
        }
        $this->container['archived_at'] = $archived_at;

        return $this;
    }

    /**
     * Gets execution_rules
     *
     * @return \HubSpot\Client\Automation\Actions\Model\PublicExecutionTranslationRule[]|null
     */
    public function getExecutionRules()
    {
        return $this->container['execution_rules'];
    }

    /**
     * Sets execution_rules
     *
     * @param \HubSpot\Client\Automation\Actions\Model\PublicExecutionTranslationRule[]|null $execution_rules execution_rules
     *
     * @return self
     */
    public function setExecutionRules($execution_rules)
    {
        if (is_null($execution_rules)) {
            throw new \InvalidArgumentException('non-nullable execution_rules cannot be null');
        }
        $this->container['execution_rules'] = $execution_rules;

        return $this;
    }

    /**
     * Gets functions
     *
     * @return \HubSpot\Client\Automation\Actions\Model\PublicActionFunctionIdentifier[]
     */
    public function getFunctions()
    {
        return $this->container['functions'];
    }

    /**
     * Sets functions
     *
     * @param \HubSpot\Client\Automation\Actions\Model\PublicActionFunctionIdentifier[] $functions functions
     *
     * @return self
     */
    public function setFunctions($functions)
    {
        if (is_null($functions)) {
            throw new \InvalidArgumentException('non-nullable functions cannot be null');
        }
        $this->container['functions'] = $functions;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param string $id id
     *
     * @return self
     */
    public function setId($id)
    {
        if (is_null($id)) {
            throw new \InvalidArgumentException('non-nullable id cannot be null');
        }
        $this->container['id'] = $id;

        return $this;
    }

    /**
     * Gets input_field_dependencies
     *
     * @return \HubSpot\Client\Automation\Actions\Model\PublicActionDefinitionInputFieldDependenciesInner[]|null
     */
    public function getInputFieldDependencies()
    {
        return $this->container['input_field_dependencies'];
    }

    /**
     * Sets input_field_dependencies
     *
     * @param \HubSpot\Client\Automation\Actions\Model\PublicActionDefinitionInputFieldDependenciesInner[]|null $input_field_dependencies input_field_dependencies
     *
     * @return self
     */
    public function setInputFieldDependencies($input_field_dependencies)
    {
        if (is_null($input_field_dependencies)) {
            throw new \InvalidArgumentException('non-nullable input_field_dependencies cannot be null');
        }
        $this->container['input_field_dependencies'] = $input_field_dependencies;

        return $this;
    }

    /**
     * Gets input_fields
     *
     * @return \HubSpot\Client\Automation\Actions\Model\InputFieldDefinition[]
     */
    public function getInputFields()
    {
        return $this->container['input_fields'];
    }

    /**
     * Sets input_fields
     *
     * @param \HubSpot\Client\Automation\Actions\Model\InputFieldDefinition[] $input_fields input_fields
     *
     * @return self
     */
    public function setInputFields($input_fields)
    {
        if (is_null($input_fields)) {
            throw new \InvalidArgumentException('non-nullable input_fields cannot be null');
        }
        $this->container['input_fields'] = $input_fields;

        return $this;
    }

    /**
     * Gets labels
     *
     * @return array<string,\HubSpot\Client\Automation\Actions\Model\PublicActionLabels>
     */
    public function getLabels()
    {
        return $this->container['labels'];
    }

    /**
     * Sets labels
     *
     * @param array<string,\HubSpot\Client\Automation\Actions\Model\PublicActionLabels> $labels labels
     *
     * @return self
     */
    public function setLabels($labels)
    {
        if (is_null($labels)) {
            throw new \InvalidArgumentException('non-nullable labels cannot be null');
        }
        $this->container['labels'] = $labels;

        return $this;
    }

    /**
     * Gets object_request_options
     *
     * @return \HubSpot\Client\Automation\Actions\Model\PublicObjectRequestOptions|null
     */
    public function getObjectRequestOptions()
    {
        return $this->container['object_request_options'];
    }

    /**
     * Sets object_request_options
     *
     * @param \HubSpot\Client\Automation\Actions\Model\PublicObjectRequestOptions|null $object_request_options object_request_options
     *
     * @return self
     */
    public function setObjectRequestOptions($object_request_options)
    {
        if (is_null($object_request_options)) {
            throw new \InvalidArgumentException('non-nullable object_request_options cannot be null');
        }
        $this->container['object_request_options'] = $object_request_options;

        return $this;
    }

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

    /**
     * Sets object_types
     *
     * @param string[] $object_types object_types
     *
     * @return self
     */
    public function setObjectTypes($object_types)
    {
        if (is_null($object_types)) {
            throw new \InvalidArgumentException('non-nullable object_types cannot be null');
        }
        $this->container['object_types'] = $object_types;

        return $this;
    }

    /**
     * Gets output_fields
     *
     * @return \HubSpot\Client\Automation\Actions\Model\OutputFieldDefinition[]|null
     */
    public function getOutputFields()
    {
        return $this->container['output_fields'];
    }

    /**
     * Sets output_fields
     *
     * @param \HubSpot\Client\Automation\Actions\Model\OutputFieldDefinition[]|null $output_fields output_fields
     *
     * @return self
     */
    public function setOutputFields($output_fields)
    {
        if (is_null($output_fields)) {
            throw new \InvalidArgumentException('non-nullable output_fields cannot be null');
        }
        $this->container['output_fields'] = $output_fields;

        return $this;
    }

    /**
     * Gets published
     *
     * @return bool
     */
    public function getPublished()
    {
        return $this->container['published'];
    }

    /**
     * Sets published
     *
     * @param bool $published published
     *
     * @return self
     */
    public function setPublished($published)
    {
        if (is_null($published)) {
            throw new \InvalidArgumentException('non-nullable published cannot be null');
        }
        $this->container['published'] = $published;

        return $this;
    }

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

    /**
     * Sets revision_id
     *
     * @param string $revision_id revision_id
     *
     * @return self
     */
    public function setRevisionId($revision_id)
    {
        if (is_null($revision_id)) {
            throw new \InvalidArgumentException('non-nullable revision_id cannot be null');
        }
        $this->container['revision_id'] = $revision_id;

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


