Updated session model class
This commit is contained in:
parent
6c2f432469
commit
71ebad65b9
|
@ -32,6 +32,7 @@ class Response extends UtopiaResponse
|
|||
const MODEL_USER = 'user';
|
||||
const MODEL_USER_LIST = 'userList';
|
||||
const MODEL_SESSION = 'session';
|
||||
const MODEL_SESSION_LIST = 'sessionList';
|
||||
const MODEL_TOKEN = 'token'; // - Missing
|
||||
|
||||
// Database
|
||||
|
@ -75,6 +76,7 @@ class Response extends UtopiaResponse
|
|||
->setModel(new ErrorDev())
|
||||
// Lists
|
||||
->setModel(new BaseList('Users List', self::MODEL_USER_LIST, 'users', self::MODEL_USER))
|
||||
->setModel(new BaseList('Sessions List', self::MODEL_SESSION_LIST, 'sessions', self::MODEL_SESSION))
|
||||
->setModel(new BaseList('Files List', self::MODEL_FILE_LIST, 'files', self::MODEL_FILE))
|
||||
->setModel(new BaseList('Teams List', self::MODEL_TEAM_LIST, 'teams', self::MODEL_TEAM))
|
||||
->setModel(new BaseList('Memberships List', self::MODEL_MEMBERSHIP_LIST, 'memberships', self::MODEL_MEMBERSHIP))
|
||||
|
@ -156,14 +158,12 @@ class Response extends UtopiaResponse
|
|||
$document->setAttribute($key, $rule['default']);
|
||||
}
|
||||
else {
|
||||
var_dump($data);
|
||||
throw new Exception('Missing response key: '.$key);
|
||||
throw new Exception('Model '.$model->getName().' is missing response key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
if($rule['array']) {
|
||||
if(!is_array($data[$key])) {
|
||||
var_dump($data);
|
||||
throw new Exception($key.' must be an array of type '.$rule['type']);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class Session extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('expire', [
|
||||
'type' => 'string',
|
||||
'type' => 'integer',
|
||||
'description' => 'Session expiration date in Unix timestamp.',
|
||||
'example' => 1592981250,
|
||||
])
|
||||
|
@ -25,6 +25,81 @@ class Session extends Model
|
|||
'description' => 'IP session in use when the session was created.',
|
||||
'example' => '127.0.0.1',
|
||||
])
|
||||
->addRule('osCode', [
|
||||
'type' => 'string',
|
||||
'description' => 'Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).',
|
||||
'example' => 'Mac',
|
||||
])
|
||||
->addRule('osName', [
|
||||
'type' => 'string',
|
||||
'description' => 'Operating system name.',
|
||||
'example' => 'Mac',
|
||||
])
|
||||
->addRule('osVersion', [
|
||||
'type' => 'string',
|
||||
'description' => 'Operating system version.',
|
||||
'example' => 'Mac',
|
||||
])
|
||||
->addRule('clientType', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client type.',
|
||||
'example' => 'browser',
|
||||
])
|
||||
->addRule('clientCode', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).',
|
||||
'example' => 'CM',
|
||||
])
|
||||
->addRule('clientName', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client name.',
|
||||
'example' => 'Chrome Mobile iOS',
|
||||
])
|
||||
->addRule('clientVersion', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client version.',
|
||||
'example' => '84.0',
|
||||
])
|
||||
->addRule('clientEngine', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client engine name.',
|
||||
'example' => 'WebKit',
|
||||
])
|
||||
->addRule('clientEngineVersion', [
|
||||
'type' => 'string',
|
||||
'description' => 'Client engine name.',
|
||||
'example' => '605.1.15',
|
||||
])
|
||||
->addRule('deviceName', [
|
||||
'type' => 'string',
|
||||
'description' => 'Device name.',
|
||||
'example' => 'smartphone',
|
||||
])
|
||||
->addRule('deviceBrand', [
|
||||
'type' => 'string',
|
||||
'description' => 'Device brand name.',
|
||||
'example' => 'Google',
|
||||
])
|
||||
->addRule('deviceModel', [
|
||||
'type' => 'string',
|
||||
'description' => 'Device model name.',
|
||||
'example' => 'Nexus 5',
|
||||
])
|
||||
->addRule('countryCode', [
|
||||
'type' => 'string',
|
||||
'description' => 'Country two-character ISO 3166-1 alpha code.',
|
||||
'example' => 'US',
|
||||
])
|
||||
->addRule('countryName', [
|
||||
'type' => 'string',
|
||||
'description' => 'Country name.',
|
||||
'example' => 'United States',
|
||||
])
|
||||
->addRule('current', [
|
||||
'type' => 'boolean',
|
||||
'description' => 'Returns true if this the current user session.',
|
||||
'example' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue