Read Parcel2Go label hash from order links when Hash is empty
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
504a867351
commit
51c6748894
@@ -163,6 +163,25 @@ class Parcel2Go
|
||||
])->throw()->json() ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parcel2Go leaves the order's Hash empty and puts the label hash in its "labels-a4" link instead.
|
||||
*
|
||||
* @param array<string, mixed> $order
|
||||
*/
|
||||
public function labelHash(array $order): ?string
|
||||
{
|
||||
if (filled($order['Hash'] ?? null)) {
|
||||
return (string) $order['Hash'];
|
||||
}
|
||||
$link = collect($order['Links'] ?? [])->first(fn ($link): bool => is_array($link) && str_starts_with((string) ($link['Name'] ?? ''), 'labels-a4'))['Link'] ?? null;
|
||||
if (! is_string($link)) {
|
||||
return null;
|
||||
}
|
||||
parse_str((string) parse_url($link, PHP_URL_QUERY), $query);
|
||||
|
||||
return filled($query['hash'] ?? null) ? (string) $query['hash'] : null;
|
||||
}
|
||||
|
||||
public function labelPdf(string $reference, string $hash): string
|
||||
{
|
||||
$token = $this->profileConnected() ? $this->profileAccessToken() : $this->accessToken();
|
||||
|
||||
Reference in New Issue
Block a user