<?php

declare(strict_types=1);

namespace AmazonPHP\SellingPartner\Model\Sellers;

use AmazonPHP\SellingPartner\Exception\AssertionException;
use AmazonPHP\SellingPartner\ModelInterface;
use AmazonPHP\SellingPartner\ObjectSerializer;

/**
 * The Selling Partner API for Sellers.
 *
 * The Selling Partner API for Sellers lets you retrieve information on behalf of sellers about their seller account, such as the marketplaces they participate in. Along with listing the marketplaces that a seller can sell in, the API also provides additional information about the marketplace such as the default language and the default currency. The API also provides seller-specific information such as whether the seller has suspended listings in that marketplace.
 *
 * The version of the OpenAPI document: v1
 *
 * This class was auto-generated by https://openapi-generator.tech
 * Do not change it, it will be overwritten with next execution of /bin/generate.sh
 *
 * @implements \ArrayAccess<TKey, TValue>
 *
 * @template TKey int|null
 * @template TValue mixed|null
 */
class Business implements \ArrayAccess, \JsonSerializable, \Stringable, ModelInterface
{
    final public const DISCRIMINATOR = null;

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static array $openAPITypes = [
        'name' => 'string',
        'registered_business_address' => '\AmazonPHP\SellingPartner\Model\Sellers\Address',
        'company_registration_number' => 'string',
        'company_tax_identification_number' => 'string',
        'non_latin_name' => '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 array $openAPIFormats = [
        'name' => null,
        'registered_business_address' => null,
        'company_registration_number' => null,
        'company_tax_identification_number' => null,
        'non_latin_name' => null,
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static array $attributeMap = [
        'name' => 'name',
        'registered_business_address' => 'registeredBusinessAddress',
        'company_registration_number' => 'companyRegistrationNumber',
        'company_tax_identification_number' => 'companyTaxIdentificationNumber',
        'non_latin_name' => 'nonLatinName',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static array $setters = [
        'name' => 'setName',
        'registered_business_address' => 'setRegisteredBusinessAddress',
        'company_registration_number' => 'setCompanyRegistrationNumber',
        'company_tax_identification_number' => 'setCompanyTaxIdentificationNumber',
        'non_latin_name' => 'setNonLatinName',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static array $getters = [
        'name' => 'getName',
        'registered_business_address' => 'getRegisteredBusinessAddress',
        'company_registration_number' => 'getCompanyRegistrationNumber',
        'company_tax_identification_number' => 'getCompanyTaxIdentificationNumber',
        'non_latin_name' => 'getNonLatinName',
    ];

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected array $container = [];

    /**
     * Constructor.
     *
     * @param null|mixed[] $data Associated array of property values
     *                           initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['name'] = $data['name'] ?? null;
        $this->container['registered_business_address'] = $data['registered_business_address'] ?? null;
        $this->container['company_registration_number'] = $data['company_registration_number'] ?? null;
        $this->container['company_tax_identification_number'] = $data['company_tax_identification_number'] ?? null;
        $this->container['non_latin_name'] = $data['non_latin_name'] ?? null;
    }

    /**
     * Array of property to type mappings. Used for (de)serialization.
     */
    public static function openAPITypes() : array
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     */
    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.
     */
    public static function attributeMap() : array
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     */
    public static function setters() : array
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     */
    public static function getters() : array
    {
        return self::$getters;
    }

    /**
     * Gets the string presentation of the object.
     */
    public function __toString() : string
    {
        return (string) \json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

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

    /**
     * Validate all properties.
     *
     * @throws AssertionException
     */
    public function validate() : void
    {
        if ($this->container['name'] === null) {
            throw new AssertionException("'name' can't be null");
        }

        if ($this->container['registered_business_address'] === null) {
            throw new AssertionException("'registered_business_address' can't be null");
        }

        $this->container['registered_business_address']->validate();
    }

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

    /**
     * Sets name.
     *
     * @param string $name the registered business name
     */
    public function setName(string $name) : self
    {
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets registered_business_address.
     */
    public function getRegisteredBusinessAddress() : Address
    {
        return $this->container['registered_business_address'];
    }

    /**
     * Sets registered_business_address.
     *
     * @param Address $registered_business_address registered_business_address
     */
    public function setRegisteredBusinessAddress(Address $registered_business_address) : self
    {
        $this->container['registered_business_address'] = $registered_business_address;

        return $this;
    }

    /**
     * Gets company_registration_number.
     */
    public function getCompanyRegistrationNumber() : ?string
    {
        return $this->container['company_registration_number'];
    }

    /**
     * Sets company_registration_number.
     *
     * @param null|string $company_registration_number The seller's company registration number, if applicable. This field will be absent for individual sellers and sole proprietorships.
     */
    public function setCompanyRegistrationNumber(?string $company_registration_number) : self
    {
        $this->container['company_registration_number'] = $company_registration_number;

        return $this;
    }

    /**
     * Gets company_tax_identification_number.
     */
    public function getCompanyTaxIdentificationNumber() : ?string
    {
        return $this->container['company_tax_identification_number'];
    }

    /**
     * Sets company_tax_identification_number.
     *
     * @param null|string $company_tax_identification_number The seller's company tax identification number, if applicable. This field will be present for certain business types only, such as sole proprietorships.
     */
    public function setCompanyTaxIdentificationNumber(?string $company_tax_identification_number) : self
    {
        $this->container['company_tax_identification_number'] = $company_tax_identification_number;

        return $this;
    }

    /**
     * Gets non_latin_name.
     */
    public function getNonLatinName() : ?string
    {
        return $this->container['non_latin_name'];
    }

    /**
     * Sets non_latin_name.
     *
     * @param null|string $non_latin_name the non-Latin script version of the registered business name, if applicable
     */
    public function setNonLatinName(?string $non_latin_name) : self
    {
        $this->container['non_latin_name'] = $non_latin_name;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     */
    public function offsetExists($offset) : bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset) : mixed
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     */
    public function offsetSet($offset, $value) : void
    {
        if (null === $offset) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     */
    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() : string
    {
        return \json_encode(ObjectSerializer::sanitizeForSerialization($this), JSON_THROW_ON_ERROR);
    }

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