mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Added team model
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
abstract class BaseList extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Team extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class TeamList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user