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

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

    public const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static string $openAPIModelName = 'GetDealsMovementsInPipeline_allOf_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 = [
        'movements_between_stages' => '\Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataMovementsBetweenStages',
        'new_deals' => '\Pipedrive\Model\DealsMovementsInfo',
        'deals_left_open' => '\Pipedrive\Model\DealsMovementsInfo',
        'won_deals' => '\Pipedrive\Model\DealsMovementsInfo',
        'lost_deals' => '\Pipedrive\Model\DealsMovementsInfo',
        'average_age_in_days' => '\Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataAverageAgeInDays'
    ];

    /**
      * 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 = [
        'movements_between_stages' => null,
        'new_deals' => null,
        'deals_left_open' => null,
        'won_deals' => null,
        'lost_deals' => null,
        'average_age_in_days' => 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 = [
        'movements_between_stages' => 'movements_between_stages',
        'new_deals' => 'new_deals',
        'deals_left_open' => 'deals_left_open',
        'won_deals' => 'won_deals',
        'lost_deals' => 'lost_deals',
        'average_age_in_days' => 'average_age_in_days'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'movements_between_stages' => 'setMovementsBetweenStages',
        'new_deals' => 'setNewDeals',
        'deals_left_open' => 'setDealsLeftOpen',
        'won_deals' => 'setWonDeals',
        'lost_deals' => 'setLostDeals',
        'average_age_in_days' => 'setAverageAgeInDays'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'movements_between_stages' => 'getMovementsBetweenStages',
        'new_deals' => 'getNewDeals',
        'deals_left_open' => 'getDealsLeftOpen',
        'won_deals' => 'getWonDeals',
        'lost_deals' => 'getLostDeals',
        'average_age_in_days' => 'getAverageAgeInDays'
    ];

    /**
     * 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['movements_between_stages'] = $data['movements_between_stages'] ?? null;
        $this->container['new_deals'] = $data['new_deals'] ?? null;
        $this->container['deals_left_open'] = $data['deals_left_open'] ?? null;
        $this->container['won_deals'] = $data['won_deals'] ?? null;
        $this->container['lost_deals'] = $data['lost_deals'] ?? null;
        $this->container['average_age_in_days'] = $data['average_age_in_days'] ?? 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 movements_between_stages
     *
     * @return \Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataMovementsBetweenStages|null
     */
    public function getMovementsBetweenStages()
    {
        return $this->container['movements_between_stages'];
    }

    /**
     * Sets movements_between_stages
     *
     * @param \Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataMovementsBetweenStages|null $movements_between_stages movements_between_stages
     *
     * @return self
     */
    public function setMovementsBetweenStages($movements_between_stages): self
    {
        $this->container['movements_between_stages'] = $movements_between_stages;

        return $this;
    }

    /**
     * Gets new_deals
     *
     * @return \Pipedrive\Model\DealsMovementsInfo|null
     */
    public function getNewDeals()
    {
        return $this->container['new_deals'];
    }

    /**
     * Sets new_deals
     *
     * @param \Pipedrive\Model\DealsMovementsInfo|null $new_deals new_deals
     *
     * @return self
     */
    public function setNewDeals($new_deals): self
    {
        $this->container['new_deals'] = $new_deals;

        return $this;
    }

    /**
     * Gets deals_left_open
     *
     * @return \Pipedrive\Model\DealsMovementsInfo|null
     */
    public function getDealsLeftOpen()
    {
        return $this->container['deals_left_open'];
    }

    /**
     * Sets deals_left_open
     *
     * @param \Pipedrive\Model\DealsMovementsInfo|null $deals_left_open deals_left_open
     *
     * @return self
     */
    public function setDealsLeftOpen($deals_left_open): self
    {
        $this->container['deals_left_open'] = $deals_left_open;

        return $this;
    }

    /**
     * Gets won_deals
     *
     * @return \Pipedrive\Model\DealsMovementsInfo|null
     */
    public function getWonDeals()
    {
        return $this->container['won_deals'];
    }

    /**
     * Sets won_deals
     *
     * @param \Pipedrive\Model\DealsMovementsInfo|null $won_deals won_deals
     *
     * @return self
     */
    public function setWonDeals($won_deals): self
    {
        $this->container['won_deals'] = $won_deals;

        return $this;
    }

    /**
     * Gets lost_deals
     *
     * @return \Pipedrive\Model\DealsMovementsInfo|null
     */
    public function getLostDeals()
    {
        return $this->container['lost_deals'];
    }

    /**
     * Sets lost_deals
     *
     * @param \Pipedrive\Model\DealsMovementsInfo|null $lost_deals lost_deals
     *
     * @return self
     */
    public function setLostDeals($lost_deals): self
    {
        $this->container['lost_deals'] = $lost_deals;

        return $this;
    }

    /**
     * Gets average_age_in_days
     *
     * @return \Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataAverageAgeInDays|null
     */
    public function getAverageAgeInDays()
    {
        return $this->container['average_age_in_days'];
    }

    /**
     * Sets average_age_in_days
     *
     * @param \Pipedrive\Model\GetDealsMovementsInPipelineAllOfDataAverageAgeInDays|null $average_age_in_days average_age_in_days
     *
     * @return self
     */
    public function setAverageAgeInDays($average_age_in_days): self
    {
        $this->container['average_age_in_days'] = $average_age_in_days;

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


