src/AddressValidation.php
private function createRequest()
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $avRequest = $xml->appendChild($xml->createElement('AddressValidationRequest'));
        $avRequest->setAttribute('xml:lang', 'en-US');

        $request = $avRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'XAV'));

        if (null !== $this->requestOption) {
            $request->appendChild($xml->createElement('RequestOption', $this->requestOption));
        }

        if (null !== $this->maxSuggestion) {
            $avRequest->appendChild($xml->createElement('MaximumListSize', $this->maxSuggestion));
        }

        if (null !== $this->address) {
            $addressNode = $avRequest->appendChild($xml->createElement('AddressKeyFormat'));

            if ($this->address->getAttentionName()) {
                $addressNode->appendChild($xml->createElement('ConsigneeName', $this->address->getAttentionName()));
            }
            if ($this->address->getBuildingName()) {
                $addressNode->appendChild($xml->createElement('BuildingName', $this->address->getBuildingName()));
            }
            if ($this->address->getAddressLine1()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine1()));
            }
            if ($this->address->getAddressLine2()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine2()));
            }
            if ($this->address->getAddressLine3()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine3()));
            }
            if ($this->address->getStateProvinceCode()) {
                $addressNode->appendChild($xml->createElement('PoliticalDivision1',
                    $this->address->getStateProvinceCode()));
            }
            if ($this->address->getCity()) {
                $addressNode->appendChild($xml->createElement('PoliticalDivision2', $this->address->getCity()));
            }
            if ($this->address->getCountryCode()) {
                $addressNode->appendChild($xml->createElement('CountryCode', $this->address->getCountryCode()));
            }
            if ($this->address->getPostalCode()) {
                $addressNode->appendChild($xml->createElement('PostcodePrimaryLow', $this->address->getPostalCode()));
            }
        }

        return $xml->saveXML();
    }
private function createRequest()
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $avRequest = $xml->appendChild($xml->createElement('AddressValidationRequest'));
        $avRequest->setAttribute('xml:lang', 'en-US');

        $request = $avRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'XAV'));

        if (null !== $this->requestOption) {
            $request->appendChild($xml->createElement('RequestOption', $this->requestOption));
        }

        if (null !== $this->maxSuggestion) {
            $avRequest->appendChild($xml->createElement('MaximumListSize', $this->maxSuggestion));
        }

        if (null !== $this->address) {
            $addressNode = $avRequest->appendChild($xml->createElement('AddressKeyFormat'));

            if ($this->address->getAttentionName()) {
                $addressNode->appendChild($xml->createElement('ConsigneeName', $this->address->getAttentionName()));
            }
            if ($this->address->getBuildingName()) {
                $addressNode->appendChild($xml->createElement('BuildingName', $this->address->getBuildingName()));
            }
            if ($this->address->getAddressLine1()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine1()));
            }
            if ($this->address->getAddressLine2()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine2()));
            }
            if ($this->address->getAddressLine3()) {
                $addressNode->appendChild($xml->createElement('AddressLine', $this->address->getAddressLine3()));
            }
            if ($this->address->getStateProvinceCode()) {
                $addressNode->appendChild($xml->createElement('PoliticalDivision1',
                    $this->address->getStateProvinceCode()));
            }
            if ($this->address->getCity()) {
                $addressNode->appendChild($xml->createElement('PoliticalDivision2', $this->address->getCity()));
            }
            if ($this->address->getCountryCode()) {
                $addressNode->appendChild($xml->createElement('CountryCode', $this->address->getCountryCode()));
            }
            if ($this->address->getPostalCode()) {
                $addressNode->appendChild($xml->createElement('PostcodePrimaryLow', $this->address->getPostalCode()));
            }
        }

        return $xml->saveXML();
    }
Create the XAV request.

@return string