DHL-PHP-SDK  v0.4
A wrapper for the DHL-XML-API Version 2
ShipmentOrder.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Petschko\DHL;
4 
16 use stdClass;
17 use Exception;
18 
33  private $sequenceNumber = '1';
34 
40  private $shipmentDetails;
41 
47  private $sender;
48 
54  private $receiver;
55 
63  private $returnReceiver = null;
64 
72  private $exportDocument = null;
73 
81  private $printOnlyIfReceiverIsValid = null;
82 
93  private $labelResponseType = null;
94 
98  public function __destruct() {
99  unset($this->sequenceNumber);
100  unset($this->shipmentDetails);
101  unset($this->sender);
102  unset($this->receiver);
103  unset($this->returnReceiver);
104  unset($this->exportDocument);
105  unset($this->printOnlyIfReceiverIsValid);
106  unset($this->labelResponseType);
107  }
108 
114  public function getSequenceNumber() {
115  return $this->sequenceNumber;
116  }
117 
123  public function setSequenceNumber($sequenceNumber) {
124  $this->sequenceNumber = $sequenceNumber;
125  }
126 
132  public function getShipmentDetails() {
133  return $this->shipmentDetails;
134  }
135 
141  public function setShipmentDetails($shipmentDetails) {
142  $this->shipmentDetails = $shipmentDetails;
143  }
144 
150  public function getSender() {
151  return $this->sender;
152  }
153 
159  public function setSender($sender) {
160  $this->sender = $sender;
161  }
162 
168  public function getReceiver() {
169  return $this->receiver;
170  }
171 
177  public function setReceiver($receiver) {
178  $this->receiver = $receiver;
179  }
180 
188  public function getReturnReceiver() {
189  return $this->returnReceiver;
190  }
191 
199  public function setReturnReceiver($returnReceiver) {
200  $this->returnReceiver = $returnReceiver;
201  }
202 
208  public function getExportDocument() {
209  return $this->exportDocument;
210  }
211 
217  public function setExportDocument($exportDocument) {
218  $this->exportDocument = $exportDocument;
219  }
220 
226  public function getPrintOnlyIfReceiverIsValid() {
227  return $this->printOnlyIfReceiverIsValid;
228  }
229 
237  public function setPrintOnlyIfReceiverIsValid($printOnlyIfReceiverIsValid) {
238  $this->printOnlyIfReceiverIsValid = $printOnlyIfReceiverIsValid;
239  }
240 
246  public function getLabelResponseType() {
247  return $this->labelResponseType;
248  }
249 
255  public function setLabelResponseType($labelResponseType) {
256  $this->labelResponseType = $labelResponseType;
257  }
258 
264  public function getShipmentOrderClass_v2() {
265  $class = new StdClass;
266  $class->sequenceNumber = $this->getSequenceNumber();
267 
268  // Shipment
269  $class->Shipment = new StdClass;
270  $class->Shipment->ShipmentDetails = $this->getShipmentDetails()->getShipmentDetailsClass_v2();
271 
272  // Shipper
273  $class->Shipment->Shipper = $this->getSender()->getClass_v2();
274 
275  // Receiver
276  $class->Shipment->Receiver = $this->getReceiver()->getClass_v2();
277 
278  // Return-Receiver
279  if($this->getReturnReceiver() !== null)
280  $class->Shipment->ReturnReceiver = $this->getReturnReceiver()->getClass_v2();
281 
282  // Export-Document
283  if($this->getExportDocument() !== null) {
284  try {
285  $class->Shipment->ExportDocument = $this->getExportDocument()->getExportDocumentClass_v2();
286  } catch(Exception $e) {
287  trigger_error('[DHL-PHP-SDK]: Exception in method ' . __METHOD__ . ':' . $e->getMessage(), E_USER_WARNING);
288  }
289  }
290 
291  // Other Settings
292  if($this->getPrintOnlyIfReceiverIsValid() !== null) {
293  $class->PrintOnlyIfCodeable = new StdClass;
294  $class->PrintOnlyIfCodeable->active = (int) $this->getPrintOnlyIfReceiverIsValid();
295  }
296  if($this->getLabelResponseType() !== null)
297  $class->labelResponseType = $this->getLabelResponseType();
298 
299  return $class;
300  }
301 }
setPrintOnlyIfReceiverIsValid($printOnlyIfReceiverIsValid)
setShipmentDetails($shipmentDetails)
setLabelResponseType($labelResponseType)
setSequenceNumber($sequenceNumber)
setReturnReceiver($returnReceiver)
setExportDocument($exportDocument)