Skip to content

Commit

Permalink
Allow local checkout environment with sidekick on bold.ninja tunnels (#…
Browse files Browse the repository at this point in the history
…272)

* Allow local checkout environment including sidekick on bold.ninja tunnels

* Revert "Allow local checkout environment including sidekick on bold.ninja tunnels"

This reverts commit de441c0.

* Allow for easier local checkout setup
  • Loading branch information
cxfos authored Jun 17, 2024
1 parent 4fdeb0b commit 76660ed
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Model/Http/BoldClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,28 @@ private function getHeaders(int $websiteId): array
private function getUrl(int $websiteId, string $url): string
{
$apiUrl = $this->config->getApiUrl($websiteId);

if (str_contains($apiUrl, 'bold.ninja')) {
$parseApiUrl = parse_url($apiUrl);
$scheme = $parseApiUrl['scheme'];
$host = $parseApiUrl['host'];
$path = $parseApiUrl['path'];
$tunnelDomain = ltrim($path, '/');
$baseApiUrl = $scheme.'://'.$host;

if ($url === 'shops/v1/info') {
$apiUrl = $baseApiUrl;
}

if (str_contains($url, 'checkout_sidekick')) {
$apiUrl = $baseApiUrl.'/sidekick-'.$tunnelDomain;
}
}

if (!$this->config->getShopId($websiteId)) {
return $apiUrl . $url;
return $apiUrl.$url;
}
return $apiUrl . str_replace('{{shopId}}', $this->config->getShopId($websiteId), $url);

return $apiUrl.str_replace('{{shopId}}', $this->config->getShopId($websiteId), $url);
}
}

0 comments on commit 76660ed

Please sign in to comment.