Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-550]: fix/get shared folder content #163

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading