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

/**
 * Labels
 *
 * Contact Us: [USPS API Support](https://emailus.usps.com/s/usps-APIs) | [Terms of Service](https://about.usps.com/termsofuse.htm)  The USPS&#174; Labels API allows you to digitally create mailing labels for the following mail classes: USPS Ground Advantage&#8482;, Parcel Select&#174; Destination Entry, Parcel Select Lightweight&#174;, USPS Connect&#174; Local, USPS Connect&#174; Regional, Priority  Mail&#174;, Priority Mail Express&#174;, Bound Printed Matter, Library Mail, and Media Mail&#174;.  * Use the [Getting Started guide](https://developers.usps.com/getting-started) to get started with the Labels API. * The USPS&#174; Labels API uses a token to authorize the use of an [Enterprise Payment](https://postalpro.usps.com/EPS) or Permit account. The specification to generate the token is in the [Payments 3.0 - Set Payment Account Information](https://developers.usps.com/paymentsv3#tag/Resources/operation/post-payments-payment-authorization).  **Manifest Scheduling**   The following table outlines the Domestic Label manifesting schedule for specific conditions listed below.   | Condition                   | Scheduling | | ----------------------------| -------- | | **Customs Forms labels**    | 12:30am CT on the day after label creation. | | **Return labels**    | 12:30am CT on the day after label creation. | | **Smart Locker labels**     | Electronic data is sent to Postal systems within 15 minutes of label creation. | | **Value of `true` provided for `immediateManifest` field**| Electronic data is sent to Postal systems within 15 minutes of label creation.  | | **Label is added to a [SCAN Form](https://developers.usps.com/scanv3#tag/Resources/operation/post-scan-form)**| Electronic data is sent to Postal systems within 15 minutes of SCAN Form creation.  | | **All other conditions**    | 12:30am CT after the `mailingDate` value provided by the user |
 *
 * OpenAPI spec version: 3.9.9
 * 
 * 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\Labels\Model;
use \USPS\Labels\ObjectSerializer;

/**
 * DomesticPackageReturnOptions Class Doc Comment
 *
 * @category Class
 * @description Options added to packages that are less frequently used
 * @package  USPS\Labels
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class DomesticPackageReturnOptions extends PackageOptions 
{
    const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerTypes = [
        'immediate_manifest' => 'bool',
        'redirect_address' => '',
        'content_type' => 'string',
        'generate_gx_event' => 'bool',
        'containers' => '\USPS\Labels\Model\Container[]',
        'ancillary_service_endorsements' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $swaggerFormats = [
        'immediate_manifest' => null,
        'redirect_address' => null,
        'content_type' => null,
        'generate_gx_event' => null,
        'containers' => null,
        'ancillary_service_endorsements' => null
    ];

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

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

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'immediate_manifest' => 'immediateManifest',
        'redirect_address' => 'redirectAddress',
        'content_type' => 'contentType',
        'generate_gx_event' => 'generateGXEvent',
        'containers' => 'containers',
        'ancillary_service_endorsements' => 'ancillaryServiceEndorsements'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'immediate_manifest' => 'setImmediateManifest',
        'redirect_address' => 'setRedirectAddress',
        'content_type' => 'setContentType',
        'generate_gx_event' => 'setGenerateGxEvent',
        'containers' => 'setContainers',
        'ancillary_service_endorsements' => 'setAncillaryServiceEndorsements'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'immediate_manifest' => 'getImmediateManifest',
        'redirect_address' => 'getRedirectAddress',
        'content_type' => 'getContentType',
        'generate_gx_event' => 'getGenerateGxEvent',
        'containers' => 'getContainers',
        'ancillary_service_endorsements' => 'getAncillaryServiceEndorsements'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return parent::attributeMap() + self::$attributeMap;
    }

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

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

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

    const CONTENT_TYPE_HAZMAT = 'HAZMAT';
    const CONTENT_TYPE_CREMATED_REMAINS = 'CREMATED_REMAINS';
    const CONTENT_TYPE_BEES = 'BEES';
    const CONTENT_TYPE_DAY_OLD_POULTRY = 'DAY_OLD_POULTRY';
    const CONTENT_TYPE_ADULT_BIRDS = 'ADULT_BIRDS';
    const CONTENT_TYPE_OTHER_LIVES = 'OTHER_LIVES';
    const CONTENT_TYPE_PERISHABLE = 'PERISHABLE';
    const CONTENT_TYPE_PHARMACEUTICALS = 'PHARMACEUTICALS';
    const CONTENT_TYPE_MEDICAL_SUPPLIES = 'MEDICAL_SUPPLIES';
    const CONTENT_TYPE_FRUITS = 'FRUITS';
    const CONTENT_TYPE_VEGETABLES = 'VEGETABLES';
    const CONTENT_TYPE_LIVE_PLANTS = 'LIVE_PLANTS';
    const ANCILLARY_SERVICE_ENDORSEMENTS_CHANGE_SERVICE_REQUESTED = 'CHANGE_SERVICE_REQUESTED';
    const ANCILLARY_SERVICE_ENDORSEMENTS_ADDRESS_SERVICE_REQUESTED = 'ADDRESS_SERVICE_REQUESTED';
    const ANCILLARY_SERVICE_ENDORSEMENTS_ELECTRONIC_SERVICE_REQUESTED = 'ELECTRONIC_SERVICE_REQUESTED';
    const ANCILLARY_SERVICE_ENDORSEMENTS_RETURN_SERVICE_REQUESTED = 'RETURN_SERVICE_REQUESTED';
    const ANCILLARY_SERVICE_ENDORSEMENTS_TEMP_RETURN_SERVICE_REQUESTED = 'TEMP_RETURN_SERVICE_REQUESTED';
    const ANCILLARY_SERVICE_ENDORSEMENTS_FORWARDING_SERVICE_REQUESTED = 'FORWARDING_SERVICE_REQUESTED';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getContentTypeAllowableValues()
    {
        return [
            self::CONTENT_TYPE_HAZMAT,
            self::CONTENT_TYPE_CREMATED_REMAINS,
            self::CONTENT_TYPE_BEES,
            self::CONTENT_TYPE_DAY_OLD_POULTRY,
            self::CONTENT_TYPE_ADULT_BIRDS,
            self::CONTENT_TYPE_OTHER_LIVES,
            self::CONTENT_TYPE_PERISHABLE,
            self::CONTENT_TYPE_PHARMACEUTICALS,
            self::CONTENT_TYPE_MEDICAL_SUPPLIES,
            self::CONTENT_TYPE_FRUITS,
            self::CONTENT_TYPE_VEGETABLES,
            self::CONTENT_TYPE_LIVE_PLANTS,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getAncillaryServiceEndorsementsAllowableValues()
    {
        return [
            self::ANCILLARY_SERVICE_ENDORSEMENTS_CHANGE_SERVICE_REQUESTED,
            self::ANCILLARY_SERVICE_ENDORSEMENTS_ADDRESS_SERVICE_REQUESTED,
            self::ANCILLARY_SERVICE_ENDORSEMENTS_ELECTRONIC_SERVICE_REQUESTED,
            self::ANCILLARY_SERVICE_ENDORSEMENTS_RETURN_SERVICE_REQUESTED,
            self::ANCILLARY_SERVICE_ENDORSEMENTS_TEMP_RETURN_SERVICE_REQUESTED,
            self::ANCILLARY_SERVICE_ENDORSEMENTS_FORWARDING_SERVICE_REQUESTED
        ];
    }


    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        parent::__construct($data);

        $this->container['immediate_manifest'] = isset($data['immediate_manifest']) ? $data['immediate_manifest'] : false;
        $this->container['redirect_address'] = isset($data['redirect_address']) ? $data['redirect_address'] : null;
        $this->container['content_type'] = isset($data['content_type']) ? $data['content_type'] : null;
        $this->container['generate_gx_event'] = isset($data['generate_gx_event']) ? $data['generate_gx_event'] : true;
        $this->container['containers'] = isset($data['containers']) ? $data['containers'] : null;
        $this->container['ancillary_service_endorsements'] = isset($data['ancillary_service_endorsements']) ? $data['ancillary_service_endorsements'] : null;
    }

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

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

        $allowedValues = $this->getAncillaryServiceEndorsementsAllowableValues();
        if (!is_null($this->container['ancillary_service_endorsements']) && !in_array($this->container['ancillary_service_endorsements'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'ancillary_service_endorsements', 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 immediate_manifest
     *
     * @return bool
     */
    public function getImmediateManifest()
    {
        return $this->container['immediate_manifest'];
    }

    /**
     * Sets immediate_manifest
     *
     * @param bool $immediate_manifest Setting this field to `true` will send electronic data to Postal systems within 15 minutes of label creation.
     *
     * @return $this
     */
    public function setImmediateManifest($immediate_manifest)
    {
        $this->container['immediate_manifest'] = $immediate_manifest;

        return $this;
    }

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

    /**
     * Sets redirect_address
     *
     * @param  $redirect_address **Deprecated**: Use the `ancillaryServiceEndorsements` field instead.  Address to send the package to if it is not deliverable.  Note:   - Required when `nonDeliveryOption` is a value of `REDIRECT`.
     *
     * @return $this
     */
    public function setRedirectAddress($redirect_address)
    {
        $this->container['redirect_address'] = $redirect_address;

        return $this;
    }

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

    /**
     * Sets content_type
     *
     * @param string $content_type The type of contents in the package. * HAZMAT * CREMATED_REMAINS * BEES * DAY_OLD_POULTRY * ADULT_BIRDS * OTHER_LIVES * PERISHABLE * PHARMACEUTICALS * MEDICAL_SUPPLIES * FRUITS * VEGETABLES * LIVE_PLANTS  Note: * `CREMATED_REMAINS` is currently only eligible for the `PRIORITY_MAIL_EXPRESS_RETURN_SERVICE` mail class.  Please refer to [Publication 139](https://about.usps.com/publications/pub139/welcome.htm) for guidelines on how to package and ship `CREMATED_REMAINS`. * `HAZMAT` domestic labels with destination addresses to APO/FPO/DPO and PTFAS (except Puerto Rico) will not contain any Hazmat markings/indicators, including service type codes in the IMpb. When users indicate a shipment contains hazmat materials in the API request (via content type and/or extra services), that information will still be captured and sent in the shipping services file. For more information, please review the [USPS APIs release notes](https://postalpro.usps.gov/usps-apis-releases) * For guidelines on shipping Hazardous Material, please refer to [Publication 52](https://pe.usps.com/text/pub52/welcome.htm).
     *
     * @return $this
     */
    public function setContentType($content_type)
    {
        $allowedValues = $this->getContentTypeAllowableValues();
        if (!is_null($content_type) && !in_array($content_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'content_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['content_type'] = $content_type;

        return $this;
    }

    /**
     * Gets generate_gx_event
     *
     * @return bool
     */
    public function getGenerateGxEvent()
    {
        return $this->container['generate_gx_event'];
    }

    /**
     * Sets generate_gx_event
     *
     * @param bool $generate_gx_event Provides the option for a user to not create a \"GX\" event for the package. By default, a GX event will be created.
     *
     * @return $this
     */
    public function setGenerateGxEvent($generate_gx_event)
    {
        $this->container['generate_gx_event'] = $generate_gx_event;

        return $this;
    }

    /**
     * Gets containers
     *
     * @return \USPS\Labels\Model\Container[]
     */
    public function getContainers()
    {
        return $this->container['containers'];
    }

    /**
     * Sets containers
     *
     * @param \USPS\Labels\Model\Container[] $containers containers
     *
     * @return $this
     */
    public function setContainers($containers)
    {
        $this->container['containers'] = $containers;

        return $this;
    }

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

    /**
     * Sets ancillary_service_endorsements
     *
     * @param string $ancillary_service_endorsements Endorsements allow the sender to obtain the addressee's new (forwarding) address (provided the appropriate endorsement is used  and if the addressee filed a Change-of-Address Order with the Postal Service) or the reason for non-delivery.  For more information see [PostalPro](https://postalpro.usps.com/address-quality/ancillary-service-endorsements)
     *
     * @return $this
     */
    public function setAncillaryServiceEndorsements($ancillary_service_endorsements)
    {
        $allowedValues = $this->getAncillaryServiceEndorsementsAllowableValues();
        if (!is_null($ancillary_service_endorsements) && !in_array($ancillary_service_endorsements, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'ancillary_service_endorsements', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['ancillary_service_endorsements'] = $ancillary_service_endorsements;

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