Skip to content

Commit

Permalink
Update LaravelPostnlApi.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sytheveenje committed Jan 31, 2024
1 parent 044325c commit d2c547a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/LaravelPostnlApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,18 @@ public function generateLabel(
return $e->getMessage();
}

$responseShipments = collect($response->object()->ResponseShipments)->first();
if($response->object() && $response->object()->ResponseShipments) {
$responseShipments = collect($response->object()->ResponseShipments)->first();

if($fullLabel) {
return $responseShipments;
}
if($fullLabel) {
return $responseShipments;
}

return collect($responseShipments->Labels)->first()->Content;

return collect($responseShipments->Labels)->first()->Content;
} else {
return Exception('PostNL API Error: '. $response->object());
}

}

Expand Down Expand Up @@ -194,7 +199,7 @@ public function confirmShipment(
array $contact = null,
string $productCodeDelivery = '3085',
array $productOptions = null,
string $devilveryDate = null,
string $deliveryDate = null,
string $reference = null,
string $remark = null
)
Expand All @@ -215,7 +220,7 @@ public function confirmShipment(
'Contacts' => $contact,
'ProductCodeDelivery' => $productCodeDelivery,
'ProductOptions' => $productOptions,
'DeliveryDate' => $devilveryDate,
'DeliveryDate' => Carbon::parse($deliveryDate)->format('d-m-Y H:i:s'),
'Barcode' => $barcode,
'Reference' => $reference,
'Remark' => $remark,
Expand Down

0 comments on commit d2c547a

Please sign in to comment.