From e2ee481392fa253ca42420e6e7257f59f2d780f1 Mon Sep 17 00:00:00 2001 From: "tomaz.jakomin" Date: Wed, 5 Feb 2020 09:41:35 +0100 Subject: [PATCH 1/3] DHL-66 Updated TrackingResponseMapper.php and ClassMap.php to properly map response class. Added missing PiecesEnabled.php option class. Reordered some imports. --- src/Api/Data/RateRequestInterface.php | 6 +++--- src/Api/RateRequestBuilderInterface.php | 2 +- src/RequestBuilder/RateRequestBuilder.php | 2 +- src/RequestBuilder/ShipmentDeleteRequestBuilder.php | 7 ++++--- src/Webservice/Soap/ClassMap.php | 1 + .../ShipmentRequest/Packages/RequestedPackages.php | 2 +- .../Soap/Type/ShipmentRequest/Ship/Address.php | 2 +- .../Soap/Type/ShipmentRequest/Ship/Contact.php | 2 +- src/Webservice/Soap/Type/Tracking/PiecesEnabled.php | 12 ++++++++++++ src/Webservice/Soap/Type/Tracking/ShipmentInfo.php | 4 ++-- .../Soap/TypeMapper/ShipmentDeleteResponseMapper.php | 1 - .../Soap/TypeMapper/TrackingResponseMapper.php | 10 +++++++--- 12 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 src/Webservice/Soap/Type/Tracking/PiecesEnabled.php diff --git a/src/Api/Data/RateRequestInterface.php b/src/Api/Data/RateRequestInterface.php index 749432b..e082c78 100644 --- a/src/Api/Data/RateRequestInterface.php +++ b/src/Api/Data/RateRequestInterface.php @@ -4,11 +4,11 @@ */ namespace Dhl\Express\Api\Data; -use Dhl\Express\Api\Data\Request\Rate\ShipperAddressInterface; +use Dhl\Express\Api\Data\Request\InsuranceInterface; +use Dhl\Express\Api\Data\Request\Rate\PackageInterface; use Dhl\Express\Api\Data\Request\Rate\RecipientAddressInterface; use Dhl\Express\Api\Data\Request\Rate\ShipmentDetailsInterface; -use Dhl\Express\Api\Data\Request\Rate\PackageInterface; -use Dhl\Express\Api\Data\Request\InsuranceInterface; +use Dhl\Express\Api\Data\Request\Rate\ShipperAddressInterface; /** * Rate Request Interface. diff --git a/src/Api/RateRequestBuilderInterface.php b/src/Api/RateRequestBuilderInterface.php index 6e784b8..646c943 100644 --- a/src/Api/RateRequestBuilderInterface.php +++ b/src/Api/RateRequestBuilderInterface.php @@ -5,8 +5,8 @@ namespace Dhl\Express\Api; -use Dhl\Express\Api\Data\RateRequestInterface; use InvalidArgumentException; +use Dhl\Express\Api\Data\RateRequestInterface; /** * Rate Request Builder. diff --git a/src/RequestBuilder/RateRequestBuilder.php b/src/RequestBuilder/RateRequestBuilder.php index 9c780b3..227a9e9 100644 --- a/src/RequestBuilder/RateRequestBuilder.php +++ b/src/RequestBuilder/RateRequestBuilder.php @@ -5,6 +5,7 @@ namespace Dhl\Express\RequestBuilder; +use InvalidArgumentException; use Dhl\Express\Api\RateRequestBuilderInterface; use Dhl\Express\Model\RateRequest; use Dhl\Express\Model\Request\Insurance; @@ -12,7 +13,6 @@ use Dhl\Express\Model\Request\Rate\RecipientAddress; use Dhl\Express\Model\Request\Rate\ShipmentDetails; use Dhl\Express\Model\Request\Rate\ShipperAddress; -use InvalidArgumentException; /** * Rate Request Builder. diff --git a/src/RequestBuilder/ShipmentDeleteRequestBuilder.php b/src/RequestBuilder/ShipmentDeleteRequestBuilder.php index 2650c19..fe4c32b 100644 --- a/src/RequestBuilder/ShipmentDeleteRequestBuilder.php +++ b/src/RequestBuilder/ShipmentDeleteRequestBuilder.php @@ -4,6 +4,7 @@ */ namespace Dhl\Express\RequestBuilder; +use DateTime; use Dhl\Express\Api\ShipmentDeleteRequestBuilderInterface; use Dhl\Express\Model\ShipmentDeleteRequest; @@ -22,7 +23,7 @@ class ShipmentDeleteRequestBuilder implements ShipmentDeleteRequestBuilderInterf */ private $data = []; - public function setPickupDate(\DateTime $pickupDate) + public function setPickupDate(DateTime $pickupDate) { $this->data['pickupDate'] = $pickupDate; return $this; @@ -62,8 +63,8 @@ public function build() $this->data['requesterName'] ); - if (isset($this->data['reason'])) { - $request->setReason($this->data['reason']); + if (isset($this->data['reasonCode'])) { + $request->setReason($this->data['reasonCode']); } $this->data = []; diff --git a/src/Webservice/Soap/ClassMap.php b/src/Webservice/Soap/ClassMap.php index c1f96c8..c8f616d 100644 --- a/src/Webservice/Soap/ClassMap.php +++ b/src/Webservice/Soap/ClassMap.php @@ -42,6 +42,7 @@ public static function get() // trackShipmentRequest 'ServiceHeader' => Type\Tracking\ServiceHeader::class, + 'ResponseServiceHeader' => Type\Tracking\ServiceHeader::class, 'TrackingResponse' => Type\Tracking\TrackingResponse::class, 'Response' => Type\Tracking\Response::class, 'AWBInfo' => Type\Tracking\AWBInfo::class, diff --git a/src/Webservice/Soap/Type/ShipmentRequest/Packages/RequestedPackages.php b/src/Webservice/Soap/Type/ShipmentRequest/Packages/RequestedPackages.php index 0e222fc..30e263d 100644 --- a/src/Webservice/Soap/Type/ShipmentRequest/Packages/RequestedPackages.php +++ b/src/Webservice/Soap/Type/ShipmentRequest/Packages/RequestedPackages.php @@ -4,8 +4,8 @@ */ namespace Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages; -use Dhl\Express\Webservice\Soap\Type\Common\Packages\RequestedPackages\Dimensions; use Dhl\Express\Webservice\Soap\Type\Common\Money; +use Dhl\Express\Webservice\Soap\Type\Common\Packages\RequestedPackages\Dimensions; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages\RequestedPackages\CustomerReferences; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages\RequestedPackages\PackageContentDescription; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Packages\RequestedPackages\PieceIdentificationNumber; diff --git a/src/Webservice/Soap/Type/ShipmentRequest/Ship/Address.php b/src/Webservice/Soap/Type/ShipmentRequest/Ship/Address.php index 1bc3994..6d05a0d 100644 --- a/src/Webservice/Soap/Type/ShipmentRequest/Ship/Address.php +++ b/src/Webservice/Soap/Type/ShipmentRequest/Ship/Address.php @@ -4,7 +4,7 @@ */ namespace Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship; -use \Dhl\Express\Webservice\Soap\Type\Common\Ship\Address as CommonAddress; +use Dhl\Express\Webservice\Soap\Type\Common\Ship\Address as CommonAddress; /** * An ship address. diff --git a/src/Webservice/Soap/Type/ShipmentRequest/Ship/Contact.php b/src/Webservice/Soap/Type/ShipmentRequest/Ship/Contact.php index e4bccd6..eae2aac 100644 --- a/src/Webservice/Soap/Type/ShipmentRequest/Ship/Contact.php +++ b/src/Webservice/Soap/Type/ShipmentRequest/Ship/Contact.php @@ -4,10 +4,10 @@ */ namespace Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship; -use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\PersonName; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\CompanyName; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\EmailAddress; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\MobilePhoneNumber; +use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\PersonName; use Dhl\Express\Webservice\Soap\Type\ShipmentRequest\Ship\Contact\PhoneNumber; /** diff --git a/src/Webservice/Soap/Type/Tracking/PiecesEnabled.php b/src/Webservice/Soap/Type/Tracking/PiecesEnabled.php new file mode 100644 index 0000000..fa65c26 --- /dev/null +++ b/src/Webservice/Soap/Type/Tracking/PiecesEnabled.php @@ -0,0 +1,12 @@ +getResponse()->getServiceHeader()->getMessageTime()); if (\is_bool($time)) { throw new \InvalidArgumentException( @@ -93,19 +92,24 @@ public function map(SoapTrackingResponse $soapTrackingResponse) return new TrackingResponse( new Message( $time, - $soapResponseContent->getResponse()->getServiceHeader()->getMessageReference() + $soapResponseContent->getResponse()->getServiceHeader()->getMessageTime() ), $trackingInfos ); } /** - * @param ShipmentEventCollection $shipmentEvents + * @param null|ShipmentEventCollection $shipmentEvents * @return ShipmentEventInterface[] */ private function convertTrackEventItems(ShipmentEventCollection $shipmentEvents) { $events = []; + + if (!$shipmentEvents) { + return $events; + } + foreach ($shipmentEvents->getArrayOfShipmentEventItem() as $shipmentEvent) { $events[] = new TrackingInfo\ShipmentEvent( $shipmentEvent->getDate(), From cee8df8636c3b743caca358c67ee151c1c219b84 Mon Sep 17 00:00:00 2001 From: "tomaz.jakomin" Date: Wed, 5 Feb 2020 14:43:05 +0100 Subject: [PATCH 2/3] DHL-66 Update to correct method --- src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php b/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php index 6144f37..05debf3 100644 --- a/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php +++ b/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php @@ -92,7 +92,7 @@ public function map(SoapTrackingResponse $soapTrackingResponse) return new TrackingResponse( new Message( $time, - $soapResponseContent->getResponse()->getServiceHeader()->getMessageTime() + $soapResponseContent->getResponse()->getServiceHeader()->getMessageReference() ), $trackingInfos ); From e608d731c5b560363d69aac48a2a5361929ef3f9 Mon Sep 17 00:00:00 2001 From: "tomaz.jakomin" Date: Wed, 5 Feb 2020 14:54:25 +0100 Subject: [PATCH 3/3] DHL-66 Removed type hinting to be compatible with older php version --- src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php b/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php index 05debf3..d6fbc59 100644 --- a/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php +++ b/src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php @@ -102,7 +102,7 @@ public function map(SoapTrackingResponse $soapTrackingResponse) * @param null|ShipmentEventCollection $shipmentEvents * @return ShipmentEventInterface[] */ - private function convertTrackEventItems(ShipmentEventCollection $shipmentEvents) + private function convertTrackEventItems($shipmentEvents) { $events = [];