44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
|
/**
|
||
|
* Create an organization on behalf of a user.
|
||
|
*
|
||
|
* @param string $username The user's display name.
|
||
|
* @param string $fullName The organization full name.
|
||
|
* @param string|null $description The organization description (optional).
|
||
|
* @param string|null $location The organization location (optional).
|
||
|
* @param bool $repoAdminChangeTeamAccess Whether repo admin can change team access (optional).
|
||
|
* @param string $visibility The organization visibility (optional).
|
||
|
* @param string|null $website The organization website (optional).
|
||
|
*
|
||
|
* @return object|null
|
||
|
* @since 3.2.0
|
||
|
**/
|
||
|
public function create(
|
||
|
string $username,
|
||
|
string $fullName,
|
||
|
?string $description = null,
|
||
|
?string $location = null,
|
||
|
bool $repoAdminChangeTeamAccess = false,
|
||
|
string $visibility = 'public',
|
||
|
?string $website = null
|
||
|
): ?object
|
||
|
{
|
||
|
// Build the request path.
|
||
|
$path = "/admin/users/{$username}/orgs";
|
||
|
|
||
|
// Set the organization data.
|
||
|
$data = new \stdClass();
|
||
|
$data->full_name = $fullName;
|
||
|
$data->description = $description;
|
||
|
$data->location = $location;
|
||
|
$data->repo_admin_change_team_access = $repoAdminChangeTeamAccess;
|
||
|
$data->visibility = $visibility;
|
||
|
$data->website = $website;
|
||
|
|
||
|
// Send the post request.
|
||
|
return $this->response->get(
|
||
|
$this->http->post(
|
||
|
$this->uri->get($path), json_encode($data)
|
||
|
), 201
|
||
|
);
|
||
|
}
|