gitea/src/b5ca512b-f667-4ec6-bc6e-914.../code.power

42 lines
1020 B
Plaintext

/**
* Gets all packages of an owner.
*
* @param string $owner The owner of the packages.
* @param int $page Page number of results to return (1-based).
* @param int $limit Page size of results.
* @param string|null $type Package type filter (optional).
* @param string|null $name Filter Name filter (optional).
*
* @return array|null
* @since 3.2.0
**/
public function get(
string $owner,
int $page = 1,
int $limit = 10,
?string $type = null,
?string $nameFilter = null
): ?array
{
// Build the request path.
$path = "/packages/{$owner}";
// Configure the URI with query parameters.
$uri = $this->uri->get($path);
$uri->setVar('page', $page);
$uri->setVar('limit', $limit);
if ($type !== null)
{
$uri->setVar('type', $type);
}
if ($nameFilter !== null)
{
$uri->setVar('q', $nameFilter);
}
// Send the get request.
return $this->response->get(
$this->http->get($uri)
);
}