Skip to content

Commit

Permalink
Merge pull request #244 from internxt/feat/modify-getFolderBuyUuid-to…
Browse files Browse the repository at this point in the history
…-get-the-paged-items

[PB-2376]: feat/add pagination to getFoldercontentByUuid endpoint
  • Loading branch information
xabg2 authored Sep 20, 2024
2 parents ed90920 + 7c4b1d3 commit 081b429
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 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.5.16",
"version": "1.5.17",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
27 changes: 21 additions & 6 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,36 @@ export class Storage {
*
* @param {string} folderUuid - The UUID of the folder.
* @param {boolean} [trash=false] - Whether to include trash items in the response.
* @param {boolean} [offset] - The position of the first file to return.
* @param {boolean} [limit] - The max number of files to be returned.
* @param {boolean} [workspacesToken] - Token for accessing workspaces.
* @return {[Promise<FetchFolderContentResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getFolderContentByUuid(
folderUuid: string,
public getFolderContentByUuid({
folderUuid,
trash = false,
workspacesToken?: string,
): [Promise<FetchFolderContentResponse>, RequestCanceler] {
const query = trash ? '/?trash=true' : '';
offset,
limit,
workspacesToken,
}: {
folderUuid: string;
trash?: boolean;
limit?: number;
offset?: number;
workspacesToken?: string;
}): [Promise<FetchFolderContentResponse>, RequestCanceler] {
const query = new URLSearchParams();
if (offset !== undefined) query.set('offset', String(offset));
if (limit !== undefined) query.set('limit', String(limit));
if (trash) query.set('trash', 'true');

const customHeaders = workspacesToken
? {
'x-internxt-workspace': workspacesToken,
}
: undefined;
const { promise, requestCanceler } = this.client.getCancellable<FetchFolderContentResponse>(
`/folders/content/${folderUuid}${query}`,
`/folders/content/${folderUuid}?${query}`,
this.headers(customHeaders),
);

Expand Down

0 comments on commit 081b429

Please sign in to comment.