Example #1
0
 /**
  * Confirm a shipment
  *
  * @param bool $verifyPeer
  *
  * @throws \Exception
  *
  * @return array label file format, label image data
  */
 public function ship($verifyPeer = true)
 {
     $request = [];
     $request['Shipment']['Package'] = [];
     $request['Shipment'] = ['Notification' => ['ShipmentNotification' => '', 'ExceptionNotification' => '', 'DeliveryNotification' => '', 'ReceiptNotification' => ''], 'ShipmentLabel' => ['Type' => 'PAPER_LABEL']];
     // TODO - we can only add in one package - ask G what to do here....
     foreach ($this->packages as $package) {
         $request['Shipment']['Package'] = $this->addPackageLineItem($package);
     }
     $this->client = new \SoapClient($this->wsdl['shipping'], ['trace' => 1]);
     $this->client->__setSoapHeaders($this->requestHeader);
     $this->response = $this->client->SubmitShipment($request);
     if ($this->response->SubmitShipmentResult->Result->Code == '1') {
         throw new \Exception(implode("\n", $this->response->Result->Message));
     }
     $label = $this->response->SubmitShipmentResult->Label->Paper;
     // @todo test this is the right format and label is not base64 enoded
     return ['gif', $label];
 }