Exemplo n.º 1
0
 /**
  * Download delivery confirmation certificate
  *
  * @param boolean $flush  Flag - flush changes or not (OPTIONAL)
  *
  * @return boolean
  */
 protected function downloadDeliveryConfirmationCertificate($flush = true)
 {
     $result = false;
     $data = \XLite\Module\XC\CanadaPost\Core\Service\Tracking::getInstance()->callGetDeliveryConfirmCertByPinNumber($this->getRealTrackingPin());
     if (isset($data->deliveryConfirmationCertificate)) {
         $this->saveTrackingFile($data->deliveryConfirmationCertificate, \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking\File::DOCTYPE_DCONG_CERT, $flush);
         $result = true;
     }
     return $result;
 }
Exemplo n.º 2
0
 /** 
  * Get tracking details wrapper
  *
  * @return \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking|null
  */
 public function getTrackingDetails()
 {
     // Get actual tracking details
     $trackingPin = $this->getTrackingPin();
     if (!isset($this->trackingDetails) && !empty($trackingPin)) {
         // Get tracking details from the Canada Post server
         $data = \XLite\Module\XC\CanadaPost\Core\Service\Tracking::getInstance()->callGetTrackingDetailsByPinNumber($trackingPin);
         if (isset($data->trackingDetail)) {
             // Prepare tracking details
             $trackingDetail = $this->prepareTrackingData($data->trackingDetail);
             $details = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking($trackingDetail);
             $details->setShipment($this);
             $this->trackingDetails = $details;
             \XLite\Core\Database::getEM()->persist($details);
             $details->updateExpiry();
             if (isset($trackingDetail['_deliveryOptions'])) {
                 // Add delivery options
                 foreach ($trackingDetail['_deliveryOptions'] as $option_data) {
                     $option = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking\DeliveryOption($option_data);
                     \XLite\Core\Database::getEM()->persist($option);
                     $details->addDeliveryOption($option);
                 }
             }
             if (isset($trackingDetail['_significantEvents'])) {
                 // Add significant  events
                 foreach ($trackingDetail['_significantEvents'] as $event_data) {
                     $event = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking\SignificantEvent($event_data);
                     \XLite\Core\Database::getEM()->persist($event);
                     $details->addSignificantEvent($event);
                 }
             }
             \XLite\Core\Database::getEM()->flush();
             // Download files if they are exists
             $details->downloadFiles();
         }
     }
     return $this->trackingDetails;
 }