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

Commit

Permalink
DHLEX-68: resolve #5
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz.jakomin authored and mam08ixo committed Feb 24, 2020
1 parent 1c589e2 commit ae745c1
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.idea
/composer.lock
/vendor
/Test/Coverage
/test/coverage
/coverage
6 changes: 3 additions & 3 deletions src/Api/Data/RateRequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions src/RequestBuilder/ShipmentDeleteRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
namespace Dhl\Express\RequestBuilder;

use DateTime;
use Dhl\Express\Api\ShipmentDeleteRequestBuilderInterface;
use Dhl\Express\Model\ShipmentDeleteRequest;

Expand All @@ -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;
Expand Down Expand Up @@ -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 = [];
Expand Down
1 change: 1 addition & 0 deletions src/Webservice/Soap/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Webservice/Soap/Type/ShipmentRequest/Ship/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Webservice/Soap/Type/ShipmentRequest/Ship/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
13 changes: 13 additions & 0 deletions src/Webservice/Soap/Type/Tracking/PiecesEnabled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* See LICENSE.md for license details.
*/

namespace Dhl\Express\Webservice\Soap\Type\Tracking;

class PiecesEnabled
{
const PIECE_AND_SHIPMENT_DETAIL = 'B';
const SHIPMENT_DETAIL = 'S';
const PIECE_DETAIL = 'P';
}
4 changes: 2 additions & 2 deletions src/Webservice/Soap/Type/Tracking/ShipmentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ShipmentInfo
protected $WeightUnit;

/**
* @var ShipmentEventCollection
* @var ShipmentEventCollection|null
*/
protected $ShipmentEvent;

Expand Down Expand Up @@ -276,7 +276,7 @@ public function setWeightUnit(WeightUnit $WeightUnit)
}

/**
* @return ShipmentEventCollection
* @return ShipmentEventCollection|null
*/
public function getShipmentEvent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Dhl\Express\Api\Data\ShipmentDeleteResponseInterface;
use Dhl\Express\Exception\ShipmentDeleteRequestException;
use Dhl\Express\Model\ShipmentDeleteResponse;
use Dhl\Express\Webservice\Soap\Type\Common\Notification;
use Dhl\Express\Webservice\Soap\Type\SoapShipmentDeleteResponse;

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Webservice/Soap/TypeMapper/TrackingResponseMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,25 @@ public function map(SoapTrackingResponse $soapTrackingResponse)
$weight,
$estimatedDeliveryDate
);

$soapTrackingPieces = $soapTrackingItem->getPieces();
$trackingPieces = [];
if ($soapTrackingPieces !== null) {
/** @var PieceInterface[] $trackingPieces */
$trackingPieces = $soapTrackingPieces->getPieceInfo()->getArrayOfPieceInfoItem();
}

if (($shipmentInfo !== null) && ($shipmentInfo->getShipmentEvent() instanceof ShipmentEventCollection)) {
$shipmentEvents = $this->convertTrackEventItems($shipmentInfo->getShipmentEvent());
} else {
$shipmentEvents = [];
}

$trackingInfos[] = new TrackingInfo(
$soapTrackingItem->getAWBNumber(),
$soapTrackingItem->getStatus()->getActionStatus(),
$shipmentDetails,
$shipmentInfo ? $this->convertTrackEventItems($shipmentInfo->getShipmentEvent()) : [],
$shipmentEvents,
$trackingPieces
);
}
Expand Down Expand Up @@ -106,6 +113,7 @@ public function map(SoapTrackingResponse $soapTrackingResponse)
private function convertTrackEventItems(ShipmentEventCollection $shipmentEvents)
{
$events = [];

foreach ($shipmentEvents->getArrayOfShipmentEventItem() as $shipmentEvent) {
$events[] = new TrackingInfo\ShipmentEvent(
$shipmentEvent->getDate(),
Expand Down
2 changes: 1 addition & 1 deletion test/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.2/phpunit.xsd" columns="max" stderr="true">
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.7/phpunit.xsd" columns="max" stderr="true">
<testsuites>
<testsuite name="DHL Express API Unit Tests">
<directory>./Unit</directory>
Expand Down

0 comments on commit ae745c1

Please sign in to comment.