gitea/src/c1be1e0d-479d-44de-bfe4-cfa.../code.power

74 lines
1.8 KiB
Plaintext

/**
* Get a list of members of an organization.
*
* @param string $orgName The organization name.
* @param int $page The page number.
* @param int $limit The number of members per page.
*
* @return array|null The organization members.
* @since 3.2.0
*/
public function list(
string $orgName,
int $page = 1,
int $limit = 10
): ?array
{
// Build the request path.
$path = "/orgs/{$orgName}/members";
// Get the URI and set query parameters.
$uri = $this->uri->get($path);
$uri->setVar('page', $page);
$uri->setVar('limit', $limit);
// Send the request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Check if a user is a member of an organization.
*
* @param string $org The organization name.
* @param string $username The username.
*
* @return string Whether the user is a member of the organization.
* @since 3.2.0
*/
public function check(string $org, string $username): string
{
// Build the request path.
$path = "/orgs/{$org}/members/{$username}";
// Send the request.
return $this->response->get(
$this->http->get(
$this->uri->get($path)
), 204, 'success'
);
}
/**
* Remove a member from an organization.
*
* @param string $org The organization name.
* @param string $username The username of the user to remove.
*
* @return string Whether the user was successfully removed from the organization.
* @since 3.2.0
*/
public function remove(string $org, string $username): string
{
// Build the request path.
$path = "/orgs/{$org}/members/{$username}";
// Send the request.
return $this->response->get(
$this->http->delete(
$this->uri->get($path)
), 204, 'success'
);
}