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

/**
 * LetterRateDetail Class Doc Comment
 *
 * @category Class
 * @description Informative details about the price.
 * @package  USPS\DomesticPrices
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class LetterRateDetail implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerTypes = [
        'sku' => 'string',
        'description' => 'string',
        'price_type' => 'string',
        'price' => 'double',
        'weight' => 'double',
        'fees' => '\USPS\DomesticPrices\Model\RateDetailsFees[]',
        'start_date' => '\DateTime',
        'end_date' => 'string',
        'mail_class' => 'string',
        'extra_services' => '\USPS\DomesticPrices\Model\ExtraServiceRateDetails'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerFormats = [
        'sku' => null,
        'description' => null,
        'price_type' => null,
        'price' => 'double',
        'weight' => 'double',
        'fees' => null,
        'start_date' => 'date',
        'end_date' => null,
        'mail_class' => null,
        'extra_services' => 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',
        'description' => 'description',
        'price_type' => 'priceType',
        'price' => 'price',
        'weight' => 'weight',
        'fees' => 'fees',
        'start_date' => 'startDate',
        'end_date' => 'endDate',
        'mail_class' => 'mailClass',
        'extra_services' => 'extraServices'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'sku' => 'setSku',
        'description' => 'setDescription',
        'price_type' => 'setPriceType',
        'price' => 'setPrice',
        'weight' => 'setWeight',
        'fees' => 'setFees',
        'start_date' => 'setStartDate',
        'end_date' => 'setEndDate',
        'mail_class' => 'setMailClass',
        'extra_services' => 'setExtraServices'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'sku' => 'getSku',
        'description' => 'getDescription',
        'price_type' => 'getPriceType',
        'price' => 'getPrice',
        'weight' => 'getWeight',
        'fees' => 'getFees',
        'start_date' => 'getStartDate',
        'end_date' => 'getEndDate',
        'mail_class' => 'getMailClass',
        'extra_services' => 'getExtraServices'
    ];

    /**
     * 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 PRICE_TYPE_RETAIL = 'RETAIL';
    const MAIL_CLASS_FIRST_CLASS_MAIL = 'FIRST-CLASS_MAIL';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getPriceTypeAllowableValues()
    {
        return [
            self::PRICE_TYPE_RETAIL,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getMailClassAllowableValues()
    {
        return [
            self::MAIL_CLASS_FIRST_CLASS_MAIL,
        ];
    }

    /**
     * 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['description'] = isset($data['description']) ? $data['description'] : null;
        $this->container['price_type'] = isset($data['price_type']) ? $data['price_type'] : null;
        $this->container['price'] = isset($data['price']) ? $data['price'] : null;
        $this->container['weight'] = isset($data['weight']) ? $data['weight'] : null;
        $this->container['fees'] = isset($data['fees']) ? $data['fees'] : null;
        $this->container['start_date'] = isset($data['start_date']) ? $data['start_date'] : null;
        $this->container['end_date'] = isset($data['end_date']) ? $data['end_date'] : null;
        $this->container['mail_class'] = isset($data['mail_class']) ? $data['mail_class'] : null;
        $this->container['extra_services'] = isset($data['extra_services']) ? $data['extra_services'] : null;
    }

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

        $allowedValues = $this->getPriceTypeAllowableValues();
        if (!is_null($this->container['price_type']) && !in_array($this->container['price_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'price_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getMailClassAllowableValues();
        if (!is_null($this->container['mail_class']) && !in_array($this->container['mail_class'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'mail_class', 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 string
     */
    public function getSku()
    {
        return $this->container['sku'];
    }

    /**
     * Sets sku
     *
     * @param string $sku The stock keeping unit for the designated rate.
     *
     * @return $this
     */
    public function setSku($sku)
    {
        $this->container['sku'] = $sku;

        return $this;
    }

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

    /**
     * Sets description
     *
     * @param string $description The description of the price.
     *
     * @return $this
     */
    public function setDescription($description)
    {
        $this->container['description'] = $description;

        return $this;
    }

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

    /**
     * Sets price_type
     *
     * @param string $price_type The type of price type applied (Retail).
     *
     * @return $this
     */
    public function setPriceType($price_type)
    {
        $allowedValues = $this->getPriceTypeAllowableValues();
        if (!is_null($price_type) && !in_array($price_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'price_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['price_type'] = $price_type;

        return $this;
    }

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

    /**
     * Sets price
     *
     * @param double $price The postage price.
     *
     * @return $this
     */
    public function setPrice($price)
    {
        $this->container['price'] = $price;

        return $this;
    }

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

    /**
     * Sets weight
     *
     * @param double $weight The calculated weight for the package based on user input.  The greater of dimWeight and weight will be used to calculated the rate.
     *
     * @return $this
     */
    public function setWeight($weight)
    {
        $this->container['weight'] = $weight;

        return $this;
    }

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

    /**
     * Sets fees
     *
     * @param \USPS\DomesticPrices\Model\RateDetailsFees[] $fees The fees associated with the package.
     *
     * @return $this
     */
    public function setFees($fees)
    {
        $this->container['fees'] = $fees;

        return $this;
    }

    /**
     * Gets start_date
     *
     * @return \DateTime
     */
    public function getStartDate()
    {
        return $this->container['start_date'];
    }

    /**
     * Sets start_date
     *
     * @param \DateTime $start_date Effective start date of the rate.
     *
     * @return $this
     */
    public function setStartDate($start_date)
    {
        $this->container['start_date'] = $start_date;

        return $this;
    }

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

    /**
     * Sets end_date
     *
     * @param string $end_date Effective end date of the rate.  If blank the rate doesn't have an end date as of yet.
     *
     * @return $this
     */
    public function setEndDate($end_date)
    {
        $this->container['end_date'] = $end_date;

        return $this;
    }

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

    /**
     * Sets mail_class
     *
     * @param string $mail_class The mail class of the price.
     *
     * @return $this
     */
    public function setMailClass($mail_class)
    {
        $allowedValues = $this->getMailClassAllowableValues();
        if (!is_null($mail_class) && !in_array($mail_class, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'mail_class', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['mail_class'] = $mail_class;

        return $this;
    }

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

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

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