Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Add label options to shipment request #11

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Api/Data/Request/Shipment/LabelOptionsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* See LICENSE.md for license details.
*/

namespace Dhl\Express\Api\Data\Request\Shipment;

/**
* LabelOptions Interface.
*
* @api
* @author Daniel Fairbrother <dfairbrother@datto.com>
* @link https://www.datto.com
*/
interface LabelOptionsInterface
{
/**
* Returns the request waybill document option.
*
* @return string
*/
public function getRequestWaybillDocument();
}
41 changes: 41 additions & 0 deletions src/Model/Request/Shipment/LabelOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* See LICENSE.md for license details.
*/

namespace Dhl\Express\Model\Request\Shipment;

use Dhl\Express\Api\Data\Request\Shipment\LabelOptionsInterface;


/**
* LabelOptions Details.
*
* @author Daniel Fairbrother <dfairbrother@datto.com>
* @link https://www.datto.com
*/
class LabelOptions implements LabelOptionsInterface
{
/**
* The service type.
*
* @var string
*/
private $requestWaybillDocument;

/**
* LabelOptions constructor.
*
* @param LabelOptions $requestWaybillDocument
*/
public function __construct(
$requestWaybillDocument
) {
$this->requestWaybillDocument = $requestWaybillDocument;
}

public function getRequestWaybillDocument()
{
return (string) $this->requestWaybillDocument;
}
}
25 changes: 25 additions & 0 deletions src/Model/ShipmentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Dhl\Express\Api\Data\Request\InsuranceInterface;
use Dhl\Express\Api\Data\Request\PackageInterface;
use Dhl\Express\Api\Data\Request\Shipment\DangerousGoods\DryIceInterface;
use Dhl\Express\Api\Data\Request\Shipment\LabelOptionsInterface;
use Dhl\Express\Api\Data\Request\Shipment\ShipmentDetailsInterface;
use Dhl\Express\Api\Data\ShipmentRequestInterface;
use Dhl\Express\Model\Request\Recipient;
Expand Down Expand Up @@ -61,6 +62,11 @@ class ShipmentRequest implements ShipmentRequestInterface
*/
private $dryIce;

/**
* @var null|LabelOptionsInterface
*/
private $labelOptions;

/**
* SoapShipmentRequest constructor.
*
Expand Down Expand Up @@ -124,6 +130,11 @@ public function getDryIce()
return $this->dryIce;
}

public function getLabelOptions()
{
return $this->labelOptions;
}

/**
* Sets the billing account number.
*
Expand Down Expand Up @@ -165,4 +176,18 @@ public function setDryIce(DryIceInterface $dryIce)

return $this;
}

/**
* Sets the label options instance.
*
* @param LabelOptionsInterface $labelOptions The label options instance
*
* @return ShipmentRequest
*/
public function setLabelOptions(LabelOptionsInterface $labelOptions)
{
$this->labelOptions = $labelOptions;

return $this;
}
}
18 changes: 18 additions & 0 deletions src/RequestBuilder/ShipmentRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ public function setInsurance($insuranceValue, $insuranceCurrency)
return $this;
}

public function setLabelOptions($requestWaybillDocument)
{
$this->data['labelOptions'] = [
'requestWaybillDocument' => $requestWaybillDocument
];

return $this;
}

public function setShipper(
$countryCode,
$postalCode,
Expand Down Expand Up @@ -404,6 +413,15 @@ public function build()
$request->setDryIce($dryIce);
}

// build label options
if (!empty($this->data['labelOptions'])) {
$labelOptions = new LabelOptions(
$this->data['labelOptions']['requestWaybillDocument']
);

$request->setLabelOptions($labelOptions);
}

$this->data = [];

return $request;
Expand Down
58 changes: 58 additions & 0 deletions src/Webservice/Soap/Type/ShipmentRequest/LabelOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* See LICENSE.md for license details.
*/
namespace Dhl\Express\Webservice\Soap\Type\ShipmentRequest;

use Dhl\Express\Api\Data\Request\Shipment\LabelOptionsInterface;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\LabelOptions\RequestWaybillDocument;

