add: all
This commit is contained in:
parent
a15319c4d1
commit
eebf859afa
39 changed files with 2742 additions and 937 deletions
61
app/Http/Controllers/GiteaApiController/GiteaFetch.php
Normal file
61
app/Http/Controllers/GiteaApiController/GiteaFetch.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\GiteaApiController;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\CsvController\CsvController;
|
||||
use App\Http\Controllers\IssueValidationController;
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
use Illuminate\Http\Request;
|
||||
use OwenVoke\Gitea\Client;
|
||||
|
||||
class GiteaFetch extends Controller
|
||||
{
|
||||
private $giteaClient;
|
||||
|
||||
private $partner_organization;
|
||||
|
||||
private $main_company_organization;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->main_company_organization = getenv('GITEA_MAIN_COMPANY_ORGANIZATION');
|
||||
$this->partner_organization = getenv('GITEA_PARTNER_ORGANIZATION');
|
||||
$this->gitea_url = getenv('GITEA_URL');
|
||||
$this->gitea_token = getenv('GITEA_TOKEN');
|
||||
$this->giteaClient = new Client(null, null, $this->gitea_url);
|
||||
$this->giteaClient->authenticate($this->gitea_token, null, Client::AUTH_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
function get_repositories()
|
||||
{
|
||||
$repositories = $this->giteaClient->organizations()->repositories($this->partner_organization, 1, 9999);
|
||||
return $repositories;
|
||||
}
|
||||
|
||||
function get_issues(string $repository, array $parameters = array())
|
||||
{
|
||||
return $this->giteaClient->repositories()->issues()->all($this->partner_organization, $repository, $parameters);
|
||||
}
|
||||
|
||||
function get_issue_time(string $repository_name, int $issue_number){
|
||||
return $this->giteaClient->repositories()->issues()->times($this->partner_organization, $repository_name, $issue_number);
|
||||
}
|
||||
|
||||
function get_company_agents()
|
||||
{
|
||||
$gitea_api_call_url = $this->gitea_url . '/api/v1/orgs/' . $this->main_company_organization . '/members';
|
||||
$http_client = new GuzzleClient();
|
||||
$res = $http_client->get($gitea_api_call_url, [
|
||||
'headers' => [
|
||||
'Authorization' => 'token ' . $this->gitea_token
|
||||
]
|
||||
]);
|
||||
$responseBody = $res->getBody()->getContents();
|
||||
$users = json_decode($responseBody, true);
|
||||
//removes 1st user, usually it's the admin
|
||||
array_shift($users);
|
||||
$users = array_column($users, 'username');
|
||||
return $users;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue