<?php
/**
 * ExtraServiceRateDetailsExtraServices
 *
 * PHP version 5
 *
 * @category Class
 * @package  USPS\InternationalPrices
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * International Prices
 *
 * Contact Us: [USPS API Support](https://emailus.usps.com/s/usps-APIs) | [Terms of Service](https://about.usps.com/termsofuse.htm)  The International Prices API allows users to retrieve International postage rates for packages by: * Look up International Base Postage based on a set of given package characteristics * Look up International Base Postage based on a given SKU  The USPS&#174; has implemented Stock Keeping Units (SKUs) which provide unique identification for their products. These SKUs are available for download online for mailers.   For further details on package specifications, delivery information, and more, please consult the [International Mail Manual. (IMM)](https://pe.usps.com/text/imm/welcome.htm). For a list of published rates please refer to the [USPS Price List](https://pe.usps.com/text/dmm300/Notice123.htm) To discover the rate ingredients for this API, take a look at [Publication 205](http://postalpro.usps.com/pub205).    **Authentication, Authorization and Access Control**      Client applications are given authorized access to protected information resources. Authorization is accomplished via the USPS&#174; Customer Onboarding Platform, where Customer Registration users may grant applications access to their protected business information. All client applications must go through this onboarding process. Any Customer Registration user wishing to share their protected business information with client application(s) may also grant authorized access.  The OAuth2, version 3 (/v3), API is based on this authorization grant and must be used to get tokens for all V3 APIs. * The resulting OAuth2 access token is to be placed in the **Authorization** header, using the **Bearer** authentication scheme. * All version 3 APIs validate access to protected information resources and will respond with a *401* HTTP status, *Unauthorized* reason, when the client application has not been authorized to access the given information resource.  The following APIs may include payment account or permit identification used to get contract rates.
 *
 * OpenAPI spec version: 3.3.10
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 * Swagger Codegen version: 3.0.71
 */
/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace USPS\InternationalPrices\Model;

use \ArrayAccess;
use \USPS\InternationalPrices\ObjectSerializer;

