<?php
/**
 * UpdateCustomer
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Conekta
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Conekta API
 *
 * Conekta sdk
 *
 * The version of the OpenAPI document: 2.2.0
 * Contact: engineering@conekta.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.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 Conekta\Model;

use \ArrayAccess;
use \Conekta\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'antifraud_info' => '\Conekta\Model\UpdateCustomerAntifraudInfo',
        'date_of_birth' => 'string',
        'default_payment_source_id' => 'string',
        'email' => 'string',
        'name' => 'string',
        'phone' => 'string',
        'plan_id' => 'string',
        'default_shipping_contact_id' => 'string',
        'corporate' => 'bool',
        'custom_reference' => 'string',
        'fiscal_entities' => '\Conekta\Model\CustomerFiscalEntitiesRequest[]',
        'metadata' => 'array<string,mixed>',
        'national_id' => 'string',
        'payment_sources' => '\Conekta\Model\CustomerPaymentMethodsRequest[]',
        'shipping_contacts' => '\Conekta\Model\CustomerShippingContacts[]',
        'subscription' => '\Conekta\Model\SubscriptionRequest'
    ];

    /**
      * 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 = [
        'antifraud_info' => null,
        'date_of_birth' => null,
        'default_payment_source_id' => null,
        'email' => null,
        'name' => null,
        'phone' => null,
        'plan_id' => null,
        'default_shipping_contact_id' => null,
        'corporate' => null,
        'custom_reference' => null,
        'fiscal_entities' => null,
        'metadata' => null,
        'national_id' => null,
        'payment_sources' => null,
        'shipping_contacts' => null,
        'subscription' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'antifraud_info' => true,
        'date_of_birth' => false,
        'default_payment_source_id' => false,
        'email' => false,
        'name' => false,
        'phone' => false,
        'plan_id' => false,
        'default_shipping_contact_id' => false,
        'corporate' => false,
        'custom_reference' => false,
        'fiscal_entities' => false,
        'metadata' => false,
        'national_id' => false,
        'payment_sources' => false,
        'shipping_contacts' => false,
        'subscription' => 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 = [
        'antifraud_info' => 'antifraud_info',
        'date_of_birth' => 'date_of_birth',
        'default_payment_source_id' => 'default_payment_source_id',
        'email' => 'email',
        'name' => 'name',
        'phone' => 'phone',
        'plan_id' => 'plan_id',
        'default_shipping_contact_id' => 'default_shipping_contact_id',
        'corporate' => 'corporate',
        'custom_reference' => 'custom_reference',
        'fiscal_entities' => 'fiscal_entities',
        'metadata' => 'metadata',
        'national_id' => 'national_id',
        'payment_sources' => 'payment_sources',
        'shipping_contacts' => 'shipping_contacts',
        'subscription' => 'subscription'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'antifraud_info' => 'setAntifraudInfo',
        'date_of_birth' => 'setDateOfBirth',
        'default_payment_source_id' => 'setDefaultPaymentSourceId',
        'email' => 'setEmail',
        'name' => 'setName',
        'phone' => 'setPhone',
        'plan_id' => 'setPlanId',
        'default_shipping_contact_id' => 'setDefaultShippingContactId',
        'corporate' => 'setCorporate',
        'custom_reference' => 'setCustomReference',
        'fiscal_entities' => 'setFiscalEntities',
        'metadata' => 'setMetadata',
        'national_id' => 'setNationalId',
        'payment_sources' => 'setPaymentSources',
        'shipping_contacts' => 'setShippingContacts',
        'subscription' => 'setSubscription'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'antifraud_info' => 'getAntifraudInfo',
        'date_of_birth' => 'getDateOfBirth',
        'default_payment_source_id' => 'getDefaultPaymentSourceId',
        'email' => 'getEmail',
        'name' => 'getName',
        'phone' => 'getPhone',
        'plan_id' => 'getPlanId',
        'default_shipping_contact_id' => 'getDefaultShippingContactId',
        'corporate' => 'getCorporate',
        'custom_reference' => 'getCustomReference',
        'fiscal_entities' => 'getFiscalEntities',
        'metadata' => 'getMetadata',
        'national_id' => 'getNationalId',
        'payment_sources' => 'getPaymentSources',
        'shipping_contacts' => 'getShippingContacts',
        'subscription' => 'getSubscription'
    ];

    /**
     * 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('antifraud_info', $data ?? [], null);
        $this->setIfExists('date_of_birth', $data ?? [], null);
        $this->setIfExists('default_payment_source_id', $data ?? [], null);
        $this->setIfExists('email', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('phone', $data ?? [], null);
        $this->setIfExists('plan_id', $data ?? [], null);
        $this->setIfExists('default_shipping_contact_id', $data ?? [], null);
        $this->setIfExists('corporate', $data ?? [], false);
        $this->setIfExists('custom_reference', $data ?? [], null);
        $this->setIfExists('fiscal_entities', $data ?? [], null);
        $this->setIfExists('metadata', $data ?? [], null);
        $this->setIfExists('national_id', $data ?? [], null);
        $this->setIfExists('payment_sources', $data ?? [], null);
        $this->setIfExists('shipping_contacts', $data ?? [], null);
        $this->setIfExists('subscription', $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 (!is_null($this->container['metadata']) && (count($this->container['metadata']) > 100)) {
            $invalidProperties[] = "invalid value for 'metadata', number of items must be less than or equal to 100.";
        }

        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 antifraud_info
     *
     * @return \Conekta\Model\UpdateCustomerAntifraudInfo|null
     */
    public function getAntifraudInfo()
    {
        return $this->container['antifraud_info'];
    }

    /**
     * Sets antifraud_info
     *
     * @param \Conekta\Model\UpdateCustomerAntifraudInfo|null $antifraud_info antifraud_info
     *
     * @return self
     */
    public function setAntifraudInfo($antifraud_info)
    {
        if (is_null($antifraud_info)) {
            array_push($this->openAPINullablesSetToNull, 'antifraud_info');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('antifraud_info', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['antifraud_info'] = $antifraud_info;

        return $this;
    }

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

    /**
     * Sets date_of_birth
     *
     * @param string|null $date_of_birth It is a parameter that allows to identify the date of birth of the client.
     *
     * @return self
     */
    public function setDateOfBirth($date_of_birth)
    {
        if (is_null($date_of_birth)) {
            throw new \InvalidArgumentException('non-nullable date_of_birth cannot be null');
        }
        $this->container['date_of_birth'] = $date_of_birth;

        return $this;
    }

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

    /**
     * Sets default_payment_source_id
     *
     * @param string|null $default_payment_source_id It is a parameter that allows to identify in the response, the Conekta ID of a payment method (payment_id)
     *
     * @return self
     */
    public function setDefaultPaymentSourceId($default_payment_source_id)
    {
        if (is_null($default_payment_source_id)) {
            throw new \InvalidArgumentException('non-nullable default_payment_source_id cannot be null');
        }
        $this->container['default_payment_source_id'] = $default_payment_source_id;

        return $this;
    }

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

    /**
     * Sets email
     *
     * @param string|null $email An email address is a series of customizable characters followed by a universal Internet symbol, the at symbol (@), the name of a host server, and a web domain ending (.mx, .com, .org, . net, etc).
     *
     * @return self
     */
    public function setEmail($email)
    {
        if (is_null($email)) {
            throw new \InvalidArgumentException('non-nullable email cannot be null');
        }
        $this->container['email'] = $email;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets phone
     *
     * @param string|null $phone Is the customer's phone number
     *
     * @return self
     */
    public function setPhone($phone)
    {
        if (is_null($phone)) {
            throw new \InvalidArgumentException('non-nullable phone cannot be null');
        }
        $this->container['phone'] = $phone;

        return $this;
    }

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

    /**
     * Sets plan_id
     *
     * @param string|null $plan_id Contains the ID of a plan, which could together with name, email and phone create a client directly to a subscription
     *
     * @return self
     */
    public function setPlanId($plan_id)
    {
        if (is_null($plan_id)) {
            throw new \InvalidArgumentException('non-nullable plan_id cannot be null');
        }
        $this->container['plan_id'] = $plan_id;

        return $this;
    }

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

    /**
     * Sets default_shipping_contact_id
     *
     * @param string|null $default_shipping_contact_id It is a parameter that allows to identify in the response, the Conekta ID of the shipping address (shipping_contact)
     *
     * @return self
     */
    public function setDefaultShippingContactId($default_shipping_contact_id)
    {
        if (is_null($default_shipping_contact_id)) {
            throw new \InvalidArgumentException('non-nullable default_shipping_contact_id cannot be null');
        }
        $this->container['default_shipping_contact_id'] = $default_shipping_contact_id;

        return $this;
    }

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

    /**
     * Sets corporate
     *
     * @param bool|null $corporate It is a value that allows identifying if the email is corporate or not.
     *
     * @return self
     */
    public function setCorporate($corporate)
    {
        if (is_null($corporate)) {
            throw new \InvalidArgumentException('non-nullable corporate cannot be null');
        }
        $this->container['corporate'] = $corporate;

        return $this;
    }

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

    /**
     * Sets custom_reference
     *
     * @param string|null $custom_reference It is an undefined value.
     *
     * @return self
     */
    public function setCustomReference($custom_reference)
    {
        if (is_null($custom_reference)) {
            throw new \InvalidArgumentException('non-nullable custom_reference cannot be null');
        }
        $this->container['custom_reference'] = $custom_reference;

        return $this;
    }

    /**
     * Gets fiscal_entities
     *
     * @return \Conekta\Model\CustomerFiscalEntitiesRequest[]|null
     */
    public function getFiscalEntities()
    {
        return $this->container['fiscal_entities'];
    }

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

        return $this;
    }

    /**
     * Gets metadata
     *
     * @return array<string,mixed>|null
     */
    public function getMetadata()
    {
        return $this->container['metadata'];
    }

    /**
     * Sets metadata
     *
     * @param array<string,mixed>|null $metadata metadata
     *
     * @return self
     */
    public function setMetadata($metadata)
    {
        if (is_null($metadata)) {
            throw new \InvalidArgumentException('non-nullable metadata cannot be null');
        }

        if ((count($metadata) > 100)) {
            throw new \InvalidArgumentException('invalid value for $metadata when calling UpdateCustomer., number of items must be less than or equal to 100.');
        }
        $this->container['metadata'] = $metadata;

        return $this;
    }

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

    /**
     * Sets national_id
     *
     * @param string|null $national_id It is a parameter that allows to identify the national identification number of the client.
     *
     * @return self
     */
    public function setNationalId($national_id)
    {
        if (is_null($national_id)) {
            throw new \InvalidArgumentException('non-nullable national_id cannot be null');
        }
        $this->container['national_id'] = $national_id;

        return $this;
    }

    /**
     * Gets payment_sources
     *
     * @return \Conekta\Model\CustomerPaymentMethodsRequest[]|null
     */
    public function getPaymentSources()
    {
        return $this->container['payment_sources'];
    }

    /**
     * Sets payment_sources
     *
     * @param \Conekta\Model\CustomerPaymentMethodsRequest[]|null $payment_sources Contains details of the payment methods that the customer has active or has used in Conekta
     *
     * @return self
     */
    public function setPaymentSources($payment_sources)
    {
        if (is_null($payment_sources)) {
            throw new \InvalidArgumentException('non-nullable payment_sources cannot be null');
        }
        $this->container['payment_sources'] = $payment_sources;

        return $this;
    }

    /**
     * Gets shipping_contacts
     *
     * @return \Conekta\Model\CustomerShippingContacts[]|null
     */
    public function getShippingContacts()
    {
        return $this->container['shipping_contacts'];
    }

    /**
     * Sets shipping_contacts
     *
     * @param \Conekta\Model\CustomerShippingContacts[]|null $shipping_contacts Contains the detail of the shipping addresses that the client has active or has used in Conekta
     *
     * @return self
     */
    public function setShippingContacts($shipping_contacts)
    {
        if (is_null($shipping_contacts)) {
            throw new \InvalidArgumentException('non-nullable shipping_contacts cannot be null');
        }
        $this->container['shipping_contacts'] = $shipping_contacts;

        return $this;
    }

    /**
     * Gets subscription
     *
     * @return \Conekta\Model\SubscriptionRequest|null
     */
    public function getSubscription()
    {
        return $this->container['subscription'];
    }

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

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

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


