Exemple #1
0
 /**
  * @return Response|\SimpleUPS\Api\Response|\SimpleXMLElement
  */
 public function sendRequest()
 {
     $xml = parent::sendRequest();
     $responseClass = new \SimpleUPS\AddressValidate\Response($this->getAddress());
     $response = $responseClass->fromXml($xml);
     return $response;
 }
Exemple #2
0
 /**
  * Build the validate address request
  * @internal
  * @return string
  * @throws \SimpleUPS\Api\MissingParameterException
  */
 public function buildXml()
 {
     if ($this->getShipment()->getDestination() == null) {
         throw new MissingParameterException('Shipment destination is missing');
     }
     $dom = new \DomDocument('1.0');
     $dom->formatOutput = $this->getDebug();
     $dom->appendChild($ratingRequest = $dom->createElement('RatingServiceSelectionRequest'));
     $addressRequestLang = $dom->createAttribute('xml:lang');
     $addressRequestLang->value = parent::getXmlLang();
     $ratingRequest->appendChild($request = $dom->createElement('Request'));
     $request->appendChild($transactionReference = $dom->createElement('TransactionReference'));
     $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext()));
     $request->appendChild($dom->createElement('RequestAction', 'Rate'));
     $request->appendChild($dom->createElement('RequestOption', 'Shop'));
     //@todo test with "Rate" as setting to determine difference
     $ratingRequest->appendChild($pickupType = $dom->createElement('PickupType'));
     $pickupType->appendChild($shipmentType = $dom->createElement('Code', $this->getPickupType()));
     if ($this->getRateType() != null) {
         $ratingRequest->appendChild($customerClassification = $dom->createElement('CustomerClassification'));
         $customerClassification->appendChild($dom->createElement('Code', $this->getRateType()));
     }
     // Shipment
     $shipment = $this->getShipment();
     $shipment->setShipper(UPS::getShipper());
     $ratingRequest->appendChild($shipment->toXml($dom));
     $xml = parent::buildAuthenticationXml() . $dom->saveXML();
     return $xml;
 }