updateUser
Cập nhật một đối tượng người dùng duy nhất. 🔐 Phương thức này yêu cầu ủy quyền?.
Người dùng?.updateUser( body?, langCode? );
Ví dụ tối thiểu
// 1. Ủy quyềnawait AuthProvider?.auth("email"?, {
"authData": [
?{
"marker": "email_reg",?"value": "your@email.com",?},
{
"marker": "password_reg",?"value": "yourPassword"?}
]
});
// 2. Cập nhật người dùngconst body = {
"formIdentifier": "reg",?"authData": [?{
"marker": "password",?"value": "yourPassword"?}
],"formData": {
?"marker": "last_name",?"type": "string"?"value": "Username"?},
"notificationData": {
?"email": "example@oneentry.cloud",?"phonePush": ["+99999999999"],?"phoneSMS": "+99999999999",?"state": {}
?}
};
const value = await Users.updateUser(body);
Schema
body(required): IUserBody
Nội dung yêu cầu
ví dụ:
{
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": {
"marker": "last_name",
"type": "string",
"value": "Username"
},
"notificationData": {
"email": "example@oneentry.cloud",
"phonePush": [
"+99999999999"
],
"phoneSMS": "+99999999999",
"state": {}
}
}
formIdentifier(required): string
Định danh văn bản của biểu mẫu.
ví dụ: "form_12345"
langCode: string
Mã ngôn ngữ cho việc địa phương hóa. Mặc định: "en_US".
formData: IAuthFormData | IAuthFormData[]
Đối tượng dữ liệu biểu mẫu hoặc mảng các đối tượng dữ liệu biểu mẫu.
ví dụ:
[
{
"marker": "first_name",
"type": "string",
"value": "John"
},
{
"marker": "last_name",
"type": "string",
"value": "Doe"
}
]
notificationData: object
Đối tượng chứa dữ liệu thông báo, bao gồm thông tin email và điện thoại.
ví dụ:
{
"email": "example@oneentry.cloud",
"phonePush": [
"+99999999999"
],
"phoneSMS": "+99999999999"
}
state: any
Đối tượng chứa thông tin trạng thái bổ sung.
ví dụ:
{
"key": "value"
}
langCode: string
Mã ngôn ngữ. Mặc định: "en_US"
ví dụ: "en_US"
Phương thức này cập nhật đối tượng dữ liệu của người dùng đã được ủy quyền. Trả về true (trong trường hợp cập nhật thành công) hoặc false (trong trường hợp cập nhật không thành công).
Ví dụ cho tham số body với các loại dữ liệu khác nhau
Ví dụ với thuộc tính kiểu đơn giản "string", "integer", "float"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": {
"en_US": [
{
"marker": "last_name",
"type": "string",
"value": "Федор Иванов"
}
]
},
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
},
"state": {}
}
Ví dụ với các thuộc tính kiểu "date", "dateTime", "time"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "birthday",
"type": "date",
"value": {
"fullDate": "2024-05-07T21:02:00.000Z",
"formattedValue": "08-05-2024 00:02",
"formatString": "DD-MM-YYYY HH:mm"
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "text"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "about",
"type": "text",
"value": {
"htmlValue": "<p>Это я</p>",
"plainValue": "Это я",
"mdValue": "*Это я*",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "textWithHeader"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "about",
"type": "textWithHeader",
"value": {
"header": "Заголовок",
"htmlValue": "<p>Это я</p>",
"plainValue": "Это я",
"mdValue": "*Это я*",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với các thuộc tính kiểu "image" và "groupOfImages"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "avatar",
"type": "image",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585,
"previewLink": "",
"params": {
"isImageCompressed": true
}
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "file"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "picture",
"type": "file",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "radioButton"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "selector",
"type": "radioButton",
"value": {
"title": "red",
"value": "1",
"extended": {
"value": "красный",
"type": "string"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "list"
{
"formIdentifier": "reg",
"langCode": "en_US",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "selector",
"type": "list",
"value": [
{
"title": "red",
"value": "1",
"extended": {
"value": "красный",
"type": "string"
}
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "entity" (danh sách lồng nhau)
{
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "entity-selector",
"type": "entity",
"value": [
1,
2
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ với thuộc tính kiểu "timeInterval"
{
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "interval",
"type": "timeInterval",
"value": [
[
"2025-02-11T16:00:00.000Z",
"2025-02-13T16:00:00.000Z"
]
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}
Ví dụ trả về
true