Skip to content

Commit

Permalink
Simplified client logic by removing header based api call and add las…
Browse files Browse the repository at this point in the history
…tRequestHeaders method.
  • Loading branch information
sanderlissenburg committed Jan 27, 2025
1 parent 9ba5475 commit b7d19d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class BaseClient
/** @var ?callable */
private $accessTokenExpiredCallback = null;

private $lastRequestHeaders = null;

/**
* BaseClient constructor.
*/
Expand Down Expand Up @@ -376,9 +378,7 @@ public function request(string $method, string $url, array $options, array $resp
}
}

if ($method === 'HEAD' && $response->getStatusCode() === 200) {
return $response->getHeaders();
}
$this->lastRequestHeaders = $response->getHeaders();

return $this->decodeResponse($response, $responseTypes, $url);
}
Expand Down
25 changes: 0 additions & 25 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1800,31 +1800,6 @@ public function getShippingLabel(string $shippingLabelId): ?string
return $this->request('GET', $url, $options, $responseTypes);
}

/**
* Retrieves the headers of a shipping label by shipping label id. Shipping label metadata, for example the X-Track-And-Trace-Code, are added as headers
* in the response.
*
* @param string $shippingLabelId
* @return string|null
* @throws Exception\ConnectException
* @throws Exception\Exception
* @throws Exception\RateLimitException
* @throws Exception\ResponseException
* @throws Exception\UnauthorizedException
*/
public function getShippingLabelHeaders(string $shippingLabelId): ?array
{
$url = "retailer/shipping-labels/{$shippingLabelId}";
$options = [
'produces' => 'application/vnd.retailer.v10+pdf',
];
$responseTypes = [
'404' => 'null',
];

return $this->request('HEAD', $url, $options, $responseTypes);
}

/**
* Retrieves all event notification subscriptions for a given retailer. Each subscription may have different types
* of events and a destination, which could either be a URL (for WEBHOOK) or a topic name (for GCP_PUBSUB).
Expand Down

0 comments on commit b7d19d7

Please sign in to comment.