/**
* The LabelOptions section
*
* @api
* @author Daniel Fairbrother <dfairbrother@datto.com>
* @link https://www.datto.com
*/
class LabelOptions implements LabelOptionsInterface
{
/**
* The request waybill document option.
*
* @var RequestWaybillDocument
*/
private $RequestWaybillDocument;

/**
* Constructor.
*
* @param string $requestWaybillDocument The request waybill document (either Y/N or true/false)
*/
public function __construct($requestWaybillDocument)
{
$this->setRequestWaybillDocument($requestWaybillDocument);
}

/**
* Returns the request waybill document option.
*
* @return RequestWaybillDocument
*/
public function getRequestWaybillDocument()
{
return $this->RequestWaybillDocument;
}

/**
* Sets the delivery option.
*
* @param string $requestWaybillDocument The delivery option
*
* @return self
*/
public function setRequestWaybillDocument($requestWaybillDocument)
{
$this->RequestWaybillDocument = $requestWaybillDocument;
return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* See LICENSE.md for license details.
*/
namespace Dhl\Express\Webservice\Soap\Type\ShipmentRequest\LabelOptions;

use Dhl\Express\Webservice\Soap\Type\Common\YesNo;

/**
* The RequestWaybillDocument field is used to indicate that you would like a copy of the waybill document
* the default in a ShipmentRequest in N
*
* @api
* @author Daniel Fairbrother <dfairbrother@datto.com>
* @link https://www.datto.com
*/
class RequestWaybillDocument extends YesNo
{
}
28 changes: 28 additions & 0 deletions src/Webservice/Soap/Type/ShipmentRequest/RequestedShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class RequestedShipment
*/
private $OnDemandDeliveryOptions;

/**
* @var null|LabelOptions
*/
private $LabelOptions;

/**
* @var Ship
*/
Expand Down Expand Up @@ -296,6 +301,29 @@ public function setOnDemandDeliveryOptions(OnDemandDeliveryOptions $onDemandDeli
return $this;
}

/**
* Returns the on demand delivery options.
*
* @return null|LabelOptions
*/
public function getLabelOptions()
{
return $this->LabelOptions;
}

/**
* Sets the on demand delivery options.
*
* @param LabelOptions $LabelOptions The on demand delivery options
*
* @return self
*/
public function setLabelOptions(LabelOptions $labelOptions)
{
$this->LabelOptions = $labelOptions;
return $this;
}

/**
* Returns the shipper/recipients and optional pickup addresses.
*
Expand Down
32 changes: 32 additions & 0 deletions src/Webservice/Soap/Type/ShipmentRequest/ShipmentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ class ShipmentInfo
*/
private $LabelTemplate;

/**
* The LabelOptions node conveys additional label options. It is an optional field. Currently only
* RequestWaybillDocument is supported and it takes a value of Y/N
*
* @var null|LabelOptions
*/
private $LabelOptions;

/**
* The ArchiveLabelTemplate node conveys the label template used in the operation. It is an optional field.
* This single value corresponds to the label template used to generate the Archive labels. Please check with
Expand Down Expand Up @@ -547,4 +555,28 @@ public function setPaperlessTradeImage($paperlessTradeImage)
$this->PaperlessTradeImage = $paperlessTradeImage;
return $this;
}

/**
* Returns the label options.
*
* @return null|LabelOptions
*/
public function getLabelOptions()
{
return $this->LabelOptions;
}

/**
* Sets the label options.
*
* @param LabelOptions $LabelOptions The label options
*
* @return self
*/
public function setLabelOptions(LabelOptions $labelOptions)
{
$this->LabelOptions = $labelOptions;
return $this;
}

}
10 changes: 10 additions & 0 deletions src/Webservice/Soap/TypeMapper/ShipmentRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\DangerousGoods;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\DangerousGoods\Content;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\InternationalDetail;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\LabelOptions;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages\RequestedPackages;
use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\RequestedShipment;
Expand Down Expand Up @@ -180,6 +181,15 @@ public function map(ShipmentRequestInterface $request)
);
}

// Label options
if ($labelOptions = $request->getLabelOptions()) {
$requestedShipment->getShipmentInfo()->setLabelOptions(
new LabelOptions(
$labelOptions->getRequestWaybillDocument()
)
);
}

return new SoapShipmentRequest($requestedShipment);
}

Expand Down