Skip to content

Commit

Permalink
feat: added public shared item info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Dec 19, 2023
1 parent 9f61060 commit 852e39d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
SharedFoldersInvitationsAsInvitedUserResponse,
CreateSharingPayload,
SharingMeta,
PublicSharedItemInfo,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { HttpClient } from '../../shared/http/client';
Expand Down Expand Up @@ -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<PublicSharedItemInfo>} A promise that returns data of the public shared item.
*/
public getPublicSharedItemInfo(sharingId: string): Promise<PublicSharedItemInfo> {
return this.client.get(`sharings/public/${sharingId}/item`, this.headers());
}

/**
* Request access to shared folder.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/drive/share/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions test/drive/share/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 852e39d

Please sign in to comment.