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:
Michael Gerdemann
2020-01-17 08:38:49 +01:00
parent d4bb8a6108
commit 5aaff48c99
4 changed files with 201 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Avency\Gitea\Endpoint;
use Avency\Gitea\Client;
/**
* Endpoint interface
*/
interface EndpointInterface
{
}

View 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);
}
}