From 27ec3d6ac5e042816fca79d21f77d5bed5c79141 Mon Sep 17 00:00:00 2001 From: meow12 Date: Mon, 3 Jan 2022 14:01:23 +0200 Subject: [PATCH] feat(db): change responsible user (#58) Allow to change responsible user on db record --- src/components/db.js | 30 ++++++++++++++++++++++++++++++ src/routes.js | 1 + 2 files changed, 31 insertions(+) diff --git a/src/components/db.js b/src/components/db.js index 83ac67b..3edb32d 100644 --- a/src/components/db.js +++ b/src/components/db.js @@ -705,3 +705,33 @@ export async function getChildrenOfTerms({ result: response.result, }; } + +export async function changeResponsibility({ + secretKey, + collectionName, + id, + newResponsibleUserId, + cluster, +}) { + const response = await server.loadJson( + `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.RESPONSIBILITY( + collectionName, + )}`, + { + method: 'POST', + headers: { + 'X-CM-ProjectId': Config.projectId, + 'X-CM-Cluster': cluster, + Authorization: `Bearer ${secretKey || Config.secretKey}`, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + id, + newResponsibleUserId, + }), + } + ); + + return response ? response.result : null; +} diff --git a/src/routes.js b/src/routes.js index 26dc4ab..3629d94 100644 --- a/src/routes.js +++ b/src/routes.js @@ -26,6 +26,7 @@ export const CONFIG = { DELETE_MANY: (collectionName) => `/v2/db/${collectionName}/bulk`, COUNT: (collectionName) => `/v2/db/${collectionName}/count`, DISTINCT: (collectionName) => `/v2/db/${collectionName}/distinct`, + RESPONSIBILITY: (collectionName) => `/v2/db/${collectionName}/responsibility`, }, FILES: { UPLOAD: (collectionName) => `/v2/db/${collectionName}/files`,