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

/**
 * Domestic Prices
 *
 * Contact Us: [USPS API Support](https://emailus.usps.com/s/usps-APIs) | [Terms of Service](https://about.usps.com/termsofuse.htm)  The prices API can be used to calculate postage rates for domestic packages:  * Base postage based on a set of given package characteristics * Base postage based on a given Stock Keeping Units (SKUs) * Extra service postage based on a given extra service code and mail class * A list of eligible products for a given set of package characteristics  For specifications such as package and letter dimensions, delivery information, etc., please refer to the [Domestic Mail Manual (DMM)](https://pe.usps.com/DMM300).  For a list of published prices please refer to the [USPS&#174; Price List](https://pe.usps.com/text/dmm300/Notice123.htm).  To discover the rate ingredients for this API, please visit [Publication 205](https://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.  If all mail classes are needed, please use the /total-rates/search endpoint.
 *
 * OpenAPI spec version: 3.4.27
 * 
 * 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\DomesticPrices\Model;

use \ArrayAccess;
use \USPS\DomesticPrices\ObjectSerializer;

/**
 * LetterRatesQuery Class Doc Comment
 *
 * @category Class
 * @description Letter rate ingredients for calculating base prices.
 * @package  USPS\DomesticPrices
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class LetterRatesQuery implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerTypes = [
        'weight' => '\USPS\DomesticPrices\Model\WeightOunces',
        'length' => 'double',
        'height' => 'double',
        'thickness' => 'double',
        'processing_category' => 'string',
        'mailing_date' => '\USPS\DomesticPrices\Model\MailingDate',
        'non_machinable_indicators' => '\USPS\DomesticPrices\Model\LetterRatesQueryNonMachinableIndicators',
        'extra_services' => 'int[]',
        'item_value' => 'double'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerFormats = [
        'weight' => null,
        'length' => 'double',
        'height' => 'double',
        'thickness' => 'double',
        'processing_category' => null,
        'mailing_date' => null,
        'non_machinable_indicators' => null,
        'extra_services' => null,
        'item_value' => 'double'
    ];

    /**
     * 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 = [
        'weight' => 'weight',
        'length' => 'length',
        'height' => 'height',
        'thickness' => 'thickness',
        'processing_category' => 'processingCategory',
        'mailing_date' => 'mailingDate',
        'non_machinable_indicators' => 'nonMachinableIndicators',
        'extra_services' => 'extraServices',
        'item_value' => 'itemValue'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'weight' => 'setWeight',
        'length' => 'setLength',
        'height' => 'setHeight',
        'thickness' => 'setThickness',
        'processing_category' => 'setProcessingCategory',
        'mailing_date' => 'setMailingDate',
        'non_machinable_indicators' => 'setNonMachinableIndicators',
        'extra_services' => 'setExtraServices',
        'item_value' => 'setItemValue'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'weight' => 'getWeight',
        'length' => 'getLength',
        'height' => 'getHeight',
        'thickness' => 'getThickness',
        'processing_category' => 'getProcessingCategory',
        'mailing_date' => 'getMailingDate',
        'non_machinable_indicators' => 'getNonMachinableIndicators',
        'extra_services' => 'getExtraServices',
        'item_value' => 'getItemValue'
    ];

    /**
     * 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 PROCESSING_CATEGORY_LETTERS = 'LETTERS';
    const PROCESSING_CATEGORY_FLATS = 'FLATS';
    const PROCESSING_CATEGORY_CARDS = 'CARDS';
    const EXTRA_SERVICES__910 = '910';
    const EXTRA_SERVICES__911 = '911';
    const EXTRA_SERVICES__930 = '930';
    const EXTRA_SERVICES__931 = '931';
    const EXTRA_SERVICES__934 = '934';
    const EXTRA_SERVICES__940 = '940';
    const EXTRA_SERVICES__941 = '941';
    const EXTRA_SERVICES__955 = '955';
    const EXTRA_SERVICES__957 = '957';
    const EXTRA_SERVICES__985 = '985';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getProcessingCategoryAllowableValues()
    {
        return [
            self::PROCESSING_CATEGORY_LETTERS,
            self::PROCESSING_CATEGORY_FLATS,
            self::PROCESSING_CATEGORY_CARDS,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getExtraServicesAllowableValues()
    {
        return [
            self::EXTRA_SERVICES__910,
            self::EXTRA_SERVICES__911,
            self::EXTRA_SERVICES__930,
            self::EXTRA_SERVICES__931,
            self::EXTRA_SERVICES__934,
            self::EXTRA_SERVICES__940,
            self::EXTRA_SERVICES__941,
            self::EXTRA_SERVICES__955,
            self::EXTRA_SERVICES__957,
            self::EXTRA_SERVICES__985,
        ];
    }

    /**
     * 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['weight'] = isset($data['weight']) ? $data['weight'] : null;
        $this->container['length'] = isset($data['length']) ? $data['length'] : null;
        $this->container['height'] = isset($data['height']) ? $data['height'] : null;
        $this->container['thickness'] = isset($data['thickness']) ? $data['thickness'] : null;
        $this->container['processing_category'] = isset($data['processing_category']) ? $data['processing_category'] : null;
        $this->container['mailing_date'] = isset($data['mailing_date']) ? $data['mailing_date'] : null;
        $this->container['non_machinable_indicators'] = isset($data['non_machinable_indicators']) ? $data['non_machinable_indicators'] : null;
        $this->container['extra_services'] = isset($data['extra_services']) ? $data['extra_services'] : null;
        $this->container['item_value'] = isset($data['item_value']) ? $data['item_value'] : null;
    }

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

        if ($this->container['weight'] === null) {
            $invalidProperties[] = "'weight' can't be null";
        }
        if ($this->container['length'] === null) {
            $invalidProperties[] = "'length' can't be null";
        }
        if ($this->container['height'] === null) {
            $invalidProperties[] = "'height' can't be null";
        }
        if ($this->container['thickness'] === null) {
            $invalidProperties[] = "'thickness' can't be null";
        }
        if ($this->container['processing_category'] === null) {
            $invalidProperties[] = "'processing_category' can't be null";
        }
        $allowedValues = $this->getProcessingCategoryAllowableValues();
        if (!is_null($this->container['processing_category']) && !in_array($this->container['processing_category'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'processing_category', 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 weight
     *
     * @return \USPS\DomesticPrices\Model\WeightOunces
     */
    public function getWeight()
    {
        return $this->container['weight'];
    }

    /**
     * Sets weight
     *
     * @param \USPS\DomesticPrices\Model\WeightOunces $weight weight
     *
     * @return $this
     */
    public function setWeight($weight)
    {
        $this->container['weight'] = $weight;

        return $this;
    }

    /**
     * Gets length
     *
     * @return double
     */
    public function getLength()
    {
        return $this->container['length'];
    }

    /**
     * Sets length
     *
     * @param double $length The letter/flat/card length measured in inches.  For  `LETTERS` and `CARDS` the length is the dimension parallel to the delivery address as read. For  `FLATS` the length is the longest dimension.
     *
     * @return $this
     */
    public function setLength($length)
    {
        $this->container['length'] = $length;

        return $this;
    }

    /**
     * Gets height
     *
     * @return double
     */
    public function getHeight()
    {
        return $this->container['height'];
    }

    /**
     * Sets height
     *
     * @param double $height The letter/flat/card height measured in inches.  The height is the dimension perpendicular to the length.
     *
     * @return $this
     */
    public function setHeight($height)
    {
        $this->container['height'] = $height;

        return $this;
    }

    /**
     * Gets thickness
     *
     * @return double
     */
    public function getThickness()
    {
        return $this->container['thickness'];
    }

    /**
     * Sets thickness
     *
     * @param double $thickness The letter/flat/card thickness measured in inches. The minimum dimension is always the thickness.
     *
     * @return $this
     */
    public function setThickness($thickness)
    {
        $this->container['thickness'] = $thickness;

        return $this;
    }

    /**
     * Gets processing_category
     *
     * @return string
     */
    public function getProcessingCategory()
    {
        return $this->container['processing_category'];
    }

    /**
     * Sets processing_category
     *
     * @param string $processing_category * LETTERS                  To be eligible for mailing at the price for letters, a piece must be:     * Rectangular     * At least 3-1/2 inches high x 5 inches long x 0.007 inch thick.     * No more than 6-1/8 inches high x 11-1/2 inches long x 1/4 inch thick.    For additional information on letters, please refer to the [Postal Explorer](https://pe.usps.com/businessmail101?ViewName=Letters).  * FLATS     The Postal Service uses the word \"flats\" to refer to large envelopes, newsletters, and magazines. The words large envelopes and flats are used interchangeably. Whatever you call them, flats must:      * Have one dimension that is greater than 6-1/8 inches high OR 11-½ inches long OR ¼ inch thick.     * Be no more than 12 inches high x 15 inches long x ¾ inch thick.    For additional information on flats, please refer to the [Postal Explorer](https://pe.usps.com/businessmail101?ViewName=Flats).  * CARDS     To be eligible for mailing at the price for postcards, a piece must be:     * Rectangular     * At least 3-1/2 inches high x 5 inches long x 0.007 inch thick.     * No more than 4-1/4 inches high x 6 inches long x 0.016 inch thick.    For additional information on postcards, please refer to the [Postal Explorer](https://pe.usps.com/businessmail101?ViewName=Cards).
     *
     * @return $this
     */
    public function setProcessingCategory($processing_category)
    {
        $allowedValues = $this->getProcessingCategoryAllowableValues();
        if (!in_array($processing_category, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'processing_category', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['processing_category'] = $processing_category;

        return $this;
    }

    /**
     * Gets mailing_date
     *
     * @return \USPS\DomesticPrices\Model\MailingDate
     */
    public function getMailingDate()
    {
        return $this->container['mailing_date'];
    }

    /**
     * Sets mailing_date
     *
     * @param \USPS\DomesticPrices\Model\MailingDate $mailing_date mailing_date
     *
     * @return $this
     */
    public function setMailingDate($mailing_date)
    {
        $this->container['mailing_date'] = $mailing_date;

        return $this;
    }

    /**
     * Gets non_machinable_indicators
     *
     * @return \USPS\DomesticPrices\Model\LetterRatesQueryNonMachinableIndicators
     */
    public function getNonMachinableIndicators()
    {
        return $this->container['non_machinable_indicators'];
    }

    /**
     * Sets non_machinable_indicators
     *
     * @param \USPS\DomesticPrices\Model\LetterRatesQueryNonMachinableIndicators $non_machinable_indicators non_machinable_indicators
     *
     * @return $this
     */
    public function setNonMachinableIndicators($non_machinable_indicators)
    {
        $this->container['non_machinable_indicators'] = $non_machinable_indicators;

        return $this;
    }

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

    /**
     * Sets extra_services
     *
     * @param int[] $extra_services Extra Service Code requested. * 910 - Certified Mail * 911 - Certified Mail Restricted Delivery * 930 - Insurance <=$500 * 931 - Insurance > $500 * 934 - Insurance Restricted Delivery * 940 - Registered Mail * 941 - Registered Mail Restricted Delivery * 955 - Return Receipt * 957 - Return Receipt Electronic * 985 - Hold for Pickup
     *
     * @return $this
     */
    public function setExtraServices($extra_services)
    {
        $allowedValues = $this->getExtraServicesAllowableValues();
        if (!is_null($extra_services) && array_diff($extra_services, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'extra_services', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['extra_services'] = $extra_services;

        return $this;
    }

    /**
     * Gets item_value
     *
     * @return double
     */
    public function getItemValue()
    {
        return $this->container['item_value'];
    }

    /**
     * Sets item_value
     *
     * @param double $item_value The value of the item. Required for Insurance.  The price for Insurance and Registered Mail extra services will vary based on this value.
     *
     * @return $this
     */
    public function setItemValue($item_value)
    {
        $this->container['item_value'] = $item_value;

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