mirror of
https://github.com/avency/Gitea.git
synced 2025-10-29 10:42:33 +01:00
feat: Add miscellaaneous endpoint
This commit is contained in:
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Avency\Gitea;
|
namespace Avency\Gitea;
|
||||||
|
|
||||||
use Avency\Gitea\Endpoint\EndpointInterface;
|
use Avency\Gitea\Endpoint\EndpointInterface;
|
||||||
|
use Avency\Gitea\Endpoint\Miscellaneous;
|
||||||
use Avency\Gitea\Endpoint\Repositories;
|
use Avency\Gitea\Endpoint\Repositories;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
@ -13,6 +14,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
* Gitea Client
|
* Gitea Client
|
||||||
*
|
*
|
||||||
* @method Repositories repositories()
|
* @method Repositories repositories()
|
||||||
|
* @method Miscellaneous miscellaneous()
|
||||||
*/
|
*/
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
|
|||||||
37
Classes/Endpoint/Miscellaneous.php
Normal file
37
Classes/Endpoint/Miscellaneous.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Avency\Gitea\Endpoint;
|
||||||
|
|
||||||
|
use Avency\Gitea\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Miscellaneous endpoint
|
||||||
|
*/
|
||||||
|
class Miscellaneous implements EndpointInterface
|
||||||
|
{
|
||||||
|
const BASE_URI = 'api/v1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Client
|
||||||
|
*/
|
||||||
|
protected $client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Client $client
|
||||||
|
*/
|
||||||
|
public function __construct(Client $client)
|
||||||
|
{
|
||||||
|
$this->client = $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function version(): string
|
||||||
|
{
|
||||||
|
$response = $this->client->request(self::BASE_URI . '/version');
|
||||||
|
return \GuzzleHttp\json_decode($response->getBody(), true)['version'];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user