mirror of
https://github.com/avency/Gitea.git
synced 2025-10-29 02:34:59 +01:00
feat: Add basic client and first basic endpoint
Adds the client with first basic authentication and the first endpoint `repositories` with first method.
This commit is contained in:
14
Classes/Endpoint/EndpointInterface.php
Normal file
14
Classes/Endpoint/EndpointInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Endpoint interface
|
||||
*/
|
||||
interface EndpointInterface
|
||||
{
|
||||
}
|
||||
39
Classes/Endpoint/Repositories.php
Normal file
39
Classes/Endpoint/Repositories.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Repositories endpoint
|
||||
*/
|
||||
class Repositories implements EndpointInterface
|
||||
{
|
||||
const BASE_URI = 'api/v1/repos';
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
*/
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $owner
|
||||
* @param $repositoryName
|
||||
* @return array
|
||||
*/
|
||||
public function get($owner, $repositoryName): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName);
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user