- First commit of a big WIP
This commit is contained in:
commit
0c134d9eac
6 files changed
+462
No files matched your search
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\Gitea\Entity;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\{Api\Attribute\Property\Entity,
|
||||
Attribute\Property\Field,
|
||||
Entity\Field\Datetime,
|
||||
EntityTrait,
|
||||
SearchRequest\SearchRequestInterface,
|
||||
SearchRequest\SearchRequestPaginationTrait};
|
||||
use Ulmus\Api\Attribute\Obj\Api;
|
||||
|
||||
#[Api(adapter: "gitea")]
|
||||
#[Api\Create(url: "/repos/{owner}/{repo}/issues")]
|
||||
#[Api\Read(url: "/repos/{owner}/{repo}/issues/{index}")]
|
||||
#[Api\Collection(url: "/repos/{owner}/{repo}/issues")]
|
||||
#[Api\Update(url: "/repos/{owner}/{repo}/issues/{index}")]
|
||||
#[Api\Delete(url: "/repos/{owner}/{repo}/issues/{index}")]
|
||||
class Issue
|
||||
{
|
||||
use EntityTrait;
|
||||
|
||||
#[Field\Id]
|
||||
public int $id;
|
||||
|
||||
#[Field]
|
||||
public string $title;
|
||||
|
||||
#[Field]
|
||||
public string $body;
|
||||
|
||||
#[Field]
|
||||
public int $number;
|
||||
|
||||
#[Field(name: "html_url")]
|
||||
public string $htmlUrl;
|
||||
|
||||
#[Field]
|
||||
public string $url;
|
||||
|
||||
#[Field(name: "is_locked")]
|
||||
public bool $isLocked;
|
||||
|
||||
#[Field]
|
||||
public array $labels = [];
|
||||
|
||||
#[Field\CreatedAt(name: "closed_at")]
|
||||
public ? string $closedAt;
|
||||
|
||||
#[Field\CreatedAt(name: "due_date")]
|
||||
public ? string $dueDate;
|
||||
|
||||
#[Field\CreatedAt(name: "created_at")]
|
||||
public ? Datetime $createdAt;
|
||||
|
||||
#[Field\UpdatedAt(name: "updated_at")]
|
||||
public ? Datetime $updatedAt;
|
||||
|
||||
#[Entity]
|
||||
public User $user;
|
||||
|
||||
public static function searchRequest(...$arguments) : SearchRequestInterface
|
||||
{
|
||||
return new class($arguments[0]) implements SearchRequestInterface
|
||||
{
|
||||
use SearchRequestPaginationTrait;
|
||||
|
||||
public ? string $file = null;
|
||||
|
||||
public string $createdAt = "ASC";
|
||||
|
||||
public function __construct(ServerRequestInterface $request)
|
||||
{
|
||||
$get = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return $i !== ""; }));
|
||||
|
||||
$this->page = $get->offsetExists('page') ? $get['page'] : 1;
|
||||
$this->file = $get->offsetExists('file') ? $get['file'] : null;
|
||||
$this->createdAt = $get->offsetExists('created_at') ? $get['created_at'] : "DESC";
|
||||
}
|
||||
|
||||
public function filter(\Ulmus\Repository $repository): \Ulmus\Repository {
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public function wheres() : iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i); });
|
||||
}
|
||||
|
||||
public function likes(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
|
||||
public function groups(): iterable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function orders(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\Gitea\Entity;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\{Api\Attribute\Property\Entity,
|
||||
Attribute\Property\Field,
|
||||
Entity\Field\Datetime,
|
||||
EntityTrait,
|
||||
SearchRequest\SearchRequestInterface,
|
||||
SearchRequest\SearchRequestPaginationTrait};
|
||||
use Ulmus\Api\Attribute\Obj\Api;
|
||||
|
||||
#[Api(adapter: "gitea")]
|
||||
#[Api\Create(url: "/repos/{owner}/{repo}/issues/{index}/comments")]
|
||||
#[Api\Collection(url: "/repos/{owner}/{repo}/issues/{index}/comments")]
|
||||
#[Api\Read(url: "/repos/{owner}/{repo}/issues/comments/{id}")]
|
||||
#[Api\Update(url: "/repos/{owner}/{repo}/issues/comments/{id}")]
|
||||
#[Api\Delete(url: "/repos/{owner}/{repo}/issues/comments/{id}")]
|
||||
class IssueComment
|
||||
{
|
||||
use EntityTrait;
|
||||
|
||||
#[Field\Id]
|
||||
public int $id;
|
||||
|
||||
#[Field]
|
||||
public string $body;
|
||||
|
||||
#[Field(name: "html_url")]
|
||||
public string $htmlUrl;
|
||||
|
||||
#[Field(name:"issue_url")]
|
||||
public string $issueUrl;
|
||||
|
||||
#[Field\CreatedAt(name: "created_at")]
|
||||
public ? Datetime $createdAt;
|
||||
|
||||
#[Field\UpdatedAt(name: "updated_at")]
|
||||
public ? Datetime $updatedAt;
|
||||
|
||||
#[Entity]
|
||||
public User $user;
|
||||
|
||||
public static function searchRequest(...$arguments) : SearchRequestInterface
|
||||
{
|
||||
return new class($arguments[0]) implements SearchRequestInterface
|
||||
{
|
||||
use SearchRequestPaginationTrait;
|
||||
|
||||
public ? string $file = null;
|
||||
|
||||
public string $createdAt = "ASC";
|
||||
|
||||
public function __construct(ServerRequestInterface $request)
|
||||
{
|
||||
$get = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return $i !== ""; }));
|
||||
|
||||
$this->page = $get->offsetExists('page') ? $get['page'] : 1;
|
||||
$this->file = $get->offsetExists('file') ? $get['file'] : null;
|
||||
$this->createdAt = $get->offsetExists('created_at') ? $get['created_at'] : "DESC";
|
||||
}
|
||||
|
||||
public function filter(\Ulmus\Repository $repository): \Ulmus\Repository {
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public function wheres() : iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i); });
|
||||
}
|
||||
|
||||
public function likes(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
|
||||
public function groups(): iterable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function orders(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\Gitea\Entity;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\{Api\Attribute\Property\Entity,
|
||||
Attribute\Property\Field,
|
||||
Entity\Field\Datetime,
|
||||
EntityTrait,
|
||||
SearchRequest\SearchRequestInterface,
|
||||
SearchRequest\SearchRequestPaginationTrait};
|
||||
use Ulmus\Api\Attribute\Obj\Api;
|
||||
|
||||
#[Api(adapter: "gitea")]
|
||||
#[Api\Create(url: "/repos/{owner}/{id}")]
|
||||
#[Api\Collection(url: "/repos/{owner}/{id}")]
|
||||
#[Api\Read(url: "/repos/{owner}/{id}")]
|
||||
#[Api\Update(url: "/repos/{owner}/{id}")]
|
||||
#[Api\Delete(url: "/repos/{owner}/{id}")]
|
||||
class Repository
|
||||
{
|
||||
use EntityTrait;
|
||||
|
||||
#[Field\Id]
|
||||
public int $id;
|
||||
|
||||
#[Field]
|
||||
public string $title;
|
||||
|
||||
#[Field]
|
||||
public string $body;
|
||||
|
||||
#[Field]
|
||||
public int $number;
|
||||
|
||||
#[Field(name: "html_url")]
|
||||
public string $htmlUrl;
|
||||
|
||||
#[Field(name:"original_url")]
|
||||
public ? string $originalUrl;
|
||||
|
||||
#[Field(name: "is_locked")]
|
||||
public bool $isLocked;
|
||||
|
||||
#[Field]
|
||||
public array $labels = [];
|
||||
|
||||
#[Field\CreatedAt(name: "created_at")]
|
||||
public ? Datetime $createdAt;
|
||||
|
||||
#[Field\UpdatedAt(name: "updated_at")]
|
||||
public ? Datetime $updatedAt;
|
||||
|
||||
#[Entity]
|
||||
public User $owner;
|
||||
|
||||
public static function searchRequest(...$arguments) : SearchRequestInterface
|
||||
{
|
||||
return new class($arguments[0]) implements SearchRequestInterface
|
||||
{
|
||||
use SearchRequestPaginationTrait;
|
||||
|
||||
public ? string $file = null;
|
||||
|
||||
public string $createdAt = "ASC";
|
||||
|
||||
public function __construct(ServerRequestInterface $request)
|
||||
{
|
||||
$get = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return $i !== ""; }));
|
||||
|
||||
$this->page = $get->offsetExists('page') ? $get['page'] : 1;
|
||||
$this->file = $get->offsetExists('file') ? $get['file'] : null;
|
||||
$this->createdAt = $get->offsetExists('created_at') ? $get['created_at'] : "DESC";
|
||||
}
|
||||
|
||||
public function filter(\Ulmus\Repository $repository): \Ulmus\Repository {
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public function wheres() : iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i); });
|
||||
}
|
||||
|
||||
public function likes(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
|
||||
public function groups(): iterable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function orders(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\Gitea\Entity;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\{Attribute\Property\Field,
|
||||
Entity\Field\Datetime,
|
||||
EntityTrait,
|
||||
SearchRequest\SearchRequestInterface,
|
||||
SearchRequest\SearchRequestPaginationTrait};
|
||||
use Ulmus\Api\Attribute\Obj\Api;
|
||||
|
||||
#[Api(adapter: "gitea")]
|
||||
##[Api\Create(url: "/repos/{owner}/{repo}/issues")]
|
||||
##[Api\Collection(url: "/repos/{owner}/{repo}/issues")]
|
||||
##[Api\Read(url: "/repos/{owner}/{repo}/issues/{id}")]
|
||||
##[Api\Update(url: "/repos/{owner}/{repo}/issues/{id}")]
|
||||
##[Api\Delete(url: "/repos/{owner}/{repo}/issues/{id}")]
|
||||
class User
|
||||
{
|
||||
use EntityTrait;
|
||||
|
||||
#[Field\Id]
|
||||
public int $id;
|
||||
|
||||
#[Field(name:"login")]
|
||||
public string $login;
|
||||
|
||||
#[Field(name:"full_name")]
|
||||
public string $fullName;
|
||||
|
||||
#[Field]
|
||||
public string $email;
|
||||
|
||||
#[Field]
|
||||
public string $username;
|
||||
|
||||
#[Field(name: "is_admin")]
|
||||
public bool $isAdmin;
|
||||
|
||||
#[Field(name: "avatar_url")]
|
||||
public string $avatarUrl;
|
||||
|
||||
#[Field\CreatedAt(name: "created")]
|
||||
public ? Datetime $created;
|
||||
|
||||
public static function searchRequest(...$arguments) : SearchRequestInterface
|
||||
{
|
||||
return new class($arguments[0]) implements SearchRequestInterface
|
||||
{
|
||||
use SearchRequestPaginationTrait;
|
||||
|
||||
public ? string $file = null;
|
||||
|
||||
public string $createdAt = "ASC";
|
||||
|
||||
public function __construct(ServerRequestInterface $request)
|
||||
{
|
||||
$get = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return $i !== ""; }));
|
||||
|
||||
$this->page = $get->offsetExists('page') ? $get['page'] : 1;
|
||||
$this->file = $get->offsetExists('file') ? $get['file'] : null;
|
||||
$this->createdAt = $get->offsetExists('created_at') ? $get['created_at'] : "DESC";
|
||||
}
|
||||
|
||||
public function filter(\Ulmus\Repository $repository): \Ulmus\Repository {
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public function wheres() : iterable
|
||||
{
|
||||
return array_filter([
|
||||
#(string) Bug::field('software_id') => $this->softwareId,
|
||||
], function($i) { return ! is_null($i); });
|
||||
}
|
||||
|
||||
public function likes(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
#(string) Bug::field('title') => $this->title ? "%$this->title%" : null,
|
||||
#(string) Bug::field('file') => $this->file ? "%$this->file%" : null,
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
|
||||
public function groups(): iterable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function orders(): iterable
|
||||
{
|
||||
return array_filter([
|
||||
#(string) Bug::field('created_at') => $this->createdAt,
|
||||
], function($i) { return ! is_null($i) && $i !== ""; });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user