<?php
/**
 * ChannelObjectResponseData
 *
 * 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;

/**
 * ChannelObjectResponseData 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 ChannelObjectResponseData implements ModelInterface, ArrayAccess, JsonSerializable
{
    use RawData;

    public const DISCRIMINATOR = null;

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

    /**
      * 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' => 'string',
        'name' => 'string',
        'avatar_url' => 'string',
        'provider_channel_id' => 'string',
        'marketplace_client_id' => 'string',
        'pd_company_id' => 'int',
        'pd_user_id' => 'int',
        'created_at' => '\DateTime',
        'provider_type' => 'string',
        'template_support' => '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,
        'name' => null,
        'avatar_url' => null,
        'provider_channel_id' => 'string',
        'marketplace_client_id' => null,
        'pd_company_id' => null,
        'pd_user_id' => null,
        'created_at' => 'date-time',
        'provider_type' => null,
        'template_support' => 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',
        'name' => 'name',
        'avatar_url' => 'avatar_url',
        'provider_channel_id' => 'provider_channel_id',
        'marketplace_client_id' => 'marketplace_client_id',
        'pd_company_id' => 'pd_company_id',
        'pd_user_id' => 'pd_user_id',
        'created_at' => 'created_at',
        'provider_type' => 'provider_type',
        'template_support' => 'template_support'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'id' => 'setId',
        'name' => 'setName',
        'avatar_url' => 'setAvatarUrl',
        'provider_channel_id' => 'setProviderChannelId',
        'marketplace_client_id' => 'setMarketplaceClientId',
        'pd_company_id' => 'setPdCompanyId',
        'pd_user_id' => 'setPdUserId',
        'created_at' => 'setCreatedAt',
        'provider_type' => 'setProviderType',
        'template_support' => 'setTemplateSupport'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'id' => 'getId',
        'name' => 'getName',
        'avatar_url' => 'getAvatarUrl',
        'provider_channel_id' => 'getProviderChannelId',
        'marketplace_client_id' => 'getMarketplaceClientId',
        'pd_company_id' => 'getPdCompanyId',
        'pd_user_id' => 'getPdUserId',
        'created_at' => 'getCreatedAt',
        'provider_type' => 'getProviderType',
        'template_support' => 'getTemplateSupport'
    ];

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

    const PROVIDER_TYPE_FACEBOOK = 'facebook';
    const PROVIDER_TYPE_WHATSAPP = 'whatsapp';
    const PROVIDER_TYPE_OTHER = 'other';

    /**
     * Gets allowable values of the enum
     *
     * @phpstan-return  array<string|int>
     * @phpsalm-return  array<string|int>
     * @return (string|int)[]
     */
    public function getProviderTypeAllowableValues(): array
    {
        return [
            self::PROVIDER_TYPE_FACEBOOK,
            self::PROVIDER_TYPE_WHATSAPP,
            self::PROVIDER_TYPE_OTHER,
        ];
    }

    /**
     * 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['name'] = $data['name'] ?? null;
        $this->container['avatar_url'] = $data['avatar_url'] ?? null;
        $this->container['provider_channel_id'] = $data['provider_channel_id'] ?? null;
        $this->container['marketplace_client_id'] = $data['marketplace_client_id'] ?? null;
        $this->container['pd_company_id'] = $data['pd_company_id'] ?? null;
        $this->container['pd_user_id'] = $data['pd_user_id'] ?? null;
        $this->container['created_at'] = $data['created_at'] ?? null;
        $this->container['provider_type'] = $data['provider_type'] ?? null;
        $this->container['template_support'] = $data['template_support'] ?? 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 = [];

        $allowedValues = $this->getProviderTypeAllowableValues();
        if (!is_null($this->container['provider_type']) && !in_array($this->container['provider_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'provider_type', must be one of '%s'",
                $this->container['provider_type'],
                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(): bool
    {
        return count($this->listInvalidProperties()) === 0;
    }


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

    /**
     * Sets id
     *
     * @param string|null $id The unique channel ID used internally in omnichannel-api and the frontend of the extension
     *
     * @return self
     */
    public function setId($id): self
    {
        $this->container['id'] = $id;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets avatar_url
     *
     * @param string|null $avatar_url The URL for an icon that represents your channel
     *
     * @return self
     */
    public function setAvatarUrl($avatar_url): self
    {
        $this->container['avatar_url'] = $avatar_url;

        return $this;
    }

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

    /**
     * Sets provider_channel_id
     *
     * @param string|null $provider_channel_id The channel ID you specified while creating the channel
     *
     * @return self
     */
    public function setProviderChannelId($provider_channel_id): self
    {
        $this->container['provider_channel_id'] = $provider_channel_id;

        return $this;
    }

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

    /**
     * Sets marketplace_client_id
     *
     * @param string|null $marketplace_client_id The client_id of your app in Pipedrive marketplace
     *
     * @return self
     */
    public function setMarketplaceClientId($marketplace_client_id): self
    {
        $this->container['marketplace_client_id'] = $marketplace_client_id;

        return $this;
    }

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

    /**
     * Sets pd_company_id
     *
     * @param int|null $pd_company_id The ID of the user's company in Pipedrive
     *
     * @return self
     */
    public function setPdCompanyId($pd_company_id): self
    {
        $this->container['pd_company_id'] = $pd_company_id;

        return $this;
    }

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

    /**
     * Sets pd_user_id
     *
     * @param int|null $pd_user_id The ID of the user in Pipedrive
     *
     * @return self
     */
    public function setPdUserId($pd_user_id): self
    {
        $this->container['pd_user_id'] = $pd_user_id;

        return $this;
    }

    /**
     * Gets created_at
     *
     * @return \DateTime|null
     */
    public function getCreatedAt()
    {
        return $this->container['created_at'];
    }

    /**
     * Sets created_at
     *
     * @param \DateTime|null $created_at The date and time when your channel was created in the API
     *
     * @return self
     */
    public function setCreatedAt($created_at): self
    {
        $this->container['created_at'] = $created_at;

        return $this;
    }

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

    /**
     * Sets provider_type
     *
     * @param string|null $provider_type Value of the provider_type sent to this endpoint
     *
     * @return self
     */
    public function setProviderType($provider_type): self
    {
        $allowedValues = $this->getProviderTypeAllowableValues();
        if (!is_null($provider_type) && !in_array($provider_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'provider_type', must be one of '%s'",
                    $provider_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['provider_type'] = $provider_type;

        return $this;
    }

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

    /**
     * Sets template_support
     *
     * @param bool|null $template_support Value of the template_support sent to this endpoint
     *
     * @return self
     */
    public function setTemplateSupport($template_support): self
    {
        $this->container['template_support'] = $template_support;

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


