2020-06-24 03:01:20 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
class Session extends Model
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2020-06-24 18:53:13 +12:00
|
|
|
$this
|
|
|
|
->addRule('$id', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-06-24 18:53:13 +12:00
|
|
|
'description' => 'Session ID.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-06-24 18:53:13 +12:00
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
])
|
2020-11-26 19:12:24 +13:00
|
|
|
->addRule('userId', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'User ID.',
|
2020-12-02 07:53:31 +13:00
|
|
|
'default' => '',
|
2020-11-26 19:12:24 +13:00
|
|
|
'example' => '5e5bb8c16897e',
|
|
|
|
])
|
2020-06-24 18:53:13 +12:00
|
|
|
->addRule('expire', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_INTEGER,
|
2020-06-24 23:18:33 +12:00
|
|
|
'description' => 'Session expiration date in Unix timestamp.',
|
2020-10-30 02:07:56 +13:00
|
|
|
'default' => 0,
|
2020-06-24 18:53:13 +12:00
|
|
|
'example' => 1592981250,
|
|
|
|
])
|
2021-02-20 02:59:36 +13:00
|
|
|
->addRule('provider', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'Session Provider.',
|
|
|
|
'default' => 0,
|
|
|
|
'example' => 1592981250,
|
|
|
|
])
|
|
|
|
->addRule('providerUid', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'Session Provider User ID.',
|
|
|
|
'default' => 0,
|
|
|
|
'example' => 1592981250,
|
|
|
|
])
|
|
|
|
->addRule('providerToken', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'Session Provider Token.',
|
|
|
|
'default' => 0,
|
|
|
|
'example' => 1592981250,
|
|
|
|
])
|
2020-06-24 18:53:13 +12:00
|
|
|
->addRule('ip', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'IP in use when the session was created.',
|
|
|
|
'default' => '',
|
2020-06-24 18:53:13 +12:00
|
|
|
'example' => '127.0.0.1',
|
|
|
|
])
|
2020-10-30 02:07:56 +13:00
|
|
|
->addRule('osCode', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Mac',
|
|
|
|
])
|
|
|
|
->addRule('osName', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Operating system name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Mac',
|
|
|
|
])
|
|
|
|
->addRule('osVersion', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Operating system version.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Mac',
|
|
|
|
])
|
|
|
|
->addRule('clientType', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client type.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'browser',
|
|
|
|
])
|
|
|
|
->addRule('clientCode', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'CM',
|
|
|
|
])
|
|
|
|
->addRule('clientName', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Chrome Mobile iOS',
|
|
|
|
])
|
|
|
|
->addRule('clientVersion', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client version.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => '84.0',
|
|
|
|
])
|
|
|
|
->addRule('clientEngine', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client engine name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'WebKit',
|
|
|
|
])
|
|
|
|
->addRule('clientEngineVersion', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Client engine name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => '605.1.15',
|
|
|
|
])
|
|
|
|
->addRule('deviceName', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Device name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'smartphone',
|
|
|
|
])
|
|
|
|
->addRule('deviceBrand', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Device brand name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Google',
|
|
|
|
])
|
|
|
|
->addRule('deviceModel', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Device model name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'Nexus 5',
|
|
|
|
])
|
|
|
|
->addRule('countryCode', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Country two-character ISO 3166-1 alpha code.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'US',
|
|
|
|
])
|
|
|
|
->addRule('countryName', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Country name.',
|
|
|
|
'default' => '',
|
|
|
|
'example' => 'United States',
|
|
|
|
])
|
|
|
|
->addRule('current', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_BOOLEAN,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Returns true if this the current user session.',
|
2020-11-21 10:02:42 +13:00
|
|
|
'default' => false,
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => true,
|
|
|
|
])
|
2020-06-24 18:53:13 +12:00
|
|
|
;
|
2020-06-24 03:01:20 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
|
|
|
return 'Session';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Collection
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
2020-06-24 18:41:00 +12:00
|
|
|
return Response::MODEL_SESSION;
|
2020-06-24 03:01:20 +12:00
|
|
|
}
|
|
|
|
}
|