Skip to main content

updateUser

Updating a single user object. πŸ” This method requires authorization.

Description​

This method updates the authorized user's data object. It returns a Promise that resolves to an IUserEntity object.

Users.updateUser(

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

);

Parameters schema​

Schema

body(required): IUserBody
Request body
example:

{
"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(required): string
Text identifier of the form.
example: "form_12345"

body.langCode: string
Language code for localization. Default: "en_US".

body.formData: IAuthFormData | IAuthFormData[]
Form data object or array of form data objects.
example:

[
{
"marker": "first_name",
"type": "string",
"value": "John"
},
{
"marker": "last_name",
"type": "string",
"value": "Doe"
}
]

body.notificationData: object
Object containing notification data, including email and phone information.
example:

{
"email": "example@oneentry.cloud",
"phonePush": [
"+99999999999"
],
"phoneSMS": "+99999999999"
}

body.state: any
Object containing additional state information.
example:

{
"key": "value"
}

langCode: string
Language code. Default: "en_US"
example: "en_US"

Examples​

Minimal example​

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

// 2. Update user
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);

Examples for body parameter with different types data​

Example with attribute of simple type "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": {}
}

Example with attributes of type "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"
}
}

Example with attribute of type "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"
}
}

Example with an attribute of type "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"
}
}

Example with attributes of type "image" and "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"
}
}

Example with attribute of type "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"
}
}

Example with attribute of type "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"
}
}

Example with attribute of type "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"
}
}

Example with an attribute of type "entity" (nested list)​

{
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "entity-selector",
"type": "entity",
"value": [
1,
2
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
}

Example with attribute of type "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"
}
}

Example return​

true