From 852e39d0775a1059e0d388ddbfcaf75545cfd957 Mon Sep 17 00:00:00 2001 From: Andres Pinto Date: Tue, 19 Dec 2023 01:26:12 -0400 Subject: [PATCH] feat: added public shared item info endpoint --- src/drive/share/index.ts | 10 ++++++++++ src/drive/share/types.ts | 6 ++++++ test/drive/share/index.test.ts | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/drive/share/index.ts b/src/drive/share/index.ts index 12a005aa..edb21066 100644 --- a/src/drive/share/index.ts +++ b/src/drive/share/index.ts @@ -26,6 +26,7 @@ import { SharedFoldersInvitationsAsInvitedUserResponse, CreateSharingPayload, SharingMeta, + PublicSharedItemInfo, } from './types'; import { ApiSecurity, ApiUrl, AppDetails } from '../../shared'; import { HttpClient } from '../../shared/http/client'; @@ -466,6 +467,15 @@ export class Share { return this.client.delete(`sharings/${sharingId}/password`, this.headers()); } + /** + * Get public information of the item shared. + * @param {string} sharingId - id of sharing. + * @returns {Promise} A promise that returns data of the public shared item. + */ + public getPublicSharedItemInfo(sharingId: string): Promise { + return this.client.get(`sharings/public/${sharingId}/item`, this.headers()); + } + /** * Request access to shared folder. */ diff --git a/src/drive/share/types.ts b/src/drive/share/types.ts index fdfa0d94..e607ccca 100644 --- a/src/drive/share/types.ts +++ b/src/drive/share/types.ts @@ -178,6 +178,12 @@ export type CreateSharingPayload = { encryptedPassword?: string; }; +export type PublicSharedItemInfo = { + plainName: string; + size: number; + type: string; +}; + export type AcceptInvitationToSharedFolderPayload = { encryptionKey: string; encryptionAlgorithm: string; diff --git a/test/drive/share/index.test.ts b/test/drive/share/index.test.ts index 1eb47068..1425c754 100644 --- a/test/drive/share/index.test.ts +++ b/test/drive/share/index.test.ts @@ -234,6 +234,30 @@ describe('# share service tests', () => { }); }); + describe('get public shared item info', () => { + it('Should be called with sharingId and return basic info', async () => { + // Arrange + const callStub = sinon.stub(httpClient, 'get').resolves({ + plainName: 'anyname', + size: 30, + type: 'pdf', + }); + const { client, headers } = clientAndHeadersWithToken(); + const mockUuid = '550e8400-e29b-41d4-a716-446655440000'; + + // Act + const body = await client.getPublicSharedItemInfo(mockUuid); + + // Assert + expect(callStub.firstCall.args).toEqual([`sharings/public/${mockUuid}/item`, headers]); + expect(body).toEqual({ + plainName: 'anyname', + size: 30, + type: 'pdf', + }); + }); + }); + describe('get shares list', () => { it('Should be called with right arguments & return content', async () => { // Arrange