fix bitbucket (#119)

Fix Bitbucket API errors
This commit is contained in:
Saeed Vaziry
2024-03-17 11:36:04 +01:00
committed by GitHub
parent f0c4fc4812
commit b07ae470f9
10 changed files with 167 additions and 45 deletions

View File

@ -16,7 +16,7 @@ class Gitlab extends AbstractSourceControlProvider
public function connect(): bool
{
$res = Http::withToken($this->sourceControl->access_token)
$res = Http::withToken($this->data()['token'])
->get($this->getApiUrl().'/projects');
return $res->successful();
@ -28,7 +28,7 @@ public function connect(): bool
public function getRepo(?string $repo = null): mixed
{
$repository = $repo ? urlencode($repo) : null;
$res = Http::withToken($this->sourceControl->access_token)
$res = Http::withToken($this->data()['token'])
->get($this->getApiUrl().'/projects/'.$repository.'/repository/commits');
$this->handleResponseErrors($res, $repo);
@ -49,7 +49,7 @@ public function fullRepoUrl(string $repo, string $key): string
public function deployHook(string $repo, array $events, string $secret): array
{
$repository = urlencode($repo);
$response = Http::withToken($this->sourceControl->access_token)->post(
$response = Http::withToken($this->data()['token'])->post(
$this->getApiUrl().'/projects/'.$repository.'/hooks',
[
'description' => 'deploy',
@ -84,7 +84,7 @@ public function deployHook(string $repo, array $events, string $secret): array
public function destroyHook(string $repo, string $hookId): void
{
$repository = urlencode($repo);
$response = Http::withToken($this->sourceControl->access_token)->delete(
$response = Http::withToken($this->data()['token'])->delete(
$this->getApiUrl().'/projects/'.$repository.'/hooks/'.$hookId
);
@ -99,7 +99,7 @@ public function destroyHook(string $repo, string $hookId): void
public function getLastCommit(string $repo, string $branch): ?array
{
$repository = urlencode($repo);
$res = Http::withToken($this->sourceControl->access_token)
$res = Http::withToken($this->data()['token'])
->get($this->getApiUrl().'/projects/'.$repository.'/repository/commits?ref_name='.$branch);
$this->handleResponseErrors($res, $repo);
@ -126,7 +126,7 @@ public function getLastCommit(string $repo, string $branch): ?array
public function deployKey(string $title, string $repo, string $key): void
{
$repository = urlencode($repo);
$response = Http::withToken($this->sourceControl->access_token)->post(
$response = Http::withToken($this->data()['token'])->post(
$this->getApiUrl().'/projects/'.$repository.'/deploy_keys',
[
'title' => $title,