2023-05-02 00:10:55 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 4th September, 2022
|
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace VDM\Joomla\Gitea\Abstraction;
|
|
|
|
|
|
|
|
|
|
|
|
use VDM\Joomla\Gitea\Utilities\Http;
|
|
|
|
use VDM\Joomla\Gitea\Utilities\Uri;
|
|
|
|
use VDM\Joomla\Gitea\Utilities\Response;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Gitea Api
|
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
abstract class Api
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The Http class
|
|
|
|
*
|
|
|
|
* @var Http
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Http $http;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Uri class
|
|
|
|
*
|
|
|
|
* @var Uri
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Uri $uri;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Response class
|
|
|
|
*
|
|
|
|
* @var Response
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Response $response;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param Http $http The http class.
|
|
|
|
* @param Uri $uri The uri class.
|
|
|
|
* @param Response $response The response class.
|
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
**/
|
|
|
|
public function __construct(Http $http, Uri $uri, Response $response)
|
|
|
|
{
|
|
|
|
$this->http = $http;
|
|
|
|
$this->uri = $uri;
|
|
|
|
$this->response = $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load/Reload API.
|
|
|
|
*
|
2023-10-18 07:26:30 +00:00
|
|
|
* @param string|null $url The url.
|
|
|
|
* @param token|null $token The token.
|
2023-05-02 00:10:55 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @since 3.2.0
|
|
|
|
**/
|
2023-10-18 07:26:30 +00:00
|
|
|
public function load_(?string $url = null, ?string $token = null)
|
2023-05-02 00:10:55 +00:00
|
|
|
{
|
2023-10-18 07:26:30 +00:00
|
|
|
if ($url !== null)
|
|
|
|
{
|
|
|
|
$this->uri->setUrl($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($token !== null)
|
|
|
|
{
|
|
|
|
$this->http->setToken($token);
|
|
|
|
}
|
2023-05-02 00:10:55 +00:00
|
|
|
}
|
2023-10-20 18:29:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the API url
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 3.2.0
|
|
|
|
**/
|
|
|
|
public function api()
|
|
|
|
{
|
|
|
|
return $this->uri->api();
|
|
|
|
}
|
2023-05-02 00:10:55 +00:00
|
|
|
}
|
|
|
|
|