Skip to content

Commit

Permalink
[PB-550] fix get shared folder content
Browse files Browse the repository at this point in the history
  • Loading branch information
rafijv committed Aug 21, 2023
1 parent b0c7dec commit d8390fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
UpdateUserRolePayload,
UpdateUserRoleResponse,
UpdateShareLinkPayload,
ListSharedItemsResponse,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { HttpClient } from '../../shared/http/client';
Expand Down Expand Up @@ -243,18 +244,26 @@ export class Share {

/**
* Get shared folder content
* @param {string} sharedFolderId - The UUID of the shared folder.
* @param {string} type - The item type for the query folders/files
* @param {string} token - Key that enables invited users to navigate the folders
* @param {number} page - The page number for pagination.
* @param {number} perPage - The number of items per page for pagination.
* @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
*/
public getSharedFolderContent(
sharedFolderId: string,
token: string,
type: 'folders' | 'files',
token: string | null,
page = 0,
perPage = 50,
orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC',
): Promise<ListAllSharedFoldersResponse> {
): Promise<ListSharedItemsResponse> {
const orderByQueryParam = orderBy ? `&orderBy=${orderBy}` : '';

return this.client.get(
`private-sharing/items/${sharedFolderId}?token=${token}&page=${page}&perPage=${perPage}${orderByQueryParam}`,
// eslint-disable-next-line max-len
`private-sharing/items/${sharedFolderId}/${type}?token=${token}&page=${page}&perPage=${perPage}${orderByQueryParam}`,
this.headers(),
);
}
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 @@ -143,6 +143,12 @@ export type SharedFiles = {
uuid: string;
};

export type ListSharedItemsResponse = {
credentials: { networkPass: string; networkUser: string };
items: SharedFiles[] | SharedFolders[];
token: string;
};

export type ListAllSharedFoldersResponse = {
credentials: { networkPass: string; networkUser: string };
files: SharedFiles[];
Expand Down

0 comments on commit d8390fa

Please sign in to comment.