diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index a0dff6e767..ded28945dc 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -8,6 +8,8 @@ use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\User; +use Appwrite\Utopia\Response\Model\Team; +use Appwrite\Utopia\Response\Model\TeamList; use Appwrite\Utopia\Response\Model\Locale; use Utopia\Response as UtopiaResponse; @@ -17,6 +19,7 @@ class Response extends UtopiaResponse const MODEL_LOG = 'log'; const MODEL_ERROR = 'error'; const MODEL_ERROR_DEV = 'errorDev'; + const MODEL_BASE_LIST = 'baseList'; // Users const MODEL_USER = 'user'; @@ -40,7 +43,9 @@ class Response extends UtopiaResponse // Teams const MODEL_TEAM = 'team'; + const MODEL_TEAM_LIST = 'teamList'; const MODEL_MEMBERSHIP = 'membership'; + const MODEL_MEMBERSHIP_LIST = 'membershipList'; public function __construct() { @@ -49,6 +54,8 @@ class Response extends UtopiaResponse ->setModel(new ErrorDev()) ->setModel(new User()) ->setModel(new Locale()) + ->setModel(new Team()) + ->setModel(new TeamList()) ; } @@ -116,7 +123,6 @@ class Response extends UtopiaResponse } return $this->json($output); - //return $this->yaml($output); } /** diff --git a/src/Appwrite/Utopia/Response/Model/BaseList.php b/src/Appwrite/Utopia/Response/Model/BaseList.php new file mode 100644 index 0000000000..1e7c8050bd --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/BaseList.php @@ -0,0 +1,40 @@ +addRule('sum', [ + 'type' => 'intgere', + 'description' => 'Total sum of items in the list.', + 'example' => '5e5ea5c16897e', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Base List'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_BASE_LIST; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Team.php b/src/Appwrite/Utopia/Response/Model/Team.php new file mode 100644 index 0000000000..1c538506ad --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Team.php @@ -0,0 +1,58 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Team ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Team name.', + 'default' => '', + 'example' => 'VIP', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'Team creation date in unix timestamp.', + 'default' => false, + 'example' => true, + ]) + ->addRule('sum', [ // TODO change key name? + 'type' => 'integer', + 'description' => 'Total sum of team members.', + 'default' => false, + 'example' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Team'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_TEAM; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/TeamList.php b/src/Appwrite/Utopia/Response/Model/TeamList.php new file mode 100644 index 0000000000..2c1951cfab --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/TeamList.php @@ -0,0 +1,40 @@ +addRule('teams', [ + 'type' => Response::MODEL_TEAM, + 'description' => 'List of teams.', + 'example' => [], + 'array' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Team List'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_TEAM_LIST; + } +} \ No newline at end of file