Huge number of updates, too tired to list them all

+ Added a bunch of API handler classes that will use the already created models
+ Created a new Client class that will connect to new API handler classes
+ Created new collection classes
This commit is contained in:
Benjamin Blake
2020-02-19 22:10:59 -07:00
parent f530671000
commit 1bf0c070f8
21 changed files with 1007 additions and 3 deletions

46
src/Api/Organizations.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace Gitea\Api;
use GuzzleHttp\Psr7\Response;
use Gitea\Client;
use Gitea\Models\Organization;
use Gitea\Api\AbstractApi;
class Organizations extends AbstractApi
{
/**
* Get an organization using its username and parse
* it's information into an organization object
*
* Example:
* ```
* $giteaClient->organizations()->getByUsername($orgUsername);
* ```
*
* @param string $username
* @author Benjamin Blake (sitelease.ca)
*
* @return Organization|Response
*/
public function getByUsername(string $username)
{
$client = $this->getClient();
try {
$response = $this->get("orgs/$username");
$statusCode = $response->getStatusCode();
$body = $response->getBody();
if ($statusCode == 200) {
return Organization::fromJson(json_decode($body));
} else {
return $response;
}
} catch (ServerException $serverError) {
return $response;
}
}
}