diff --git a/src/Sameday/Responses/SamedayGetParcelStatusHistoryResponse.php b/src/Sameday/Responses/SamedayGetParcelStatusHistoryResponse.php index 68f5095..4fb22b7 100644 --- a/src/Sameday/Responses/SamedayGetParcelStatusHistoryResponse.php +++ b/src/Sameday/Responses/SamedayGetParcelStatusHistoryResponse.php @@ -60,9 +60,15 @@ public function __construct(SamedayGetParcelStatusHistoryRequest $request, Samed $json['parcelSummary']['parcelAwbNumber'], $json['parcelSummary']['parcelWeight'], $json['parcelSummary']['isPickedUp'], - $json['parcelSummary']['deliveredAt'] ? new DateTime($json['parcelSummary']['deliveredAt']) : null, - $json['parcelSummary']['lastDeliveryAttempt'] ? new DateTime($json['parcelSummary']['lastDeliveryAttempt']) : null, - $json['parcelSummary']['isPickedUp'] && $json['parcelSummary']['pickedUpAt'] ? new DateTime($json['parcelSummary']['pickedUpAt']) : null + isset($json['parcelSummary']['deliveredAt']) + ? new DateTime($json['parcelSummary']['deliveredAt']) + : null, + isset($json['parcelSummary']['lastDeliveryAttempt']) + ? new DateTime($json['parcelSummary']['lastDeliveryAttempt']) + : null, + isset($json['parcelSummary']['isPickedUp'], $json['parcelSummary']['pickedUpAt']) + ? new DateTime($json['parcelSummary']['pickedUpAt']) + : null ); foreach ($json['parcelHistory'] as $history) { @@ -108,10 +114,10 @@ private function parseHistory(array $json) return new HistoryObject( $json['statusId'], $json['status'], - $json['statusLabel'], - $json['statusState'], + isset($json['statusLabel']) ? $json['statusLabel'] : null, + isset($json['statusState']) ? $json['statusState'] : null, new DateTime($json['statusDate']), - $json['county'] ?: null, + isset($json['county']) ? $json['county'] : null, $json['reason'], $json['transitLocation'] ); @@ -130,9 +136,9 @@ private function parseExpedition(array $json) $json['statusId'], $json['status'], $json['statusLabel'], - $json['statusState'], + isset($json['statusState']) ? $json['statusState'] : null, new DateTime($json['statusDate']), - $json['county'] ?: null, + isset($json['county']) ? $json['county'] : null, $json['reason'], $json['transitLocation'], $json['expeditionDetails'] diff --git a/src/Sameday/SamedayClient.php b/src/Sameday/SamedayClient.php index 0082bc3..5c3b1a5 100755 --- a/src/Sameday/SamedayClient.php +++ b/src/Sameday/SamedayClient.php @@ -27,7 +27,7 @@ */ class SamedayClient implements SamedayClientInterface { - const VERSION = '2.1.6'; + const VERSION = '2.1.7'; const API_HOST = 'https://api.sameday.ro'; const KEY_TOKEN = 'token'; const KEY_TOKEN_EXPIRES = 'expires_at';