コード例 #1
0
 public function testCreateRequest()
 {
     $xavRequest = new \Ups\AddressValidation();
     $xavRequest->setRequest($request = new RequestMock());
     $address = new \Ups\Entity\Address();
     $address->setAttentionName('Test Test');
     $address->setBuildingName('Building 1');
     $address->setAddressLine1('Times Square 1');
     $address->setAddressLine2('First Corner');
     $address->setAddressLine3('Second Corner');
     $address->setStateProvinceCode('NY');
     $address->setCity('New York');
     $address->setCountryCode('US');
     $address->setPostalCode('50000');
     try {
         // Get data
         $response = $xavRequest->validate($address);
     } catch (Exception $e) {
     }
     $this->assertEquals($request->getRequestXml(), $request->getExpectedRequestXml('/AddressValidation/Request1.xml'));
 }
コード例 #2
0
 /**
  * Build a UPS Cpmpatible Address Object from a Model
  * @param Contao\Model
  * @return stdClass
  */
 protected static function buildAddress(Model $objModel)
 {
     $Address = new Ups_Address();
     $arrSubdivision = explode('-', $objModel->subdivision);
     $Address->setAddressLine1($objModel->street_1);
     $Address->setAddressLine2($objModel->street_2);
     $Address->setAddressLine3($objModel->street_3);
     $Address->setCity($objModel->city);
     $Address->setStateProvinceCode(strtoupper($arrSubdivision[1]));
     $Address->setPostalCode($objModel->postal);
     $Address->setCountryCode(strtoupper($arrSubdivision[0]));
     return $Address;
 }