Skip to content

Refactor GuzzleClient #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Clients/GuzzleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use GuzzleHttp\Client;
use LKDev\HetznerCloud\HetznerAPIClient;

class GuzzleClient extends Client
class GuzzleClient
{
protected Client $client;

/**
* @param HetznerAPIClient $client
* @param array $additionalGuzzleConfig
Expand All @@ -21,6 +23,11 @@ public function __construct(HetznerAPIClient $client, $additionalGuzzleConfig =
'User-Agent' => ((strlen($client->getUserAgent()) > 0) ? $client->getUserAgent().' ' : '').'hcloud-php/'.HetznerAPIClient::VERSION,
],
], $additionalGuzzleConfig);
parent::__construct($guzzleConfig);
$this->client = new Client($guzzleConfig);
}

public function __call($name, $arguments)
{
return $this->client->$name(...$arguments);
}
}
1 change: 1 addition & 0 deletions src/Models/PlacementGroups/PlacementGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LKDev\HetznerCloud\Models\PlacementGroups;

use GuzzleHttp\Client;
use LKDev\HetznerCloud\APIResponse;
use LKDev\HetznerCloud\HetznerAPIClient;
use LKDev\HetznerCloud\Models\Actions\Action;
Expand Down