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

[_]: feat/add endpoint to decline invitations #165

Merged
merged 6 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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.44",
"version": "1.4.45",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
25 changes: 9 additions & 16 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ListAllSharedFoldersResponse,
ListPrivateSharedFoldersResponse,
ListShareLinksResponse,
PrivateSharedFolder,
SharedFolderUser,
ShareDomainsResponse,
ShareLink,
Expand All @@ -24,6 +23,7 @@ import {
RemoveUserRolePayload,
Role,
SharingInvite,
SharedFoldersInvitationsAsInvitedUserResponse,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { HttpClient } from '../../shared/http/client';
Expand Down Expand Up @@ -267,28 +267,17 @@ export class Share {
);
}

/**
* Get private folder data.
*
* @param {string} folderUUID - The UUID of the folder.
* @returns {Promise<{ data: PrivateSharedFolder }>} A promise containing the private folder data.
*/
public getPrivateSharedFolder(folderUUID: string): Promise<{ data: PrivateSharedFolder }> {
return this.client.get(`private-sharing/by-folder-id/${folderUUID}`, this.headers());
}

Comment on lines -270 to -279
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been deleted because the endpoint no longer works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think so. Now we use sharings/... instead of private-sharing/...

/**
* Update the role of a user on a folder.
*
* @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
* @param {string} options.folderUUID - The unique identifier of the folder.
* @param {string} options.roleId - The identifier of the role to assign to the user.
* @param {string} options.sharingId - The unique identifier of the user to whom we will update the role.
* @param {string} options.newRoleId - The new role Id.
* @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
*/
public updateUserRole({ folderUUID, roleId, newRoleId }: UpdateUserRolePayload): Promise<UpdateUserRoleResponse> {
public updateUserRole({ sharingId, newRoleId }: UpdateUserRolePayload): Promise<UpdateUserRoleResponse> {
return this.client.put(
`sharings/${folderUUID}/roles/${roleId}`,
`sharings/${sharingId}/role`,
{
roleId: newRoleId,
},
Expand Down Expand Up @@ -340,7 +329,7 @@ export class Share {
}: {
limit?: number;
offset?: number;
}): Promise<{ invites: any }> {
}): Promise<{ invites: SharedFoldersInvitationsAsInvitedUserResponse[] }> {
return this.client.get(`sharings/invites?limit=${limit}&offset=${offset}`, this.headers());
}

Expand Down Expand Up @@ -410,6 +399,10 @@ export class Share {
);
}

public declineSharedFolderInvite(invitationId: string): Promise<void> {
return this.client.delete(`sharings/invites/${invitationId}`, this.headers());
}

/**
* Fetches roles for sharing items.
*
Expand Down
87 changes: 50 additions & 37 deletions src/drive/share/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ export type GrantSharePrivilegesToUserResponse = { message: string };
export type UpdateUserRoleResponse = { message: string };

export type UpdateUserRolePayload = {
folderUUID: string;
roleId: string;
sharingId: string;
newRoleId: string;
};

Expand Down Expand Up @@ -211,6 +210,55 @@ export type Role = {

export type getSharedFolderUsersResponse = { users: SharedFolderUser[] };

export type SharedFoldersInvitationsAsInvitedUserResponse = {
createdAt: Date;
encryptionAlgorithm: string;
encryptionKey: string;
id: string;
invited: { avatar: string | null; email: string; lastname: string; name: string; uuid: string };
item: ItemInvitation;
itemId: string;
itemType: string;
roleId: string;
sharedWith: string;
type: string;
updatedAt: Date;
};

type ItemInvitation = {
bucket: string | null;
createdAt: Date;
deleted: boolean;
deletedAt: Date | null;
encryptVersion: string;
id: number;
name: string;
parent: null;
parentId: number;
plainName: string;
removed: boolean;
removedAt: Date | null;
size: number;
type: string;
updatedAt: Date;
user: { avatar: string | null; email: string; lastname: string; name: string; uuid: string } | null;
userId: number;
uuid: string;
};

export type FolderUserInfo = {
avatar: string | null;
email: string;
grantedFrom: string;
grantedFromPlainName: string;
id: number;
lastname: string;
name: string;
roleId: string;
roleName: string;
uuid: string;
};

export type SharingInvitation = {
id: number;
userId: string;
Expand Down Expand Up @@ -252,38 +300,3 @@ export type SharingInvite = {
createdAt: Date;
updatedAt: Date;
};

export type PrivateSharedFolder = {
id: string;
folderId: string;
ownerId: string;
sharedWith: string;
encryptionKey: string;
createdAt: string;
updatedAt: string;
folder: {
id: number;
uuid: string;
parentId: number;
parentUuid: string | null;
name: string;
bucket: string | null;
userId: number;
encryptVersion: string;
plainName: string | null;
deleted: boolean;
removed: boolean;
deletedAt: string | null;
createdAt: string;
updatedAt: string;
removedAt: string | null;
};
owner: {
uuid: string;
email: string;
name: string;
lastname: string;
avatar: string | null;
};
fileSize: number;
};
Loading