Aller au contenu principal

updateUser

Mise à jour d'un seul objet utilisateur. 🔐 Cette méthode nécessite l'autorisation.

Description

Cette méthode met à jour l'objet de données de l'utilisateur autorisé. Elle renvoie une promesse qui se résout en un objet IUserEntity.

Utilisateurs.updateUser(

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

);

Schéma des paramètres

Schéma

body(obligatoire) : IUserBody
Corps de la requête
exemple :

{
"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(obligatoire) : string
Identifiant textuel du formulaire.
exemple : "form_12345"

body.langCode : string
Code de langue pour la localisation. Par défaut : "en_US".

body.formData : IAuthFormData | IAuthFormData[]
Objet de données de formulaire ou tableau d'objets de données de formulaire.
exemple :

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

body.notificationData : objet
Objet contenant des données de notification, y compris des informations sur l'email et le téléphone.
exemple :

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

body.state : any
Objet contenant des informations d'état supplémentaires.
exemple :

{
"key": "value"
}

langCode : string
Code de langue. Par défaut : "en_US"
exemple : "en_US"

Exemples

Exemple minimal

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

// 2. Mettre à jour l'utilisateur
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 Utilisateurs.updateUser(body);

Exemples pour le paramètre body avec différents types de données

Exemple avec attribut de type simple "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": {}
}

Exemple avec des attributs de 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"
}
}

Exemple avec un attribut de 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"
}
}

Exemple avec un attribut de 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"
}
}

Exemple avec des attributs de type "image" et "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"
}
}

Exemple avec un attribut de 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"
}
}

Exemple avec un attribut de 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"
}
}

Exemple avec un attribut de 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"
}
}

Exemple avec un attribut de type "entity" (liste imbriquée)

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

Exemple avec un attribut de 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"
}
}

Exemple de retour

true