feat: implement multi-provider architecture for contribution fetching and add Docker support

This commit is contained in:
2026-05-29 11:51:05 +02:00
parent 381b8f4489
commit 56035096c6
13 changed files with 272 additions and 89 deletions
+16 -6
View File
@@ -12,18 +12,28 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
*
* Required token scopes: read:user
*/
class GiteaProvider
class GiteaProvider implements ProviderInterface
{
public function __construct(private readonly HttpClientInterface $client) {}
public function __construct(
private readonly HttpClientInterface $client,
private readonly string $username,
private readonly string $token,
private readonly string $baseUrl,
) {}
public function isConfigured(): bool
{
return $this->username !== '' && $this->token !== '' && $this->baseUrl !== '';
}
/**
* @return array<string, int> date (Y-m-d) => contribution count
*/
public function fetch(string $username, string $token, string $baseUrl): array
public function fetch(): array
{
$baseUrl = rtrim($baseUrl, '/');
$response = $this->client->request('GET', "$baseUrl/api/v1/users/$username/heatmap", [
'headers' => ['Authorization' => "token $token"],
$baseUrl = rtrim($this->baseUrl, '/');
$response = $this->client->request('GET', "$baseUrl/api/v1/users/{$this->username}/heatmap", [
'headers' => ['Authorization' => "token {$this->token}"],
]);
$data = $response->toArray();