Updated naming conventions
This commit is contained in:
parent
97a9497ec1
commit
2f1e25fc09
|
@ -17,6 +17,7 @@ use Appwrite\Database\Document;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
use Appwrite\Event\Event;
|
use Appwrite\Event\Event;
|
||||||
use Appwrite\Network\Validator\Origin;
|
use Appwrite\Network\Validator\Origin;
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configuration files
|
* Configuration files
|
||||||
|
@ -270,7 +271,6 @@ $utopia->options(function () use ($request, $response) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) {
|
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) {
|
||||||
$env = Config::getParam('env');
|
|
||||||
$version = Config::getParam('version');
|
$version = Config::getParam('version');
|
||||||
|
|
||||||
switch ($error->getCode()) {
|
switch ($error->getCode()) {
|
||||||
|
@ -292,7 +292,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
||||||
|
|
||||||
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
||||||
|
|
||||||
$output = ((App::MODE_TYPE_DEVELOPMENT == $env)) ? [
|
$output = ($utopia->isDevelopment()) ? [
|
||||||
'message' => $error->getMessage(),
|
'message' => $error->getMessage(),
|
||||||
'code' => $error->getCode(),
|
'code' => $error->getCode(),
|
||||||
'file' => $error->getFile(),
|
'file' => $error->getFile(),
|
||||||
|
@ -337,9 +337,8 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
||||||
$response->send($layout->render());
|
$response->send($layout->render());
|
||||||
}
|
}
|
||||||
|
|
||||||
$response
|
$response->dynamic(new Document($output),
|
||||||
->json($output)
|
$utopia->isDevelopment() ? Response::MODEL_ERROR_DEV : Response::MODEL_LOCALE);
|
||||||
;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$utopia->get('/manifest.json')
|
$utopia->get('/manifest.json')
|
||||||
|
|
|
@ -4,7 +4,6 @@ global $utopia, $register, $request, $response, $user, $audit,
|
||||||
$webhook, $mail, $project, $projectDB, $clients;
|
$webhook, $mail, $project, $projectDB, $clients;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
use Utopia\Validator\Assoc;
|
use Utopia\Validator\Assoc;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
|
@ -25,7 +24,7 @@ use Appwrite\Database\Validator\Authorization;
|
||||||
use Appwrite\Template\Template;
|
use Appwrite\Template\Template;
|
||||||
use Appwrite\OpenSSL\OpenSSL;
|
use Appwrite\OpenSSL\OpenSSL;
|
||||||
use Appwrite\URL\URL as URLParser;
|
use Appwrite\URL\URL as URLParser;
|
||||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
use Appwrite\Utopia\Response;
|
||||||
use DeviceDetector\DeviceDetector;
|
use DeviceDetector\DeviceDetector;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
use Utopia\Validator\ArrayList;
|
use Utopia\Validator\ArrayList;
|
||||||
|
@ -134,8 +133,8 @@ $utopia->post('/v1/account')
|
||||||
->setParam('resource', 'users/'.$user->getId())
|
->setParam('resource', 'users/'.$user->getId())
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->setStatusCode(UtopiaResponse::STATUS_CODE_CREATED);
|
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
||||||
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()));
|
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()), Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -529,7 +528,7 @@ $utopia->get('/v1/account')
|
||||||
->label('sdk.response', ['200' => 'user'])
|
->label('sdk.response', ['200' => 'user'])
|
||||||
->action(
|
->action(
|
||||||
function () use ($response, &$user, $oauth2Keys) {
|
function () use ($response, &$user, $oauth2Keys) {
|
||||||
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()));
|
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()), Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -710,7 +709,7 @@ $utopia->patch('/v1/account/name')
|
||||||
->setParam('resource', 'users/'.$user->getId())
|
->setParam('resource', 'users/'.$user->getId())
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()));
|
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()), Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -744,7 +743,7 @@ $utopia->patch('/v1/account/password')
|
||||||
->setParam('resource', 'users/'.$user->getId())
|
->setParam('resource', 'users/'.$user->getId())
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()));
|
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()), Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -794,7 +793,7 @@ $utopia->patch('/v1/account/email')
|
||||||
->setParam('resource', 'users/'.$user->getId())
|
->setParam('resource', 'users/'.$user->getId())
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()));$response->dynamic($user);
|
$response->dynamic($user->setAttribute('roles', Authorization::getRoles()), Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
global $utopia, $register, $request, $response, $projectDB, $project, $user, $audit;
|
global $utopia, $register, $request, $response, $projectDB, $project, $user, $audit;
|
||||||
|
|
||||||
use Appwrite\Database\Document;
|
use Appwrite\Database\Document;
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
|
@ -31,7 +32,6 @@ $utopia->get('/v1/locale')
|
||||||
$ip = '79.177.241.94';
|
$ip = '79.177.241.94';
|
||||||
}
|
}
|
||||||
|
|
||||||
$output['$collection'] = 'locale';
|
|
||||||
$output['ip'] = $ip;
|
$output['ip'] = $ip;
|
||||||
|
|
||||||
$currency = null;
|
$currency = null;
|
||||||
|
@ -66,7 +66,7 @@ $utopia->get('/v1/locale')
|
||||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
|
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->dynamic(new Document($output));
|
$response->dynamic(new Document($output), Response::MODEL_LOCALE);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ $utopia->post('/v1/users')
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
||||||
$response->dynamic($user);
|
$response->dynamic($user, Response::MODEL_USER);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,27 @@ namespace Appwrite\Utopia;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Appwrite\Database\Document;
|
use Appwrite\Database\Document;
|
||||||
use Appwrite\Utopia\Response\Result;
|
use Appwrite\Utopia\Response\Model;
|
||||||
use Appwrite\Utopia\Response\Result\User;
|
use Appwrite\Utopia\Response\Model\Error;
|
||||||
use Appwrite\Utopia\Response\Result\Locale;
|
use Appwrite\Utopia\Response\Model\ErrorDev;
|
||||||
|
use Appwrite\Utopia\Response\Model\User;
|
||||||
|
use Appwrite\Utopia\Response\Model\Locale;
|
||||||
use Utopia\Response as UtopiaResponse;
|
use Utopia\Response as UtopiaResponse;
|
||||||
|
|
||||||
class Response extends UtopiaResponse
|
class Response extends UtopiaResponse
|
||||||
{
|
{
|
||||||
|
const MODEL_ERROR = 'error';
|
||||||
|
const MODEL_ERROR_DEV = 'errorDev';
|
||||||
|
const MODEL_USER = 'user';
|
||||||
|
const MODEL_LOCALE = 'locale';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setResult(new User())
|
->setModel(new Error())
|
||||||
->setResult(new Locale())
|
->setModel(new ErrorDev())
|
||||||
|
->setModel(new User())
|
||||||
|
->setModel(new Locale())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,71 +36,63 @@ class Response extends UtopiaResponse
|
||||||
/**
|
/**
|
||||||
* List of defined output objects
|
* List of defined output objects
|
||||||
*/
|
*/
|
||||||
protected $results = [];
|
protected $models = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Result Object
|
* Set Model Object
|
||||||
*
|
*
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setResult(Result $result): self
|
public function setModel(Model $instance): self
|
||||||
{
|
{
|
||||||
$this->results[$result->getCollection()] = $result;
|
$this->models[$instance->getType()] = $instance;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Result Object
|
* Get Model Object
|
||||||
*
|
*
|
||||||
* @return Result
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function getResult(string $key): Result
|
public function getModel(string $key): Model
|
||||||
{
|
{
|
||||||
if(!isset($this->results[$key])) {
|
if(!isset($this->models[$key])) {
|
||||||
throw new Exception('Undefined result: '.$key);
|
throw new Exception('Undefined model: '.$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->results[$key];
|
return $this->models[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate response objects and outputs
|
* Validate response objects and outputs
|
||||||
* the response according to given format type
|
* the response according to given format type
|
||||||
*/
|
*/
|
||||||
public function dynamic(Document $document, $type = self::CONTENT_TYPE_JSON)
|
public function dynamic(Document $document, string $model)
|
||||||
{
|
{
|
||||||
$collection = $document->getCollection();
|
|
||||||
$data = $document->getArrayCopy();
|
$data = $document->getArrayCopy();
|
||||||
$result = $this->getResult($collection);
|
$model = $this->getModel($model);
|
||||||
$output = [];
|
$output = [];
|
||||||
|
|
||||||
foreach($result->getRules() as $key => $rule) {
|
foreach($model->getRules() as $key => $rule) {
|
||||||
if(!isset($data[$key])) {
|
if(!isset($data[$key])) {
|
||||||
if(!is_null($rule['default'])) {
|
if(!is_null($rule['default'])) {
|
||||||
$data[$key] = $rule['default'];
|
$data[$key] = $rule['default'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Exception('Missing response key: ' . $key);
|
throw new Exception('Missing response key: '.$key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($rule['array'] && !is_array($data[$key])) {
|
||||||
|
throw new Exception($key.' must be an array of '.$rule['type'].' types');
|
||||||
|
}
|
||||||
|
|
||||||
$output[$key] = $data[$key];
|
$output[$key] = $data[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
return $this->json($output);
|
||||||
case self::CONTENT_TYPE_JSON:
|
//return $this->yaml($output);
|
||||||
return $this->json($output);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::CONTENT_TYPE_YAML:
|
|
||||||
return $this->yaml($output);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new Exception('Unknown content type');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response;
|
namespace Appwrite\Utopia\Response;
|
||||||
|
|
||||||
abstract class Result
|
abstract class Model
|
||||||
{
|
{
|
||||||
protected $rules = [];
|
protected $rules = [];
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ abstract class Result
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract public function getCollection():string;
|
abstract public function getType():string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Rules
|
* Get Rules
|
50
src/Appwrite/Utopia/Response/Model/Error.php
Normal file
50
src/Appwrite/Utopia/Response/Model/Error.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Error extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addRule('message', [
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'Error message.',
|
||||||
|
'example' => 'Not found',
|
||||||
|
])
|
||||||
|
->addRule('code', [
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'Error code.',
|
||||||
|
'example' => '404',
|
||||||
|
])
|
||||||
|
->addRule('version', [
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'Server version number.',
|
||||||
|
'example' => APP_VERSION_STABLE,
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'Error';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
43
src/Appwrite/Utopia/Response/Model/ErrorDev.php
Normal file
43
src/Appwrite/Utopia/Response/Model/ErrorDev.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
|
||||||
|
class ErrorDev extends Error
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->addRule('file', [
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'File path.',
|
||||||
|
'example' => '/usr/share/nginx/html/vendor/utopia-php/framework/src/App.php',
|
||||||
|
])
|
||||||
|
->addRule('line', [
|
||||||
|
'type' => 'integer',
|
||||||
|
'description' => 'Line number.',
|
||||||
|
'example' => 209,
|
||||||
|
])
|
||||||
|
// ->addRule('trace', [
|
||||||
|
// 'type' => 'string',
|
||||||
|
// 'description' => 'Error trace.',
|
||||||
|
// 'example' => [
|
||||||
|
// ''
|
||||||
|
// ],
|
||||||
|
// ])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_ERROR_DEV;
|
||||||
|
}
|
||||||
|
}
|
34
src/Appwrite/Utopia/Response/Model/File.php
Normal file
34
src/Appwrite/Utopia/Response/Model/File.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class File extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'File';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_LOCALE;
|
||||||
|
}
|
||||||
|
}
|
33
src/Appwrite/Utopia/Response/Model/Health.php
Normal file
33
src/Appwrite/Utopia/Response/Model/Health.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Health extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'User';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_LOCALE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
class Locale extends Result
|
class Locale extends Model
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -56,7 +57,7 @@ class Locale extends Result
|
||||||
*/
|
*/
|
||||||
public function getName():string
|
public function getName():string
|
||||||
{
|
{
|
||||||
return 'User';
|
return 'Locale';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,8 +65,8 @@ class Locale extends Result
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCollection():string
|
public function getType():string
|
||||||
{
|
{
|
||||||
return 'locale';
|
return Response::MODEL_LOCALE;
|
||||||
}
|
}
|
||||||
}
|
}
|
33
src/Appwrite/Utopia/Response/Model/Log.php
Normal file
33
src/Appwrite/Utopia/Response/Model/Log.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Log extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'Session';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_LOCALE;
|
||||||
|
}
|
||||||
|
}
|
33
src/Appwrite/Utopia/Response/Model/Session.php
Normal file
33
src/Appwrite/Utopia/Response/Model/Session.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Session extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'Session';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_LOCALE;
|
||||||
|
}
|
||||||
|
}
|
33
src/Appwrite/Utopia/Response/Model/Token.php
Normal file
33
src/Appwrite/Utopia/Response/Model/Token.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Token extends Model
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return 'User';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Collection
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType():string
|
||||||
|
{
|
||||||
|
return Response::MODEL_LOCALE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Utopia\Response;
|
||||||
use Appwrite\Utopia\Response\Result;
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
class User extends Result
|
class User extends Model
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -76,8 +76,8 @@ class User extends Result
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCollection():string
|
public function getType():string
|
||||||
{
|
{
|
||||||
return Database::SYSTEM_COLLECTION_USERS;
|
return Response::MODEL_USER;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
class File extends Result
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', 'string', 'User ID.', '5e5ea5c16897e')
|
|
||||||
->addRule('name', 'string', 'User name.', 'John Doe')
|
|
||||||
->addRule('email', 'string', 'User email address.', 'john@appwrite.io')
|
|
||||||
->addRule('emailVerification', 'string', 'Email verification status.', true)
|
|
||||||
->addRule('registration', 'integer', 'User registration date in UNIX format.', 1583261121)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName():string
|
|
||||||
{
|
|
||||||
return 'User';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Collection
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCollection():string
|
|
||||||
{
|
|
||||||
return Database::SYSTEM_COLLECTION_TOKENS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
class Health extends Result
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', 'string', 'User ID.', '5e5ea5c16897e')
|
|
||||||
->addRule('name', 'string', 'User name.', 'John Doe')
|
|
||||||
->addRule('email', 'string', 'User email address.', 'john@appwrite.io')
|
|
||||||
->addRule('emailVerification', 'string', 'Email verification status.', true)
|
|
||||||
->addRule('registration', 'integer', 'User registration date in UNIX format.', 1583261121)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName():string
|
|
||||||
{
|
|
||||||
return 'User';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Collection
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCollection():string
|
|
||||||
{
|
|
||||||
return Database::SYSTEM_COLLECTION_TOKENS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
class Log extends Result
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', 'string', 'Session ID.', '5e5ea5c16897e')
|
|
||||||
->addRule('expire', 'integer', 'Session expiration date in UNIX format.', 1583261121)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName():string
|
|
||||||
{
|
|
||||||
return 'Session';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Collection
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCollection():string
|
|
||||||
{
|
|
||||||
return Database::SYSTEM_COLLECTION_TOKENS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
class Session extends Result
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', 'string', 'Session ID.', '5e5ea5c16897e')
|
|
||||||
->addRule('expire', 'integer', 'Session expiration date in UNIX format.', 1583261121)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName():string
|
|
||||||
{
|
|
||||||
return 'Session';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Collection
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCollection():string
|
|
||||||
{
|
|
||||||
return Database::SYSTEM_COLLECTION_TOKENS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
use Appwrite\Database\Database;
|
|
||||||
use Appwrite\Utopia\Response\Result;
|
|
||||||
|
|
||||||
class Token extends Result
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', 'string', 'Token ID.', '5e5ea5c16897e')
|
|
||||||
->addRule('expire', 'integer', 'Token expiration date in UNIX format.', 1583261121)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName():string
|
|
||||||
{
|
|
||||||
return 'User';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Collection
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCollection():string
|
|
||||||
{
|
|
||||||
return Database::SYSTEM_COLLECTION_TOKENS;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue