|
8 | 8 | * Date: 18.11.2016
|
9 | 9 | * Time: 16:00
|
10 | 10 | * Update: 15.04.2019
|
11 |
| - * Version: 1.3.4 |
| 11 | + * Version: 1.3.5 |
12 | 12 | *
|
13 | 13 | * Notes: Contains the DHL-Response Class, which manages the response that you get with simple getters
|
14 | 14 | */
|
@@ -321,8 +321,31 @@ private function validateStatusCode() {
|
321 | 321 | $this->setStatusCode(self::DHL_ERROR_WEAK_WARNING);
|
322 | 322 |
|
323 | 323 | // 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 | + } |
326 | 349 | }
|
327 | 350 |
|
328 | 351 | /**
|
@@ -374,8 +397,6 @@ private function loadResponse_v2($response) {
|
374 | 397 | else
|
375 | 398 | $this->setStatusMessage($response->Status->statusMessage);
|
376 | 399 | }
|
377 |
| - |
378 |
| - $this->validateStatusCode(); |
379 | 400 | }
|
380 | 401 |
|
381 | 402 | // Set Manifest if exists (getManifest)
|
@@ -407,5 +428,9 @@ private function loadResponse_v2($response) {
|
407 | 428 | $this->handleMultiShipments($response->ExportDocData);
|
408 | 429 | else if(isset($response->ManifestState)) // 6
|
409 | 430 | $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(); |
410 | 435 | }
|
411 | 436 | }
|
0 commit comments