Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Commit b6adf9e

Browse files
committed
Uses a better method to avoid the Weak-Warning Bug
1 parent ed5aeb2 commit b6adf9e

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ All these Persons helped to create this SDK for the DHL-API:
6767
- [aschempp](https://github.com/aschempp) - For the help with the Notification E-Mail
6868
- [cedricziel](https://github.com/cedricziel) - For turning this Project into a [Composer](https://getcomposer.org/)-Package
6969
- [Dakror](https://github.com/Dakror) - For the `ProductInfo`-Class
70-
- [Magellanth](https://github.com/Magellanth) - For helping to solve the "Weak-Warning" issue
7170
- [octlabs](https://github.com/octlabs) - For adding some missing Documentation
7271
- [Petschko](https://github.com/Petschko) - Initially created this Project and decided to share it for free
7372
- [tobias-redmann](https://github.com/tobias-redmann) - For the `setFullStreet` method and the PHP-DHL-Example-Project for Version 1 _(This helped a lot to understand how the API works)_

includes/Response.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Date: 18.11.2016
99
* Time: 16:00
1010
* Update: 15.04.2019
11-
* Version: 1.3.4
11+
* Version: 1.3.5
1212
*
1313
* Notes: Contains the DHL-Response Class, which manages the response that you get with simple getters
1414
*/
@@ -321,8 +321,31 @@ private function validateStatusCode() {
321321
$this->setStatusCode(self::DHL_ERROR_WEAK_WARNING);
322322

323323
// Fix the DHL-Error Weak-Warning-Bug
324-
if($this->getStatusCode() === self::DHL_ERROR_WEAK_WARNING && $this->getStatusMessage() === 'ok;Der Webservice wurde ohne Fehler ausgeführt.')
325-
$this->setStatusCode(self::DHL_ERROR_NO_ERROR);
324+
if($this->countLabelData() === 1) {
325+
// ALWAYS uses the Shipment-Response when only 1
326+
$this->setStatusCode($this->getLabelData(0)->getStatusCode());
327+
$this->setStatusText($this->getLabelData(0)->getStatusText());
328+
$this->setStatusMessage($this->getLabelData(0)->getStatusMessage());
329+
} else if($this->getStatusCode() === self::DHL_ERROR_WEAK_WARNING) {
330+
$noError = true;
331+
332+
// Search in all shipments if an error/warning exists
333+
foreach($this->getLabelData() as &$labelData) {
334+
/**
335+
* @var LabelData $labelData
336+
*/
337+
if($labelData->getStatusCode() !== self::DHL_ERROR_NO_ERROR) {
338+
$noError = false;
339+
break;
340+
}
341+
}
342+
343+
if($noError) {
344+
$this->setStatusCode(self::DHL_ERROR_NO_ERROR);
345+
$this->setStatusText('ok');
346+
$this->setStatusMessage('Der Webservice wurde ohne Fehler ausgeführt.');
347+
}
348+
}
326349
}
327350

328351
/**
@@ -374,8 +397,6 @@ private function loadResponse_v2($response) {
374397
else
375398
$this->setStatusMessage($response->Status->statusMessage);
376399
}
377-
378-
$this->validateStatusCode();
379400
}
380401

381402
// Set Manifest if exists (getManifest)
@@ -407,5 +428,9 @@ private function loadResponse_v2($response) {
407428
$this->handleMultiShipments($response->ExportDocData);
408429
else if(isset($response->ManifestState)) // 6
409430
$this->handleMultiShipments($response->ManifestState);
431+
432+
// Validate the status to fix errors on the Main-Status and show weak-warnings
433+
if($this->getStatusCode() !== self::DHL_ERROR_NOT_SET)
434+
$this->validateStatusCode();
410435
}
411436
}

0 commit comments

Comments
 (0)