<?php
/**
 * ProductFieldAllOf
 *
 * PHP version 7.3
 *
 * @category Class
 * @package  Pipedrive
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Pipedrive API v1
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 5.3.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 Pipedrive\Model;

use ArrayAccess;
use JsonException;
use JsonSerializable;
use Pipedrive\Traits\RawData;
use Pipedrive\ObjectSerializer;

/**
 * ProductFieldAllOf Class Doc Comment
 *
 * @category Class
 * @package  Pipedrive
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements ArrayAccess<TKey, TValue>
 * @template TKey int|null
 * @template TValue mixed|null
 */
class ProductFieldAllOf implements ModelInterface, ArrayAccess, JsonSerializable
{
    use RawData;

    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string>
      * @phpsalm-var array<string, string>
      */
    protected static array $openAPITypes = [
        'id' => 'int',
        'key' => 'string',
        'order_nr' => 'int',
        'add_time' => 'string',
        'update_time' => 'string',
        'last_updated_by_user_id' => 'int',
        'created_by_user_id' => 'int',
        'active_flag' => 'bool',
        'edit_flag' => 'bool',
        'add_visible_flag' => 'bool',
        'important_flag' => 'bool',
        'bulk_edit_allowed' => 'bool',
        'searchable_flag' => 'bool',
        'filtering_allowed' => 'bool',
        'sortable_flag' => 'bool',
        'mandatory_flag' => '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 = [
        'id' => null,
        'key' => null,
        'order_nr' => null,
        'add_time' => null,
        'update_time' => null,
        'last_updated_by_user_id' => null,
        'created_by_user_id' => null,
        'active_flag' => null,
        'edit_flag' => null,
        'add_visible_flag' => null,
        'important_flag' => null,
        'bulk_edit_allowed' => null,
        'searchable_flag' => null,
        'filtering_allowed' => null,
        'sortable_flag' => null,
        'mandatory_flag' => null
    ];

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

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @phpstan-return array<string, string|null>
     * @psalm-return array<string, string|null>
     * @return array
     */
    public static function openAPIFormats(): array
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'id' => 'id',
        'key' => 'key',
        'order_nr' => 'order_nr',
        'add_time' => 'add_time',
        'update_time' => 'update_time',
        'last_updated_by_user_id' => 'last_updated_by_user_id',
        'created_by_user_id' => 'created_by_user_id',
        'active_flag' => 'active_flag',
        'edit_flag' => 'edit_flag',
        'add_visible_flag' => 'add_visible_flag',
        'important_flag' => 'important_flag',
        'bulk_edit_allowed' => 'bulk_edit_allowed',
        'searchable_flag' => 'searchable_flag',
        'filtering_allowed' => 'filtering_allowed',
        'sortable_flag' => 'sortable_flag',
        'mandatory_flag' => 'mandatory_flag'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'id' => 'setId',
        'key' => 'setKey',
        'order_nr' => 'setOrderNr',
        'add_time' => 'setAddTime',
        'update_time' => 'setUpdateTime',
        'last_updated_by_user_id' => 'setLastUpdatedByUserId',
        'created_by_user_id' => 'setCreatedByUserId',
        'active_flag' => 'setActiveFlag',
        'edit_flag' => 'setEditFlag',
        'add_visible_flag' => 'setAddVisibleFlag',
        'important_flag' => 'setImportantFlag',
        'bulk_edit_allowed' => 'setBulkEditAllowed',
        'searchable_flag' => 'setSearchableFlag',
        'filtering_allowed' => 'setFilteringAllowed',
        'sortable_flag' => 'setSortableFlag',
        'mandatory_flag' => 'setMandatoryFlag'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'id' => 'getId',
        'key' => 'getKey',
        'order_nr' => 'getOrderNr',
        'add_time' => 'getAddTime',
        'update_time' => 'getUpdateTime',
        'last_updated_by_user_id' => 'getLastUpdatedByUserId',
        'created_by_user_id' => 'getCreatedByUserId',
        'active_flag' => 'getActiveFlag',
        'edit_flag' => 'getEditFlag',
        'add_visible_flag' => 'getAddVisibleFlag',
        'important_flag' => 'getImportantFlag',
        'bulk_edit_allowed' => 'getBulkEditAllowed',
        'searchable_flag' => 'getSearchableFlag',
        'filtering_allowed' => 'getFilteringAllowed',
        'sortable_flag' => 'getSortableFlag',
        'mandatory_flag' => 'getMandatoryFlag'
    ];

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

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function setters(): array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @phpstan-return array<string, string>
     * @psalm-return array<string, string>
     * @return array
     */
    public static function getters(): array
    {
        return self::$getters;
    }

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


    /**
     * Associative array for storing property values
     *
     * @var array
     * @phpstan-var array<int|string, mixed>
     * @psalm-var array<int|string, mixed>
     */
    protected array $container = [];

    /**
     * Constructor
     *
     * @phpstan-param array<string, mixed>|null $data
     * @psalm-param array<string, mixed>|null $data
     * @param array|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['id'] = $data['id'] ?? null;
        $this->container['key'] = $data['key'] ?? null;
        $this->container['order_nr'] = $data['order_nr'] ?? null;
        $this->container['add_time'] = $data['add_time'] ?? null;
        $this->container['update_time'] = $data['update_time'] ?? null;
        $this->container['last_updated_by_user_id'] = $data['last_updated_by_user_id'] ?? null;
        $this->container['created_by_user_id'] = $data['created_by_user_id'] ?? null;
        $this->container['active_flag'] = $data['active_flag'] ?? null;
        $this->container['edit_flag'] = $data['edit_flag'] ?? null;
        $this->container['add_visible_flag'] = $data['add_visible_flag'] ?? null;
        $this->container['important_flag'] = $data['important_flag'] ?? null;
        $this->container['bulk_edit_allowed'] = $data['bulk_edit_allowed'] ?? null;
        $this->container['searchable_flag'] = $data['searchable_flag'] ?? null;
        $this->container['filtering_allowed'] = $data['filtering_allowed'] ?? null;
        $this->container['sortable_flag'] = $data['sortable_flag'] ?? null;
        $this->container['mandatory_flag'] = $data['mandatory_flag'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     * @phpstan-return array<int, string>
     * @psalm-return array<int, string>
     */
    public function listInvalidProperties(): array
    {
        $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(): bool
    {
        return count($this->listInvalidProperties()) === 0;
    }


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

    /**
     * Sets id
     *
     * @param int|null $id The ID of the product field
     *
     * @return self
     */
    public function setId($id): self
    {
        $this->container['id'] = $id;

        return $this;
    }

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

    /**
     * Sets key
     *
     * @param string|null $key The key of the product field
     *
     * @return self
     */
    public function setKey($key): self
    {
        $this->container['key'] = $key;

        return $this;
    }

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

    /**
     * Sets order_nr
     *
     * @param int|null $order_nr The position (index) of the product field in the detail view
     *
     * @return self
     */
    public function setOrderNr($order_nr): self
    {
        $this->container['order_nr'] = $order_nr;

        return $this;
    }

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

    /**
     * Sets add_time
     *
     * @param string|null $add_time The product field creation time. Format: YYYY-MM-DD HH:MM:SS
     *
     * @return self
     */
    public function setAddTime($add_time): self
    {
        $this->container['add_time'] = $add_time;

        return $this;
    }

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

    /**
     * Sets update_time
     *
     * @param string|null $update_time The product field last update time. Format: YYYY-MM-DD HH:MM:SS
     *
     * @return self
     */
    public function setUpdateTime($update_time): self
    {
        $this->container['update_time'] = $update_time;

        return $this;
    }

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

    /**
     * Sets last_updated_by_user_id
     *
     * @param int|null $last_updated_by_user_id The ID of the last user to update the product field
     *
     * @return self
     */
    public function setLastUpdatedByUserId($last_updated_by_user_id): self
    {
        $this->container['last_updated_by_user_id'] = $last_updated_by_user_id;

        return $this;
    }

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

    /**
     * Sets created_by_user_id
     *
     * @param int|null $created_by_user_id The ID of the user who created the product field
     *
     * @return self
     */
    public function setCreatedByUserId($created_by_user_id): self
    {
        $this->container['created_by_user_id'] = $created_by_user_id;

        return $this;
    }

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

    /**
     * Sets active_flag
     *
     * @param bool|null $active_flag Whether or not the product field is currently active
     *
     * @return self
     */
    public function setActiveFlag($active_flag): self
    {
        $this->container['active_flag'] = $active_flag;

        return $this;
    }

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

    /**
     * Sets edit_flag
     *
     * @param bool|null $edit_flag Whether or not the product field name and metadata is editable
     *
     * @return self
     */
    public function setEditFlag($edit_flag): self
    {
        $this->container['edit_flag'] = $edit_flag;

        return $this;
    }

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

    /**
     * Sets add_visible_flag
     *
     * @param bool|null $add_visible_flag Whether or not the product field is visible in the Add Product Modal
     *
     * @return self
     */
    public function setAddVisibleFlag($add_visible_flag): self
    {
        $this->container['add_visible_flag'] = $add_visible_flag;

        return $this;
    }

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

    /**
     * Sets important_flag
     *
     * @param bool|null $important_flag Whether or not the product field is marked as important
     *
     * @return self
     */
    public function setImportantFlag($important_flag): self
    {
        $this->container['important_flag'] = $important_flag;

        return $this;
    }

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

    /**
     * Sets bulk_edit_allowed
     *
     * @param bool|null $bulk_edit_allowed Whether or not the product field data can be edited
     *
     * @return self
     */
    public function setBulkEditAllowed($bulk_edit_allowed): self
    {
        $this->container['bulk_edit_allowed'] = $bulk_edit_allowed;

        return $this;
    }

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

    /**
     * Sets searchable_flag
     *
     * @param bool|null $searchable_flag Whether or not the product field is searchable
     *
     * @return self
     */
    public function setSearchableFlag($searchable_flag): self
    {
        $this->container['searchable_flag'] = $searchable_flag;

        return $this;
    }

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

    /**
     * Sets filtering_allowed
     *
     * @param bool|null $filtering_allowed Whether or not the product field value can be used when filtering searches
     *
     * @return self
     */
    public function setFilteringAllowed($filtering_allowed): self
    {
        $this->container['filtering_allowed'] = $filtering_allowed;

        return $this;
    }

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

    /**
     * Sets sortable_flag
     *
     * @param bool|null $sortable_flag Whether or not the product field is sortable
     *
     * @return self
     */
    public function setSortableFlag($sortable_flag): self
    {
        $this->container['sortable_flag'] = $sortable_flag;

        return $this;
    }

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

    /**
     * Sets mandatory_flag
     *
     * @param bool|null $mandatory_flag Whether or not the product field is mandatory when creating products
     *
     * @return self
     */
    public function setMandatoryFlag($mandatory_flag): self
    {
        $this->container['mandatory_flag'] = $mandatory_flag;

        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
     */
    public function offsetGet($offset): mixed
    {
        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.
     */
    public function jsonSerialize(): mixed
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

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

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


