Skip to content

Commit

Permalink
Merge pull request #163 from internxt/feat/PB-550-list-items-inside-s…
Browse files Browse the repository at this point in the history
…hared-folder

[PB-550]: fix/get shared folder content
  • Loading branch information
rafijv authored Aug 21, 2023
2 parents b0c7dec + 408e30d commit 3caf347
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@internxt/sdk",
"version": "1.4.42",
"version": "1.4.43",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
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 3caf347

Please sign in to comment.