appwrite/src/Appwrite/Utopia/Response/Model/Session.php

211 lines
7.7 KiB
PHP
Raw Normal View History

2020-06-23 15:01:20 +00: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 06:53:13 +00:00
$this
->addRule('$id', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-24 06:53:13 +00:00
'description' => 'Session ID.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-24 06:53:13 +00:00
'example' => '5e5ea5c16897e',
])
->addRule('$createdAt', [
2022-07-04 09:55:11 +00:00
'type' => self::TYPE_DATETIME,
2022-09-04 21:26:16 +00:00
'description' => 'Session creation date in ISO 8601 format.',
2022-07-04 09:55:11 +00:00
'default' => '',
2022-08-14 10:27:07 +00:00
'example' => self::TYPE_DATETIME_EXAMPLE,
])
2024-04-10 11:42:20 +00:00
->addRule('$updatedAt', [
'type' => self::TYPE_DATETIME,
'description' => 'Session update date in ISO 8601 format.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('userId', [
'type' => self::TYPE_STRING,
'description' => 'User ID.',
2020-12-01 18:53:31 +00:00
'default' => '',
'example' => '5e5bb8c16897e',
])
2020-06-24 06:53:13 +00:00
->addRule('expire', [
2022-07-05 10:59:03 +00:00
'type' => self::TYPE_DATETIME,
2022-09-04 21:26:16 +00:00
'description' => 'Session expiration date in ISO 8601 format.',
2022-07-05 10:59:03 +00:00
'default' => '',
2022-08-14 10:27:07 +00:00
'example' => self::TYPE_DATETIME_EXAMPLE,
2020-06-24 06:53:13 +00:00
])
2021-02-19 13:59:36 +00:00
->addRule('provider', [
'type' => self::TYPE_STRING,
'description' => 'Session Provider.',
2021-03-29 09:16:56 +00:00
'default' => '',
'example' => 'email',
2021-02-19 13:59:36 +00:00
])
->addRule('providerUid', [
'type' => self::TYPE_STRING,
'description' => 'Session Provider User ID.',
2021-03-29 09:16:56 +00:00
'default' => '',
'example' => 'user@example.com',
2021-02-19 13:59:36 +00:00
])
->addRule('providerAccessToken', [
2021-02-19 13:59:36 +00:00
'type' => self::TYPE_STRING,
'description' => 'Session Provider Access Token.',
'default' => '',
'example' => 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3',
])
2022-02-01 10:42:11 +00:00
->addRule('providerAccessTokenExpiry', [
2022-07-05 13:06:55 +00:00
'type' => self::TYPE_DATETIME,
2022-09-04 21:26:16 +00:00
'description' => 'The date of when the access token expires in ISO 8601 format.',
2022-07-05 13:06:55 +00:00
'default' => '',
2022-08-14 10:27:07 +00:00
'example' => self::TYPE_DATETIME_EXAMPLE,
2022-02-01 10:42:11 +00:00
])
->addRule('providerRefreshToken', [
'type' => self::TYPE_STRING,
'description' => 'Session Provider Refresh Token.',
2021-03-29 09:16:56 +00:00
'default' => '',
2021-03-29 11:22:50 +00:00
'example' => 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3',
2021-02-19 13:59:36 +00:00
])
2020-06-24 06:53:13 +00:00
->addRule('ip', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'IP in use when the session was created.',
'default' => '',
2020-06-24 06:53:13 +00:00
'example' => '127.0.0.1',
])
->addRule('osCode', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'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-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Operating system name.',
'default' => '',
'example' => 'Mac',
])
->addRule('osVersion', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Operating system version.',
'default' => '',
'example' => 'Mac',
])
->addRule('clientType', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Client type.',
'default' => '',
'example' => 'browser',
])
->addRule('clientCode', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'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-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Client name.',
'default' => '',
'example' => 'Chrome Mobile iOS',
])
->addRule('clientVersion', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Client version.',
'default' => '',
'example' => '84.0',
])
->addRule('clientEngine', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Client engine name.',
'default' => '',
'example' => 'WebKit',
])
->addRule('clientEngineVersion', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Client engine name.',
'default' => '',
'example' => '605.1.15',
])
->addRule('deviceName', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Device name.',
'default' => '',
'example' => 'smartphone',
])
->addRule('deviceBrand', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Device brand name.',
'default' => '',
'example' => 'Google',
])
->addRule('deviceModel', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Device model name.',
'default' => '',
'example' => 'Nexus 5',
])
->addRule('countryCode', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Country two-character ISO 3166-1 alpha code.',
'default' => '',
'example' => 'US',
])
->addRule('countryName', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
'description' => 'Country name.',
'default' => '',
'example' => 'United States',
])
->addRule('current', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_BOOLEAN,
'description' => 'Returns true if this the current user session.',
2020-11-20 21:02:42 +00:00
'default' => false,
'example' => true,
])
2023-06-22 13:35:49 +00:00
->addRule('factors', [
2024-02-05 13:17:04 +00:00
'type' => self::TYPE_STRING,
2024-02-02 12:42:15 +00:00
'description' => 'Returns a list of active session factors.',
2024-02-05 13:17:04 +00:00
'default' => [],
'example' => ['email'],
'array' => true,
2023-06-22 13:35:49 +00:00
])
->addRule('secret', [
'type' => self::TYPE_STRING,
'description' => 'Secret used to authenticate the user. Only included if the request was made with an API key',
'default' => '',
'example' => '5e5bb8c16897e',
])
2024-03-02 13:05:22 +00:00
->addRule('mfaUpdatedAt', [
'type' => self::TYPE_DATETIME,
'description' => 'Most recent date in ISO 8601 format when the session successfully passed MFA challenge.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
2020-06-24 06:53:13 +00:00
;
2020-06-23 15:01:20 +00:00
}
/**
* Get Name
*
2020-06-23 15:01:20 +00:00
* @return string
*/
2022-05-23 14:54:50 +00:00
public function getName(): string
2020-06-23 15:01:20 +00:00
{
return 'Session';
}
/**
2021-12-15 10:19:29 +00:00
* Get Type
*
2020-06-23 15:01:20 +00:00
* @return string
*/
2022-05-23 14:54:50 +00:00
public function getType(): string
2020-06-23 15:01:20 +00:00
{
2020-06-24 06:41:00 +00:00
return Response::MODEL_SESSION;
2020-06-23 15:01:20 +00:00
}
}