<?php

namespace EbaySdk\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for PromotionalShippingDiscountDetailsType StructType
 * Meta information extracted from the WSDL
 * - documentation: Details of a promotional shipping discount.
 * @subpackage Structs
 */
class PromotionalShippingDiscountDetailsType extends AbstractStructBase
{
    /**
     * The DiscountName
     * Meta information extracted from the WSDL
     * - documentation: The type of promotional shipping discount that is detailed in the profile. If the discount type is <code>MaximumShippingCostPerOrder</code>, see <b>ShippingCost</b>. If the discount type is <code>ShippingCostXForAmountY</code>, see
     * <b>ShippingCost</b> and <b>OrderAmount</b>. If the discount type is <code>ShippingCostXForItemCountN</code>, see <b>ShippingCost</b> and <b>ItemCount</b>.
     * - minOccurs: 0
     * @var string
     */
    public $DiscountName;
    /**
     * The ShippingCost
     * Meta information extracted from the WSDL
     * - documentation: This is shipping cost X when <b>DiscountName</b> is either <code>ShippingCostXForAmountY</code> or <code>ShippingCostXForItemCountN</code>, and is the maximum cost when <b>DiscountName</b> is <code>MaximumShippingCostPerOrder</code>.
     * - minOccurs: 0
     * @var \EbaySdk\StructType\AmountType
     */
    public $ShippingCost;
    /**
     * The OrderAmount
     * Meta information extracted from the WSDL
     * - documentation: This is the cost Y of the order (not including shipping cost) when <b>DiscountName</b> is set to <code>ShippingCostXForAmountY</code>.
     * - minOccurs: 0
     * @var \EbaySdk\StructType\AmountType
     */
    public $OrderAmount;
    /**
     * The ItemCount
     * Meta information extracted from the WSDL
     * - documentation: This is the number of items when <b>DiscountName</b> is set to <code>ShippingCostXForItemsY</code>.
     * - minOccurs: 0
     * @var int
     */
    public $ItemCount;
    /**
     * The any
     * @var \DOMDocument
     */
    public $any;
    /**
     * Constructor method for PromotionalShippingDiscountDetailsType
     * @uses PromotionalShippingDiscountDetailsType::setDiscountName()
     * @uses PromotionalShippingDiscountDetailsType::setShippingCost()
     * @uses PromotionalShippingDiscountDetailsType::setOrderAmount()
     * @uses PromotionalShippingDiscountDetailsType::setItemCount()
     * @uses PromotionalShippingDiscountDetailsType::setAny()
     * @param string $discountName
     * @param \EbaySdk\StructType\AmountType $shippingCost
     * @param \EbaySdk\StructType\AmountType $orderAmount
     * @param int $itemCount
     * @param \DOMDocument $any
     */
    public function __construct($discountName = null, \EbaySdk\StructType\AmountType $shippingCost = null, \EbaySdk\StructType\AmountType $orderAmount = null, $itemCount = null, \DOMDocument $any = null)
    {
        $this
            ->setDiscountName($discountName)
            ->setShippingCost($shippingCost)
            ->setOrderAmount($orderAmount)
            ->setItemCount($itemCount)
            ->setAny($any);
    }
    /**
     * Get DiscountName value
     * @return string|null
     */
    public function getDiscountName()
    {
        return $this->DiscountName;
    }
    /**
     * Set DiscountName value
     * @uses \EbaySdk\EnumType\DiscountNameCodeType::valueIsValid()
     * @uses \EbaySdk\EnumType\DiscountNameCodeType::getValidValues()
     * @throws \InvalidArgumentException
     * @param string $discountName
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public function setDiscountName($discountName = null)
    {
        // validation for constraint: enumeration
        if (!\EbaySdk\EnumType\DiscountNameCodeType::valueIsValid($discountName)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \EbaySdk\EnumType\DiscountNameCodeType', is_array($discountName) ? implode(', ', $discountName) : var_export($discountName, true), implode(', ', \EbaySdk\EnumType\DiscountNameCodeType::getValidValues())), __LINE__);
        }
        $this->DiscountName = $discountName;
        return $this;
    }
    /**
     * Get ShippingCost value
     * @return \EbaySdk\StructType\AmountType|null
     */
    public function getShippingCost()
    {
        return $this->ShippingCost;
    }
    /**
     * Set ShippingCost value
     * @param \EbaySdk\StructType\AmountType $shippingCost
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public function setShippingCost(\EbaySdk\StructType\AmountType $shippingCost = null)
    {
        $this->ShippingCost = $shippingCost;
        return $this;
    }
    /**
     * Get OrderAmount value
     * @return \EbaySdk\StructType\AmountType|null
     */
    public function getOrderAmount()
    {
        return $this->OrderAmount;
    }
    /**
     * Set OrderAmount value
     * @param \EbaySdk\StructType\AmountType $orderAmount
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public function setOrderAmount(\EbaySdk\StructType\AmountType $orderAmount = null)
    {
        $this->OrderAmount = $orderAmount;
        return $this;
    }
    /**
     * Get ItemCount value
     * @return int|null
     */
    public function getItemCount()
    {
        return $this->ItemCount;
    }
    /**
     * Set ItemCount value
     * @param int $itemCount
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public function setItemCount($itemCount = null)
    {
        // validation for constraint: int
        if (!is_null($itemCount) && !(is_int($itemCount) || ctype_digit($itemCount))) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($itemCount, true), gettype($itemCount)), __LINE__);
        }
        $this->ItemCount = $itemCount;
        return $this;
    }
    /**
     * Get any value
     * @uses \DOMDocument::loadXML()
     * @param bool $asString true: returns XML string, false: returns \DOMDocument
     * @return \DOMDocument|null
     */
    public function getAny($asString = true)
    {
        $domDocument = null;
        if (!empty($this->any) && !$asString) {
            $domDocument = new \DOMDocument('1.0', 'UTF-8');
            $domDocument->loadXML($this->any);
        }
        return $asString ? $this->any : $domDocument;
    }
    /**
     * Set any value
     * @uses \DOMDocument::hasChildNodes()
     * @uses \DOMDocument::saveXML()
     * @uses \DOMNode::item()
     * @param \DOMDocument $any
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public function setAny(\DOMDocument $any = null)
    {
        $this->any = ($any instanceof \DOMDocument) && $any->hasChildNodes() ? $any->saveXML($any->childNodes->item(0)) : $any;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \EbaySdk\StructType\PromotionalShippingDiscountDetailsType
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
