Beispiel #1
0
 /**
  * Shipper information used in rate requests
  * @todo  document how to set this via objects & constants
  * @api
  * @since 1.0
  * @return Shipper
  */
 public static function getShipper()
 {
     if (self::$shipper == null) {
         self::$shipper = new Shipper();
         if (self::$shipperNumber == null && defined('UPS_SHIPPER_NUMBER')) {
             self::$shipper->setNumber(UPS_SHIPPER_NUMBER);
         }
         $shipperAddress = new InstructionalAddress();
         if (defined('UPS_SHIPPER_ADDRESSEE')) {
             $shipperAddress->setAddressee(UPS_SHIPPER_ADDRESSEE);
         }
         if (defined('UPS_SHIPPER_STREET')) {
             $shipperAddress->setStreet(UPS_SHIPPER_STREET);
         }
         if (defined('UPS_SHIPPER_ADDRESS_LINE2')) {
             $shipperAddress->setAddressLine2(UPS_SHIPPER_ADDRESS_LINE2);
         }
         if (defined('UPS_SHIPPER_ADDRESS_LINE3')) {
             $shipperAddress->setAddressLine3(UPS_SHIPPER_ADDRESS_LINE3);
         }
         if (defined('UPS_SHIPPER_CITY')) {
             $shipperAddress->setCity(UPS_SHIPPER_CITY);
         }
         if (defined('UPS_SHIPPER_STATEPROVINCE_CODE')) {
             $shipperAddress->setStateProvinceCode(UPS_SHIPPER_STATEPROVINCE_CODE);
         }
         if (defined('UPS_SHIPPER_POSTAL_CODE')) {
             $shipperAddress->setPostalCode(UPS_SHIPPER_POSTAL_CODE);
         }
         if (defined('UPS_SHIPPER_COUNTRY_CODE')) {
             $shipperAddress->setCountryCode(UPS_SHIPPER_COUNTRY_CODE);
         }
         self::$shipper->setAddress($shipperAddress);
     }
     return self::$shipper;
 }
 /**
  * Create an address from XML.  SimpleXMLElement passed must have immediate children like AddressLine1, City, etc.
  * @internal
  *
  * @param \SimpleXMLElement $xml
  *
  * @return \SimpleUPS\InstructionalAddress
  */
 public static function fromXml(\SimpleXMLElement $xml)
 {
     $address = new InstructionalAddress();
     $address->setIsResponse();
     //@todo Consider alternatives for what to do with Consignee
     if (isset($xml->AddressLine1)) {
         $address->setStreet(trim($xml->AddressLine1));
     }
     if (isset($xml->AddressLine2)) {
         $address->setAddressLine2(trim($xml->AddressLine2));
     }
     if (isset($xml->AddressLine3)) {
         $address->setAddressLine3(trim($xml->AddressLine3));
     }
     if (isset($xml->City)) {
         $address->setCity($xml->City);
     }
     if (isset($xml->StateProvinceCode)) {
         $address->setStateProvinceCode((string) $xml->StateProvinceCode);
     }
     if (isset($xml->PostalCode)) {
         $address->setPostalCode((string) $xml->PostalCode);
     }
     if (isset($xml->CountryCode)) {
         $address->setCountryCode((string) $xml->CountryCode);
     }
     return $address;
 }