From 172b14f51b1da44cbf1656b4f261f3163364cf5b Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Thu, 4 Jul 2024 14:34:27 +0200 Subject: [PATCH] Added update name of items with uuid --- package.json | 2 +- src/drive/storage/index.ts | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f552e2b..5a8639e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/sdk", - "version": "1.4.90", + "version": "1.4.91", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/drive/storage/index.ts b/src/drive/storage/index.ts index 6c1a4fc..8dc4e48 100644 --- a/src/drive/storage/index.ts +++ b/src/drive/storage/index.ts @@ -129,6 +129,29 @@ export class Storage { ); } + /** + * Updates the name of a folder with the given UUID. + * + * @param {Object} payload - The payload containing the folder UUID and the new name. + * @param {string} payload.folderUuid - The UUID of the folder to update. + * @param {string} payload.name - The new name for the folder. + * @param {Token} [resourcesToken] - An optional token for authentication. + * @return {Promise} A promise that resolves when the folder name is successfully updated. + */ + public updateFolderNameWithUUID( + payload: { folderUuid: string; name: string }, + resourcesToken?: Token, + ): Promise { + const { folderUuid, name } = payload; + return this.client.put( + `/folders/${folderUuid}/meta`, + { + plainName: name, + }, + addResourcesTokenToHeaders(this.headers(), resourcesToken), + ); + } + /** * Fetches & returns the contents of a specific folder * @param folderId @@ -414,6 +437,26 @@ export class Storage { ); } + /** + * Updates the name of a file with the given UUID. + * + * @param {Object} payload - The payload containing the UUID and new name of the file. + * @param {string} payload.fileUuid - The UUID of the file. + * @param {string} payload.name - The new name of the file. + * @param {string} [resourcesToken] - The token for accessing resources. + * @return {Promise} - A Promise that resolves when the file name is successfully updated. + */ + public updateFileNameWithUUID(payload: { fileUuid: string; name: string }, resourcesToken?: Token): Promise { + const { fileUuid, name } = payload; + return this.client.put( + `/files/${fileUuid}/meta`, + { + plainName: name, + }, + addResourcesTokenToHeaders(this.headers(), resourcesToken), + ); + } + /** * Deletes a specific file entry * @param payload