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-954]: feat/add files to the shared list #172

Merged
merged 1 commit into from
Sep 14, 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.51",
"version": "1.4.52",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
36 changes: 28 additions & 8 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@ export class Share {
return this.client.get(`sharings/folders?page=${page}&perPage=${perPage}${orderByQueryParam}`, this.headers());
}

/**
* Fetches all shared files.
*
* @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').
* @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
*/
public getAllSharedFiles(
page = 0,
perPage = 50,
orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC',
): Promise<ListAllSharedFoldersResponse> {
const orderByQueryParam = orderBy ? `&orderBy=${orderBy}` : '';

return this.client.get(`sharings/files?page=${page}&perPage=${perPage}${orderByQueryParam}`, this.headers());
}

/**
* Get all users with access to a shared folder.
*
Expand Down Expand Up @@ -408,13 +426,13 @@ export class Share {
}): Promise<void> {
const headers = this.getRequestHeaders(token);

return this.client.post(
`sharings/invites/${invitationId}/accept`,
{
acceptInvite,
},
headers,
);
return this.client.post(
`sharings/invites/${invitationId}/accept`,
{
acceptInvite,
},
headers,
);
}

public declineSharedFolderInvite(invitationId: string, token?: string): Promise<void> {
Expand All @@ -433,11 +451,13 @@ export class Share {
}

public getAllAccessUsers({
itemType,
folderId,
}: {
itemType: string;
folderId: string;
}): Promise<Record<'users', any[]> | Record<'error', string>> {
return this.client.get(`sharings/shared-with/${folderId}`, this.headers());
return this.client.get(`sharings/shared-with/${itemType}/${folderId}`, this.headers());
}

/**
Expand Down
Loading