# gogs-php-api-client A client to query Gogs (https://gogs.io) API from PHP. ## Uages: A guide on how to use will come shortly! ### Quick example: Clone the repo. Set the `API_URL` and `API_TOKEN` in the index-file. ```php $client = new \Client\GogsAPI(API_URL, API_TOKEN); $me = $client->user(); $other = $client->user("username"); $repos = $me->get("/repos")->load(); // Loop through every repo for($repo = $repos->current(); $repo != false; $repo = $repos->next()) var_dump($repo); ``` # Progress ## Users ### Search ``` GET /users/search ``` ```php $users = $client->users()->search(array("name" => /* username */)); ``` The array-param can be * name/q: The username * limit: maximum number of results, default: 10 Returns a `CollectionResult`, e.g ```php foreach ($users as $user) echo $user->ufull_name . "\n"; ``` ### Get authenticated user ``` GET /user ``` ```php $me = $client->user(); // alt: $client->users()->get() ``` ### Get a single user ``` GET /users/:username ``` ```php $user = $client->user("username"); // alt: $client->users()->get("username") ``` ### Create a user ``` POST /admin/users ``` ```php $user = $clients->users()->new( "new user", "users@email.com" ); ``` The params should be in the order * username (required) * email (required) * source_id * login_name * password * send_notify Requires the authenticated user to have admin rights. ### Delete a user ``` DELETE /admin/users/:username ``` ```php $user->delete(); ``` Requires the authenticated user to have admin rights. ### Get a user's repos ``` GET /user/repos ``` or ``` GET /users/:username/repos ``` ```php $repos = $user->repos()->load(); ``` ### Get specific user's repo ``` GET /repos/:owner/:repo ``` ```php $repo = $user->repo( /* repo */ ); ``` ### Create a user's repo ``` POST /user/repos ``` or ``` POST /admin/users/:username/repos ``` ```php $user->repos()->new( "name" ); ``` The params should be in the order * name * description * private * bool * auto_init * gitignores * license * readme Requires the authenticated user to have admin rights to be able to create repos for other users than itself. ### Delete a user's repo ``` DELETE /repos/:owner/:repo ``` ```php $repo->delete(); ``` Requires the authenticated user to have admin rights to be able to delete repos for other users than itself. ### Get a user's organizations ``` GET /user/orgs ``` or ``` GET /users/:username/orgs ``` ```php $orgs = $user->organizations(); ``` ## Organizations ### Get an organizations repositories ``` GET /orgs/:orgname/repos ``` ```php $org = $user->organizations()->load()->current(); $repos = $org->repos(); ```