| @@ 198-219 (lines=22) @@ | ||
| 195 | * | |
| 196 | * @return SMSAResponse | |
| 197 | */ | |
| 198 | public function trackByReference(string $reference) | |
| 199 |     { | |
| 200 | $result = $this->service->getTrackingByRef( | |
| 201 | $payload = new GetTrackingByRef($reference, $this->passKey) | |
| 202 | ); | |
| 203 | ||
| 204 |         if (false === $result) { | |
| 205 |             return $this->failedRequest('GetTrackingwithRef', $payload); | |
| 206 | } | |
| 207 | ||
| 208 | $data = $result->getGetTrackingByRefResult(); | |
| 209 | ||
| 210 |         if (is_null($data)) { | |
| 211 |             return $this->failedResponse('GetTrackingwithRef', $payload, 'Shipment was not found'); | |
| 212 | } | |
| 213 | ||
| 214 | return $this->successResponse( | |
| 215 | 'GetTrackingwithRef', | |
| 216 | $payload, | |
| 217 | $data->getAny() | |
| 218 | ); | |
| 219 | } | |
| 220 | ||
| 221 | /** | |
| 222 | * @param $awb | |
| @@ 336-357 (lines=22) @@ | ||
| 333 | * | |
| 334 | * @return SMSAResponse | |
| 335 | */ | |
| 336 | public function awbPDF(string $awb): SMSAResponse | |
| 337 |     { | |
| 338 | $result = $this->service->getPDF( | |
| 339 | $payload = new GetPDF($awb, $passKey ?? $this->passKey) | |
| 340 | ); | |
| 341 | ||
| 342 |         if (false === $result) { | |
| 343 |             return $this->failedRequest('GetPDF', $payload); | |
| 344 | } | |
| 345 | ||
| 346 | $data = $result->getGetPDFResult(); | |
| 347 | ||
| 348 |         if (empty($data) || is_null($data)) { | |
| 349 |             return $this->failedResponse('GetPDF', $payload, 'Cannot print pdf, shipment was not found'); | |
| 350 | } | |
| 351 | ||
| 352 | return $this->successResponse( | |
| 353 | 'GetPDF', | |
| 354 | $payload, | |
| 355 | $data | |
| 356 | ); | |
| 357 | } | |
| 358 | ||
| 359 | /** | |
| 360 | * Parse the cities xml response into array | |