A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

654 lines
29 KiB

12 years ago
  1. <?php
  2. /**
  3. * This file is a part of Quasi CMS
  4. *@package Quasi
  5. */
  6. if(!defined('QUASICMS') ) die('No Quasi.');
  7. if (!defined("ENDICIAREQUESTBASE.CLASS.PHP")){
  8. define("ENDICIAREQUESTBASE.CLASS.PHP",1);
  9. /**
  10. * Class EndiciaRequest - class for performing shipping requests via Endicia API web services
  11. *
  12. * This class provides an interface to shipping requests. Abstract methods MUST be implemented by
  13. * subclasses, others may be overridden as needed. Subclasses are instantiated by a call to
  14. * ShippingMethod::GetRequest($strRequestType). The primary function of this base class is to associate
  15. * the request with the ShippingMethod
  16. *
  17. * This class also connects to the specified server via the methods provided by extending WebServiceRequest.
  18. *
  19. *@todo
  20. * - implement the other Get methods, only label requests are finished!
  21. * -
  22. *
  23. *@author Erik Winn <erikwinnmail@yahoo.com>
  24. *
  25. * $Id: EndiciaRequest.class.php 517 2009-03-24 17:59:23Z erikwinn $
  26. *@version 0.1
  27. *
  28. *@copyright (C) 2008 by Erik Winn
  29. *@license GPL v.2
  30. This program is free software; you can redistribute it and/or modify
  31. it under the terms of the GNU General Public License as published by
  32. the Free Software Foundation; either version 2 of the License, or
  33. (at your option) any later version.
  34. This program is distributed in the hope that it will be useful,
  35. but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. GNU General Public License for more details.
  38. You should have received a copy of the GNU General Public License
  39. along with this program; if not, write to the Free Software
  40. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  41. *
  42. *@package Quasi
  43. * @subpackage Classes
  44. */
  45. class EndiciaRequest extends ShippingRequest
  46. {
  47. /**
  48. * Assigned by Endicia - identifies the system making the request.
  49. *However, any string (strlen > 0 && < 50) will do as it is not checked
  50. *@var string strRequesterId
  51. */
  52. protected $strRequesterId;
  53. /**
  54. *@var string strRequestId
  55. */
  56. protected $strRequestId;
  57. /**
  58. * Endicia prefers the weight in ounces .. (0000.0)
  59. *@var float fltTotalWeightOz
  60. */
  61. protected $fltTotalWeightOz;
  62. /**
  63. * Type of label to return [Default, CertifiedMail, DestinationConfirm, International]
  64. * "Default" creates based on mail class. Note: if you want PDF images returned you
  65. * must set this to International for international labels.
  66. *@var string strLabelType
  67. */
  68. protected $strLabelType = 'Default';
  69. /**
  70. * The format for the returned image - this is the default for international using
  71. * LabelType "Default" is GIF so this is the best default for us.
  72. * [EPL2, GIF, JPEG, PDF, PNG, ZPLII ]
  73. *@var string strImageFormat
  74. */
  75. protected $strImageFormat = 'GIF';
  76. /**
  77. * [4X6 | 4X5 | 4X4.5 | 6X4 | 7X3 | Dmo30384 | EnvelopeSize10 | Mailer7X5 ]
  78. * The size for the returned image (inches)
  79. *@var string strLabelSize
  80. */
  81. protected $strLabelSize = '4X6';
  82. /**
  83. * Rotation for the returned image [None, Rotate90, Rotate180, Rotate270]
  84. *@var string strImageRotation
  85. */
  86. protected $strImageRotation = 'Rotate180';
  87. /**
  88. * Resolution for the returned image [150 | 203 | 300]
  89. *@var string strImageResolution
  90. */
  91. protected $strImageResolution = '203';
  92. /**
  93. * Endicia uses its own version of the USPS Service Types ..
  94. * For Domestic:
  95. * [Express, First, LibraryMail, MediaMail,ParcelPost, Priority]
  96. * For International:
  97. * [ExpressMailInternational, FirstClassMailInternational, PriorityMailInternational]
  98. *@var string strMailClass
  99. */
  100. protected $strMailClass;
  101. /**
  102. * Specifies nondelivery options for international labels and customs forms
  103. *@var string strNonDeliveryOption
  104. */
  105. protected $strNonDeliveryOption;
  106. /**
  107. * Unique identifier for the end user printing the label
  108. *@var string strPartnerCustomerId
  109. */
  110. protected $strPartnerCustomerId;
  111. /**
  112. * Unique identifier for the transaction (eg. invoice or order id)
  113. *@var string strPartnerTransactionId
  114. */
  115. protected $strPartnerTransactionId;
  116. /**
  117. * Name of the sender, required for international shipping and must contain
  118. * at least two words. This defaults to STORE_OWNER
  119. *@var string strFromName
  120. */
  121. protected $strFromName;
  122. /**
  123. * Name of the sender company
  124. * at least two words. This defaults to STORE_NAME
  125. *@var string strFromCompany
  126. */
  127. protected $strFromCompany;
  128. /**
  129. * Name of the sender city
  130. * at least two words. This defaults to STORE_CITY
  131. *@var string strFromCity
  132. */
  133. protected $strFromCity;
  134. /**
  135. * Line one of return address ..
  136. *@var string strReturnAddress1
  137. */
  138. protected $strReturnAddress1;
  139. /**
  140. * Line two of return address ..
  141. *@var string strReturnAddress2
  142. */
  143. protected $strReturnAddress2;
  144. /**
  145. * The total value of the shipment
  146. *@var float fltTotalValue
  147. */
  148. protected $fltTotalValue;
  149. /**
  150. * EndiciaRequest Constructor - sets defaults for this request method ..
  151. *
  152. * @param ShippingMethod objShippingMethod - the method to be used for the request
  153. */
  154. public function __construct(ShippingMethod $objShippingMethod)
  155. {
  156. parent::__construct($objShippingMethod);
  157. if($objShippingMethod->TestMode)
  158. {
  159. $this->strRemoteAccountId = ENDICIA_TESTACCOUNT_ID;
  160. $this->strRemotePassword = ENDICIA_TESTPASSWORD;
  161. $this->strRequestId = ENDICIA_TESTREQUEST_ID;
  162. $this->strRequesterId = ENDICIA_TESTREQUESTER_ID;
  163. $this->strRemoteDomainName = ENDICIA_TESTDOMAIN;
  164. } else {
  165. $this->strRemoteAccountId = ENDICIA_ACCOUNT_ID;
  166. $this->strRemotePassword = ENDICIA_PASSWORD;
  167. $this->strRequestId = ENDICIA_REQUEST_ID;
  168. $this->strRequesterId = ENDICIA_REQUESTER_ID;
  169. $this->strRemoteDomainName = ENDICIA_DOMAIN;
  170. }
  171. $this->strRemoteCgiUrl = '/LabelService/EwsLabelService.asmx/';
  172. //combine weight as endicia accepts only ounces
  173. $this->fltTotalWeightOz = round( ($objShippingMethod->Ounces + ($objShippingMethod->Pounds * 16)), 2);
  174. //and the minimum is one.
  175. if($this->fltTotalWeightOz < 1)
  176. $this->fltTotalWeightOz = 1;
  177. $this->fltTotalValue = $objShippingMethod->Order->ProductTotalCharged;
  178. $this->strPartnerTransactionId = 'BPCB' . $objShippingMethod->Order->Id;
  179. $this->strPartnerCustomerId = STORE_NAME;
  180. $this->strFromCompany = STORE_NAME;
  181. $this->strReturnAddress1 = STORE_ADDRESS1;
  182. $this->strReturnAddress2 = STORE_ADDRESS2;
  183. $this->strFromCity = STORE_CITY;
  184. $this->strFromName = STORE_OWNER;
  185. $aryFromName = explode( ' ', $this->strFromName );
  186. if(count( $aryFromName ) < 2 )
  187. throw new Exception('EndiciaRequest: FromName (STORE_OWNER) must have at least 2 words!');
  188. if($this->objShippingMethod->Order->IsInternational)
  189. {
  190. $this->strLabelType = 'International';
  191. // $this->strImageFormat = 'GIF';
  192. }
  193. //translate USPS service types - ugly as these change .. careful.
  194. ///@todo - fill out the rest here .. library, parcel, etc .. no time ..
  195. if( 'FIRST CLASS' == $objShippingMethod->ServiceType )
  196. $this->strMailClass = 'First';
  197. elseif( 'PRIORITY' == $objShippingMethod->ServiceType )
  198. $this->strMailClass = 'Priority';
  199. elseif( 'EXPRESS' == $objShippingMethod->ServiceType )
  200. $this->strMailClass = 'Express';
  201. elseif( 'Express Mail International' == $objShippingMethod->ServiceType )
  202. $this->strMailClass = 'ExpressMailInternational';
  203. elseif( 'First Class Mail International' == $objShippingMethod->ServiceType )
  204. $this->strMailClass = 'FirstClassMailInternational';
  205. elseif( 'Priority Mail International' == $objShippingMethod->ServiceType )
  206. $this->strMailClass = 'PriorityMailInternational';
  207. else // assume we are using the Endicia ShippingMethod natively
  208. $this->strMailClass = $objShippingMethod->ServiceType;
  209. }
  210. /**
  211. * Returns a shipping label image suitable for printing
  212. *@return image object containing the image code
  213. */
  214. public function GetLabel()
  215. {
  216. $this->createRequest(ShippingRequestType::Label, WebRequestType::POST);
  217. $this->submitRequest();
  218. return $this->objShippingLabelImage;
  219. }
  220. /**
  221. * Creates a label image request
  222. */
  223. protected function createLabelRequest()
  224. {
  225. $this->strApiName = 'GetPostageLabelXML';
  226. if('Express Mail International' == $this->ServiceType
  227. || 'Priority Mail International' == $this->ServiceType )
  228. $this->strImageRotation ='Rotate90';
  229. $strXML = 'labelRequestXML=';
  230. $strXML .= sprintf('<LabelRequest Test="%s" LabelType="%s" LabelSize="%s" LabelFormat="%s" ImageRotation="%s" ImageResolution="%s">',
  231. $this->Test,
  232. $this->strLabelType,
  233. $this->strLabelSize,
  234. $this->strImageFormat,
  235. $this->strImageRotation,
  236. $this->strImageResolution
  237. );
  238. $strXML .= '<RequesterID>' . $this->strRequesterId . '</RequesterID>';
  239. $strXML .= '<AccountID>' . $this->RemoteAccountId . '</AccountID>';
  240. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  241. $strXML .= '<MailClass>' . $this->strMailClass . '</MailClass>';
  242. $strXML .= '<WeightOz>' . $this->fltTotalWeightOz. '</WeightOz>';
  243. if($this->fltTotalValue)
  244. $strXML .= '<Value>' . $this->fltTotalValue . '</Value>';
  245. $strXML .= '<OriginCountry>' . $this->OriginCountry . '</OriginCountry>';
  246. ///@todo -- make this smarter ..
  247. $strXML .= '<Description>Consumer Goods</Description>';
  248. $strXML .= '<PartnerCustomerID>' . $this->strPartnerCustomerId . '</PartnerCustomerID>';
  249. $strXML .= '<PartnerTransactionID>' . $this->strPartnerTransactionId . '</PartnerTransactionID>';
  250. $strXML .= $this->formatAddress($this->objShippingMethod->Order);
  251. $strXML .= '<FromCompany>' . $this->strFromCompany . '</FromCompany>';
  252. $strXML .= '<FromName>' . $this->strFromName . '</FromName>';
  253. $strXML .= '<ReturnAddress1>' . $this->strReturnAddress1 . '</ReturnAddress1>';
  254. $strXML .= '<ReturnAddress2>' . $this->strReturnAddress2 . '</ReturnAddress2>';
  255. $strXML .= '<FromCity>' . $this->strFromCity . '</FromCity>';
  256. $strXML .= '<FromState>' . $this->OriginStateCode . '</FromState>';
  257. $strXML .= '<FromPostalCode>' . substr($this->OriginZip, 0, 5) . '</FromPostalCode>';
  258. $strPhone = preg_replace( '/[\- ]/', '', STORE_PHONE );
  259. $strXML .= '<FromPhone>' . $strPhone . '</FromPhone>';
  260. if($this->objShippingMethod->Order->IsInternational)
  261. {
  262. $strXML .= '<FromCountry>' . $this->OriginCountry . '</FromCountry>';
  263. $this->initCustomsInformationArray();
  264. foreach($this->aryCustomsInformation as $intIndex => $objInfo)
  265. {
  266. $intIdx = $intIndex + 1;
  267. $strXML .= '<CustomsDescription' . $intIdx . '>' . $objInfo->Description. '</CustomsDescription' . $intIdx . '>';
  268. $strXML .= '<CustomsQuantity' . $intIdx . '>' . $objInfo->Quantity . '</CustomsQuantity' . $intIdx . '>';
  269. $strXML .= '<CustomsWeight' . $intIdx . '>' . ceil($objInfo->Weight) . '</CustomsWeight' . $intIdx . '>';
  270. $strXML .= '<CustomsValue' . $intIdx . '>' . $objInfo->Value . '</CustomsValue' . $intIdx . '>';
  271. $strXML .= '<CustomsCountry' . $intIdx . '>' . $objInfo->OriginCountry . '</CustomsCountry' . $intIdx . '>';
  272. }
  273. }
  274. $strXML .= '</LabelRequest>';
  275. $this->strRequest = $strXML;
  276. }
  277. /**
  278. * Creates an account status request
  279. */
  280. protected function createAccountStatusRequest()
  281. {
  282. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  283. ShippingRequestType::ToString($this->ShippingRequestType)) );
  284. $this->strApiName = 'GetAccountStatusXML';
  285. $strXML = 'accountStatusRequestXML=';
  286. $strXML .= '<AccountStatusRequest Test="' . $this->Test . '">';
  287. $strXML .= '<RequesterID>' . $this->RequesterId . '</RequesterID>';
  288. $strXML .= '<RequestID>' . $this->RequestId . '</RequestID>';
  289. $strXML .= '<CertifiedIntermediary>';
  290. $strXML .= '<AccountID>' . $this->RemoteAccountId. '</AccountID>';
  291. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  292. $strXML .= '</CertifiedIntermediary>';
  293. $strXML .= '</AccountStatusRequest>';
  294. $this->strRequest = $strXML;
  295. }
  296. /**
  297. * Creates a request submitting an account credit payment
  298. */
  299. protected function createCreditAccountRequest($fltAmount)
  300. {
  301. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s UNTESTED DO NOT USE! ',
  302. ShippingRequestType::ToString($this->ShippingRequestType)) );
  303. $this->strApiName = 'BuyPostageXML';
  304. if( ! is_numeric($fltAmount) || $fltAmount < 10 || $fltAmount >= 100000)
  305. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s - Param: %s ' .
  306. 'Postage amount must be a number between 10 and 99999.99.',
  307. ShippingRequestType::ToString($this->ShippingRequestType),
  308. $fltAmount ));
  309. $strXML = 'recreditRequestXML=';
  310. $strXML .= '<RecreditRequest Test="' . $this->Test . '">';
  311. $strXML .= '<RequesterID>' . $this->RequesterId . '</RequesterID>';
  312. $strXML .= '<RequestID>' . $this->RequestId . '</RequestID>';
  313. $strXML .= '<CertifiedIntermediary>';
  314. $strXML .= '<AccountID>' . $this->RemoteAccountId . '</AccountID>';
  315. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  316. $strXML .= '</CertifiedIntermediary>';
  317. $strXML .= '<RecreditAmount>' . round($fltAmount, 2) . '</RecreditAmount>';
  318. $strXML .= '</RecreditRequest>';
  319. $this->strRequest = $strXML;
  320. }
  321. //Response handlers
  322. /**
  323. * Handles a rate request
  324. */
  325. protected function handleRateResponse()
  326. {
  327. $objDomDoc = $this->getDomDocument('RateRequestResponse');
  328. if($objDomDoc)
  329. {
  330. $strErrorMessage = $this->requestErrors($objDomDoc);
  331. if($strErrorMessage)
  332. {
  333. $this->blnHasErrors = true;
  334. $this->strErrors = $strErrorMessage;
  335. $this->fltRate = null;
  336. }
  337. else
  338. $this->fltRate = $objDomDoc->getElementsByTagName('NetCharge')->item(0)->nodeValue;
  339. } else {
  340. // die($this->strResponse);
  341. $this->HasErrors = true;
  342. $this->ErrorMessages = 'Unknown Endicia error ..';
  343. $this->fltRate = 0;
  344. }
  345. }
  346. /**
  347. * Handles a label image request response
  348. * This function handles the entire label request which includes extracting the tracking number
  349. * and other information from the response XML.
  350. */
  351. protected function handleLabelResponse()
  352. {
  353. $objDomDoc = $this->getDomDocument('LabelRequestResponse');
  354. if($objDomDoc)
  355. {
  356. $strErrorMessage = $this->requestErrors($objDomDoc);
  357. if($strErrorMessage)
  358. {
  359. $this->blnHasErrors = true;
  360. $this->strErrors = $strErrorMessage;
  361. $this->objShippingLabelImage = null;
  362. } else {
  363. $objImageNodeList = $objDomDoc->getElementsByTagName('Base64LabelImage');
  364. //if nothing, try the other tag - International is usually in there ..
  365. if($objImageNodeList->length <= 0)
  366. $objImageNodeList = $objDomDoc->getElementsByTagName('Image');
  367. //still nothing? ruh roh ..
  368. if($objImageNodeList->length <= 0)
  369. throw new Exception('EndiciaRequest: No label image returned for Order ' . $this->Order->Id);
  370. $this->objShippingLabelImage = base64_decode( $objImageNodeList->item(0)->nodeValue );
  371. if(!$this->objShippingLabelImage)
  372. throw new Exception('EndiciaRequest: Empty image!');
  373. if($this->Order->IsInternational)
  374. {//get customs forms if available ..
  375. if($objImageNodeList->length > 1)
  376. for($intIdx = 1; $intIdx < $objImageNodeList->length; ++$intIdx)
  377. $this->aryCustomsFormImages[] = base64_decode($objImageNodeList->item($intIdx)->nodeValue);
  378. }
  379. //try to save the tracking number ..
  380. $objTrackingNumberNodeList = $objDomDoc->getElementsByTagName('TrackingNumber');
  381. if($objTrackingNumberNodeList->length > 0)
  382. {
  383. $strTrackingNumber = $objTrackingNumberNodeList->item(0)->nodeValue;
  384. if(!empty($strTrackingNumber))
  385. {
  386. if(! TrackingNumber::LoadByOrderIdNumber($this->objShippingMethod->OrderId, $strTrackingNumber ))
  387. {
  388. $objTrackingNumber = new TrackingNumber();
  389. $objTrackingNumber->OrderId = $this->objShippingMethod->OrderId;
  390. $objTrackingNumber->Number = $strTrackingNumber;
  391. $objTrackingNumber->Save();
  392. }
  393. }
  394. }
  395. $objFinalPriceNodeList = $objDomDoc->getElementsByTagName('FinalPostage');
  396. if($objFinalPriceNodeList->length > 0)
  397. {
  398. $strFinalPrice = $objFinalPriceNodeList->item(0)->nodeValue;
  399. if(!empty($strFinalPrice))
  400. {
  401. $this->objShippingMethod->Order->ShippingCost = $strFinalPrice;
  402. $this->objShippingMethod->Order->Save(false,true);
  403. }
  404. }
  405. }
  406. } else {
  407. // die($this->strResponse);
  408. $this->blnHasErrors = true;
  409. $this->strErrors = 'Unknown Endicia error ..Request:' . $this->strRequest . ' Response:' . $this->strResponse;
  410. $this->objShippingLabelImage = 0;
  411. }
  412. }
  413. /**
  414. * Utility function to format the address for a label or rate request, creates a
  415. * string containing the XML tags for the address
  416. *@return string
  417. */
  418. private function formatAddress($objOrder)
  419. {
  420. $strToReturn = '';
  421. $intAddressLine = 1;
  422. $strToReturn .= '<ToName>' . $objOrder->FullShippingName . '</ToName>';
  423. if($objOrder->ShippingCompany)
  424. $strToReturn .= '<ToCompany>' . $objOrder->ShippingCompany . '</ToCompany>';
  425. //Endicia allows 4 Address lines so we have to be clever here ..
  426. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingStreet1 . '</ToAddress' . $intAddressLine . '>';
  427. ++$intAddressLine;
  428. if($objOrder->ShippingStreet2)
  429. {//line 2
  430. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingStreet2 . '</ToAddress' . $intAddressLine . '>';
  431. ++$intAddressLine;
  432. }
  433. if($objOrder->ShippingSuburb)
  434. {//line 2 or 3 ..
  435. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingSuburb . '</ToAddress' . $intAddressLine . '>';
  436. ++$intAddressLine;
  437. }
  438. //line 2, 3 or 4 ..
  439. if($objOrder->ShippingCounty)
  440. {//line
  441. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingCounty . '</ToAddress' . $intAddressLine . '>';
  442. ++$intAddressLine;
  443. }
  444. $strToReturn .= '<ToCity>' . $objOrder->ShippingCity . '</ToCity>';
  445. if( ZoneType::NoZone != $this->objShippingMethod->DestinationStateId )
  446. $strToReturn .= '<ToState>' . $this->objShippingMethod->DestinationStateCode . '</ToState>';
  447. //truncate zip else endicia complains ..
  448. $strToReturn .= '<ToPostalCode>' . substr( trim($this->objShippingMethod->DestinationZip), 0, 5) . '</ToPostalCode>';
  449. $strToReturn .= '<ToCountry>' . $this->objShippingMethod->DestinationCountry . '</ToCountry>';
  450. $strPhoneNumber = trim($objOrder->Account->Person->PhoneNumber);
  451. if( !empty($strPhoneNumber) && 'N/A' != $strPhoneNumber)
  452. $strPhoneNumber = preg_replace('/[^\d]/', '', $strPhoneNumber);
  453. else
  454. $strPhoneNumber = '8091236354';
  455. $strToReturn .= '<ToPhone>' . $strPhoneNumber . '</ToPhone>';
  456. return $strToReturn;
  457. }
  458. /**
  459. * Utility function to check for request errors - returns either a string containing
  460. * server error messages or false if there were none.
  461. *@param DOMDocument objDomDoc - the server response ..
  462. *@return string | boolean error messages or false if request succeeded.
  463. */
  464. private function requestErrors($objDomDoc)
  465. {
  466. $mixToReturn = false;
  467. $nodeListStatus = $objDomDoc->getElementsByTagName('Status');
  468. //Status is zero on success ..
  469. if($nodeListStatus->item(0)->nodeValue > 0)
  470. {
  471. $nodeListErrors = $objDomDoc->getElementsByTagName('ErrorMessage');
  472. $this->blnHasErrors = true;
  473. $mixToReturn = 'Request: ' . $this->strRequest;
  474. if( $nodeListErrors->length)
  475. $mixToReturn .= ' Message: ' . $nodeListErrors->item(0)->nodeValue;
  476. else
  477. $mixToReturn .= ' ... Endicia had no comment. ';
  478. }
  479. return $mixToReturn;
  480. }
  481. ///Gettors
  482. public function __get($strName)
  483. {
  484. switch ($strName)
  485. {
  486. case 'Test':
  487. return $this->TestMode ? 'YES' : 'NO';
  488. case 'Carrier':
  489. return $this->objShippingMethod->Carrier ;
  490. default:
  491. try {
  492. return parent::__get($strName);
  493. } catch (QCallerException $objExc) {
  494. $objExc->IncrementOffset();
  495. throw $objExc;
  496. }
  497. }
  498. }
  499. ///Settors
  500. public function __set($strName, $mixValue)
  501. {
  502. switch ($strName)
  503. {
  504. case 'FromName':
  505. try {
  506. return ($this->strFromDate = QType::Cast($mixValue, QType::String));
  507. } catch (QInvalidCastException $objExc) {
  508. $objExc->IncrementOffset();
  509. throw $objExc;
  510. }
  511. case 'Container':
  512. return ($this->objShippingMethod->Container = $mixValue);
  513. default:
  514. try {
  515. return (parent::__set($strName, $mixValue));
  516. } catch (QCallerException $objExc) {
  517. $objExc->IncrementOffset();
  518. throw $objExc;
  519. }
  520. }
  521. }
  522. /*************************************************************************************/
  523. ///@todo - implement the other Get methods ..:
  524. /**
  525. * Returns a rate for this method to the order address
  526. *@return float containing the rate for the order address
  527. */
  528. public function GetRate()
  529. {
  530. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  531. ShippingRequestType::ToString($this->ShippingRequestType)) );
  532. }
  533. /**
  534. * Returns an account status report
  535. *@return string containing the status report
  536. */
  537. public function GetAccountStatus()
  538. {
  539. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  540. ShippingRequestType::ToString($this->ShippingRequestType)) );
  541. }
  542. /**
  543. * Returns whether this method is available for the order address
  544. *@return boolean true if method is available
  545. */
  546. public function GetAvailability()
  547. {
  548. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  549. ShippingRequestType::ToString($this->ShippingRequestType)) );
  550. }
  551. /**
  552. * Submits an account credit payment
  553. *@return boolean true on success
  554. */
  555. public function CreditAccount()
  556. {
  557. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  558. ShippingRequestType::ToString($this->ShippingRequestType)) );
  559. }
  560. //Request string creators
  561. /**
  562. * Creates a rate request
  563. */
  564. protected function createRateRequest()
  565. {
  566. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  567. ShippingRequestType::ToString($this->ShippingRequestType)) );
  568. }
  569. /**
  570. * Creates a method available request
  571. */
  572. protected function createAvailabilityRequest()
  573. {
  574. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  575. ShippingRequestType::ToString($this->ShippingRequestType)) );
  576. }
  577. /**
  578. * Handles an account status request
  579. */
  580. protected function handleAccountStatusResponse()
  581. {
  582. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  583. ShippingRequestType::ToString($this->ShippingRequestType)) );
  584. }
  585. /**
  586. * Handles a request submitting an account credit payment
  587. */
  588. protected function handleCreditAccountResponse()
  589. {
  590. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  591. ShippingRequestType::ToString($this->ShippingRequestType)) );
  592. }
  593. /**
  594. * Handles a method available request
  595. */
  596. protected function handleAvailabilityResponse()
  597. {
  598. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  599. ShippingRequestType::ToString($this->ShippingRequestType)) );
  600. }
  601. /*************************************************************************************/
  602. }//end class
  603. }//end define
  604. ?>