feat: implement multi-provider architecture for contribution fetching and add Docker support
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user