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

84 lines
2.4 KiB
PHP
Raw Normal View History

2020-06-05 09:53:06 +00:00
<?php
2020-06-23 15:01:20 +00:00
namespace Appwrite\Utopia\Response\Model;
2020-06-05 09:53:06 +00:00
2020-06-23 15:01:20 +00:00
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
2020-06-05 09:53:06 +00:00
2020-06-23 15:01:20 +00:00
class User extends Model
2020-06-05 09:53:06 +00:00
{
public function __construct()
{
$this
2020-06-22 16:25:01 +00:00
->addRule('$id', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-22 16:25:01 +00:00
'description' => 'User ID.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-22 16:25:01 +00:00
'example' => '5e5ea5c16897e',
])
->addRule('name', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-22 16:25:01 +00:00
'description' => 'User name.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-22 16:25:01 +00:00
'example' => 'John Doe',
])
2020-06-22 19:06:57 +00:00
->addRule('registration', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_INTEGER,
2020-06-24 11:18:33 +00:00
'description' => 'User registration date in Unix timestamp.',
2021-01-13 15:06:36 +00:00
'default' => 0,
2020-06-24 06:53:13 +00:00
'example' => 1592981250,
2020-06-22 19:06:57 +00:00
])
->addRule('status', [
'type' => self::TYPE_BOOLEAN,
'description' => 'User status. Pass `true` for enabled and `false` for disabled.',
'default' => true,
'example' => true,
2020-06-22 19:06:57 +00:00
])
->addRule('passwordUpdate', [
'type' => self::TYPE_INTEGER,
'description' => 'Unix timestamp of the most recent password update',
'default' => 0,
'example' => 1592981250,
])
2020-06-22 16:25:01 +00:00
->addRule('email', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-22 16:25:01 +00:00
'description' => 'User email address.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-22 16:25:01 +00:00
'example' => 'john@appwrite.io',
])
->addRule('emailVerification', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_BOOLEAN,
2020-06-22 16:25:01 +00:00
'description' => 'Email verification status.',
'default' => false,
'example' => true,
])
->addRule('prefs', [
2021-04-21 13:37:51 +00:00
'type' => Response::MODEL_PREFERENCES,
2020-06-22 16:25:01 +00:00
'description' => 'User preferences as a key-value object',
'default' => new \stdClass,
'example' => ['theme' => 'pink', 'timezone' => 'UTC'],
2020-06-22 16:25:01 +00:00
])
2020-06-05 09:53:06 +00:00
;
}
/**
* Get Name
*
2020-06-05 09:53:06 +00:00
* @return string
*/
public function getName():string
{
return 'User';
}
/**
2021-12-15 10:19:29 +00:00
* Get Type
*
2020-06-05 09:53:06 +00:00
* @return string
*/
2020-06-23 15:01:20 +00:00
public function getType():string
2020-06-05 09:53:06 +00:00
{
2020-06-23 15:01:20 +00:00
return Response::MODEL_USER;
2020-06-05 09:53:06 +00:00
}
}