/**
 * ExtraServiceRateDetailsExtraServices Class Doc Comment
 *
 * @category Class
 * @package  USPS\InternationalPrices
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class ExtraServiceRateDetailsExtraServices implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerTypes = [
        'sku' => '\USPS\InternationalPrices\Model\SKU',
        'price' => '\USPS\InternationalPrices\Model\Price',
        'price_type' => '\USPS\InternationalPrices\Model\InternationalPriceType',
        'extra_service' => 'int',
        'name' => '\USPS\InternationalPrices\Model\ExtraServiceName',
        'warnings' => '\USPS\InternationalPrices\Model\WarningsList'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerFormats = [
        'sku' => null,
        'price' => null,
        'price_type' => null,
        'extra_service' => null,
        'name' => null,
        'warnings' => null
    ];

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

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

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'sku' => 'SKU',
        'price' => 'price',
        'price_type' => 'priceType',
        'extra_service' => 'extraService',
        'name' => 'name',
        'warnings' => 'warnings'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'sku' => 'setSku',
        'price' => 'setPrice',
        'price_type' => 'setPriceType',
        'extra_service' => 'setExtraService',
        'name' => 'setName',
        'warnings' => 'setWarnings'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'sku' => 'getSku',
        'price' => 'getPrice',
        'price_type' => 'getPriceType',
        'extra_service' => 'getExtraService',
        'name' => 'getName',
        'warnings' => 'getWarnings'
    ];

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

    const EXTRA_SERVICE_370 = 370;
    const EXTRA_SERVICE_813 = 813;
    const EXTRA_SERVICE_820 = 820;
    const EXTRA_SERVICE_826 = 826;
    const EXTRA_SERVICE_857 = 857;
    const EXTRA_SERVICE_930 = 930;
    const EXTRA_SERVICE_931 = 931;
    const EXTRA_SERVICE_955 = 955;

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getExtraServiceAllowableValues()
    {
        return [
            self::EXTRA_SERVICE_370,
            self::EXTRA_SERVICE_813,
            self::EXTRA_SERVICE_820,
            self::EXTRA_SERVICE_826,
            self::EXTRA_SERVICE_857,
            self::EXTRA_SERVICE_930,
            self::EXTRA_SERVICE_931,
            self::EXTRA_SERVICE_955,
        ];
    }

    /**
     * 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->container['sku'] = isset($data['sku']) ? $data['sku'] : null;
        $this->container['price'] = isset($data['price']) ? $data['price'] : null;
        $this->container['price_type'] = isset($data['price_type']) ? $data['price_type'] : null;
        $this->container['extra_service'] = isset($data['extra_service']) ? $data['extra_service'] : null;
        $this->container['name'] = isset($data['name']) ? $data['name'] : null;
        $this->container['warnings'] = isset($data['warnings']) ? $data['warnings'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

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


    /**
     * Gets sku
     *
     * @return \USPS\InternationalPrices\Model\SKU
     */
    public function getSku()
    {
        return $this->container['sku'];
    }

    /**
     * Sets sku
     *
     * @param \USPS\InternationalPrices\Model\SKU $sku sku
     *
     * @return $this
     */
    public function setSku($sku)
    {
        $this->container['sku'] = $sku;

        return $this;
    }

    /**
     * Gets price
     *
     * @return \USPS\InternationalPrices\Model\Price
     */
    public function getPrice()
    {
        return $this->container['price'];
    }

    /**
     * Sets price
     *
     * @param \USPS\InternationalPrices\Model\Price $price price
     *
     * @return $this
     */
    public function setPrice($price)
    {
        $this->container['price'] = $price;

        return $this;
    }

    /**
     * Gets price_type
     *
     * @return \USPS\InternationalPrices\Model\InternationalPriceType
     */
    public function getPriceType()
    {
        return $this->container['price_type'];
    }

    /**
     * Sets price_type
     *
     * @param \USPS\InternationalPrices\Model\InternationalPriceType $price_type price_type
     *
     * @return $this
     */
    public function setPriceType($price_type)
    {
        $this->container['price_type'] = $price_type;

        return $this;
    }

    /**
     * Gets extra_service
     *
     * @return int
     */
    public function getExtraService()
    {
        return $this->container['extra_service'];
    }

    /**
     * Sets extra_service
     *
     * @param int $extra_service Extra Service Code requested * `370` - USPS Delivery Duties Paid Fee * `813` - HAZMAT Class 7 - Radioactive Materials Package * `820` - HAZMAT Class 9 - Lithium batteries, unmarked package * `826` - HAZMAT Division 6.2 – Infectious Substances Package * `857` - Hazardous Material * `930` - Insurance <= $500 * `931` - Insurance > $500 * `955` - Return Receipt (Unsupported as of 01/19/2025)
     *
     * @return $this
     */
    public function setExtraService($extra_service)
    {
        $allowedValues = $this->getExtraServiceAllowableValues();
        if (!is_null($extra_service) && !in_array($extra_service, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'extra_service', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['extra_service'] = $extra_service;

        return $this;
    }

    /**
     * Gets name
     *
     * @return \USPS\InternationalPrices\Model\ExtraServiceName
     */
    public function getName()
    {
        return $this->container['name'];
    }

    /**
     * Sets name
     *
     * @param \USPS\InternationalPrices\Model\ExtraServiceName $name name
     *
     * @return $this
     */
    public function setName($name)
    {
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets warnings
     *
     * @return \USPS\InternationalPrices\Model\WarningsList
     */
    public function getWarnings()
    {
        return $this->container['warnings'];
    }

    /**
     * Sets warnings
     *
     * @param \USPS\InternationalPrices\Model\WarningsList $warnings warnings
     *
     * @return $this
     */
    public function setWarnings($warnings)
    {
        $this->container['warnings'] = $warnings;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

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

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
