示例#1
0
 /**
  * Parse response of the "Get Service" call
  *
  * @param string $responseXml Response XML data
  *
  * @return \XLite\Core\CommonCell
  */
 protected function parseResponseGetService($responseXml)
 {
     $result = new \XLite\Core\CommonCell();
     // Parse XML document
     $xml = \XLite\Module\XC\CanadaPost\Core\XML::getInstance();
     $xmlParsed = $xml->parse($responseXml, $err);
     if (isset($xmlParsed['messages'])) {
         // Collect API error messages (using common method)
         $result->errors = $this->parseResponseErrors($xmlParsed);
     } else {
         if (isset($xmlParsed['service'])) {
             // Collect returned data from "Get Service" call
             $result->service = $xml::convertParsedXmlDocument($xmlParsed['service']);
         }
     }
     return $result;
 }
示例#2
0
 /**
  * Parse response of the "Get Post Office Detail" call
  *
  * @param string $responseXml Response XML data
  *
  * @return \XLite\Core\CommonCell
  */
 protected function parseResponseGetPostOfficeDetail($responseXml)
 {
     $result = new \XLite\Core\CommonCell();
     // Parse XML document
     $xml = \XLite\Module\XC\CanadaPost\Core\XML::getInstance();
     $err = null;
     $xmlParsed = $xml->parse($responseXml, $err);
     if (isset($xmlParsed['messages'])) {
         // Collect API error messages (using common method)
         $result->errors = $this->parseResponseErrors($xmlParsed);
     } else {
         if (isset($xmlParsed['post-office-detail'])) {
             // Collect returned data from "Get Post Office Detail" call
             $result->postOfficeDetail = $xml::convertParsedXmlDocument($xmlParsed['post-office-detail']);
             // Correct hours list
             $hoursList = array();
             foreach ($xmlParsed['post-office-detail']['#']['hours-list'] as $hours) {
                 $_hours = new \XLite\Core\CommonCell();
                 $_hours->day = $hours['#']['day'][0]['#'];
                 $_time = array();
                 foreach ($hours['#']['time'] as $time) {
                     $_time[] = $time['#'];
                 }
                 $_hours->time = $_time;
                 $hoursList[] = $_hours;
             }
             $result->postOfficeDetail->hoursList = $hoursList;
         }
     }
     return $result;
 }