<?php

namespace LewisLarsen\Ebay\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for BuyerType StructType
 * Meta information extracted from the WSDL
 * - documentation: This type is used by various <b>Get</b> calls, including <b>GetItem</b> and <b>GetOrders</b>. Only the order management calls return the <b>BuyerTaxIdentifier</b> container, and each call that uses <b>BuyerType</b> uses the
 * <b>ShippingAddress</b> container a little differently.
 * @subpackage Structs
 */
class BuyerType extends AbstractStructBase
{
    /**
     * The ShippingAddress
     * Meta information extracted from the WSDL
     * - documentation: This container shows the buyer's shipping address. <br> <br> <span class="tablenote"><b>Note:</b> For an Authenticity Guarantee program order returned in <b>GetItemTransactions</b> or <b>GetSellerTransactions</b>, this is the address
     * of the authenticator's warehouse. The authenticator is responsible for delivery to the buyer's shipping address. </span> <p><span class="tablenote"><b>Note:</b> For eBay Vault scenarios: <strong>GetItemTransactions</strong> calls, and
     * <strong>GetSellerTransactions</strong> calls (Seller View only), mock address details are returned for: <br/> - Vault to vault orders: Buyer and Seller View<br /> - Ship to vault orders: Mock addresses are returned for the Buyer View (only); the
     * address returned for the Seller View will be the authenticator&apos;s address.<br> The following address details are returned for mock addresses:</span></p> <pre> &lt;ShippingAddress&gt; <br/> <code> &nbsp;&lt;Name&gt;eBay Vault&lt;/Name&gt;</code>
     * <br/> <code> &nbsp;&lt;AddressID&gt;Invalid Request&lt;/AddressID&gt;</code> <br/> <code> &nbsp;&lt;AddressOwner&gt;eBay&lt;/AddressOwner&gt;</code> <br/> <code> &nbsp;&lt;AddressUsage&gt;Invalid&lt;/AddressUsage&gt;</code> <br/> <code>
     * &nbsp;&lt;CityName&gt;Invalid Request&lt;/CityName&gt;</code> <br/> <code> &nbsp;&lt;Country&gt;US&lt;/Country&gt;</code> <br/> <code> &nbsp;&lt;CountryName&gt;Invalid Request&lt;/CountryName&gt;</code> <br/> <code>
     * &nbsp;&lt;ExternalAddressID&gt;Invalid Request&lt;/ExternalAddressID&gt;</code> <br/> <code> &nbsp;&lt;Phone&gt;Invalid Request&lt;/Phone&gt;</code> <br/> <code> &nbsp;&lt;PostalCode&gt;Invalid Request&lt;/PostalCode&gt;</code> <br/> <code>
     * &nbsp;&lt;StateOrProvince&gt;Invalid Request&lt;/StateOrProvince&gt;</code> <br/> <code> &nbsp;&lt;Street1&gt;Invalid Request&lt;/Street1&gt;</code> <br/> <code> &nbsp;&lt;Street2&gt;&lt;/Street2&gt;</code> <br/> &lt;/ShippingAddress&gt; </pre> <br/>
     * - minOccurs: 0
     * @var \LewisLarsen\Ebay\StructType\AddressType
     */
    public $ShippingAddress;
    /**
     * The BuyerTaxIdentifier
     * Meta information extracted from the WSDL
     * - documentation: This container consists of taxpayer identification for the buyer. Although this container may be used for other purposes at a later date, it is currently used by sellers selling on the Italy or Spain site to retrieve the taxpayer ID
     * of the buyer. <br/><br/> It is now required that buyers registered on the Italy site provide their Codice Fiscale ID (similar to the Social Security Number for US citizens) before buying an item on the Italy site. <br/><br/> On the Spain site, a
     * Spanish seller has the option to require that Spanish buyers (registered on Spain site) provide a tax ID before checkout. This option is set by the seller at the account level. Once a Spanish buyer provides a tax ID, this tax ID is associated with
     * his/her account, and once a tax ID is associated with the account, Spanish buyer will be asked to provide the tax ID during checkout on all eBay sites. Buyers with a registered address outside of Spain will not be asked to provide a tax ID during
     * checkout. <br/><br/> This container is only returned for Spanish or Italian sellers when the buyer was asked to provide tax identifier information during checkout. A <strong>BuyerTaxIdentifier</strong> will be returned for each tax ID that is
     * associated with the buyer's account.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \LewisLarsen\Ebay\StructType\TaxIdentifierType[]
     */
    public $BuyerTaxIdentifier;
    /**
     * The any
     * @var \DOMDocument
     */
    public $any;
    /**
     * Constructor method for BuyerType
     * @uses BuyerType::setShippingAddress()
     * @uses BuyerType::setBuyerTaxIdentifier()
     * @uses BuyerType::setAny()
     * @param \LewisLarsen\Ebay\StructType\AddressType $shippingAddress
     * @param \LewisLarsen\Ebay\StructType\TaxIdentifierType[] $buyerTaxIdentifier
     * @param \DOMDocument $any
     */
    public function __construct(\LewisLarsen\Ebay\StructType\AddressType $shippingAddress = null, array $buyerTaxIdentifier = array(), \DOMDocument $any = null)
    {
        $this
            ->setShippingAddress($shippingAddress)
            ->setBuyerTaxIdentifier($buyerTaxIdentifier)
            ->setAny($any);
    }
    /**
     * Get ShippingAddress value
     * @return \LewisLarsen\Ebay\StructType\AddressType|null
     */
    public function getShippingAddress()
    {
        return $this->ShippingAddress;
    }
    /**
     * Set ShippingAddress value
     * @param \LewisLarsen\Ebay\StructType\AddressType $shippingAddress
     * @return \LewisLarsen\Ebay\StructType\BuyerType
     */
    public function setShippingAddress(\LewisLarsen\Ebay\StructType\AddressType $shippingAddress = null)
    {
        $this->ShippingAddress = $shippingAddress;
        return $this;
    }
    /**
     * Get BuyerTaxIdentifier value
     * @return \LewisLarsen\Ebay\StructType\TaxIdentifierType[]|null
     */
    public function getBuyerTaxIdentifier()
    {
        return $this->BuyerTaxIdentifier;
    }
    /**
     * This method is responsible for validating the values passed to the setBuyerTaxIdentifier method
     * This method is willingly generated in order to preserve the one-line inline validation within the setBuyerTaxIdentifier method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateBuyerTaxIdentifierForArrayConstraintsFromSetBuyerTaxIdentifier(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $buyerTypeBuyerTaxIdentifierItem) {
            // validation for constraint: itemType
            if (!$buyerTypeBuyerTaxIdentifierItem instanceof \LewisLarsen\Ebay\StructType\TaxIdentifierType) {
                $invalidValues[] = is_object($buyerTypeBuyerTaxIdentifierItem) ? get_class($buyerTypeBuyerTaxIdentifierItem) : sprintf('%s(%s)', gettype($buyerTypeBuyerTaxIdentifierItem), var_export($buyerTypeBuyerTaxIdentifierItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The BuyerTaxIdentifier property can only contain items of type \LewisLarsen\Ebay\StructType\TaxIdentifierType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set BuyerTaxIdentifier value
     * @throws \InvalidArgumentException
     * @param \LewisLarsen\Ebay\StructType\TaxIdentifierType[] $buyerTaxIdentifier
     * @return \LewisLarsen\Ebay\StructType\BuyerType
     */
    public function setBuyerTaxIdentifier(array $buyerTaxIdentifier = array())
    {
        // validation for constraint: array
        if ('' !== ($buyerTaxIdentifierArrayErrorMessage = self::validateBuyerTaxIdentifierForArrayConstraintsFromSetBuyerTaxIdentifier($buyerTaxIdentifier))) {
            throw new \InvalidArgumentException($buyerTaxIdentifierArrayErrorMessage, __LINE__);
        }
        $this->BuyerTaxIdentifier = $buyerTaxIdentifier;
        return $this;
    }
    /**
     * Add item to BuyerTaxIdentifier value
     * @throws \InvalidArgumentException
     * @param \LewisLarsen\Ebay\StructType\TaxIdentifierType $item
     * @return \LewisLarsen\Ebay\StructType\BuyerType
     */
    public function addToBuyerTaxIdentifier(\LewisLarsen\Ebay\StructType\TaxIdentifierType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \LewisLarsen\Ebay\StructType\TaxIdentifierType) {
            throw new \InvalidArgumentException(sprintf('The BuyerTaxIdentifier property can only contain items of type \LewisLarsen\Ebay\StructType\TaxIdentifierType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->BuyerTaxIdentifier[] = $item;
        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 \LewisLarsen\Ebay\StructType\BuyerType
     */
    public function setAny(\DOMDocument $any = null)
    {
        $this->any = ($any instanceof \DOMDocument) && $any->hasChildNodes() ? $any->saveXML($any->childNodes->item(0)) : $any;
        return $this;
    }
}
