Nhảy đến nội dung

updateUser

Cập nhật một đối tượng người dùng đơn lẻ. 🔐 Phương thức này yêu cầu ủy quyền.

Mô tả

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. Nó trả về một Promise mà khi hoàn thành sẽ trả về một đối tượng IUserEntity.

Users.updateUser(

body, body.formIdentifier, body.langCode, body.formData, body.notificationData, body.state, langCode

);

Sơ đồ tham số

Sơ đồ

body(bắt buộc): 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": {}
}

body.formIdentifier(bắt buộc): string
Định danh văn bản của biểu mẫu.
ví dụ: "form_12345"

body.langCode: string
Mã ngôn ngữ cho việc địa phương hóa. Mặc định: "en_US".

body.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"
}
]

body.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"
}

body.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"

Ví dụ

Ví dụ tối thiểu

// 1. Ủy quyền
await AuthProvider.auth("email", {
"authData": [
{
"marker": "email_reg",
"value": "your@email.com",
},
{
"marker": "password_reg",
"value": "yourPassword"
}
]
});

// 2. Cập nhật người dùng
const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "yourPassword"
}
],
"formData": {
"marker": "last_name",
"type": "string"
"value": "Username"
},
"notificationData": {
"phonePush": ["+99999999999"],
"phoneSMS": "+99999999999",
},
"state": {}
};

const response = await Users.updateUser(body);

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 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 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