Skip to content

Commit

Permalink
Merge pull request #44 from sameday-courier/SamedayGetParcelResponse
Browse files Browse the repository at this point in the history
Sameday get parcel response
  • Loading branch information
Soptareanu authored Mar 5, 2024
2 parents 75d6abf + 4233d89 commit b68edfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/Sameday/Responses/SamedayGetParcelStatusHistoryResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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']
);
Expand All @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion src/Sameday/SamedayClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit b68edfe

Please sign in to comment.