Skip to content

Commit

Permalink
Merge pull request #165 from internxt/feat/decline-invitations
Browse files Browse the repository at this point in the history
[_]: feat/add endpoint to decline invitations
  • Loading branch information
masterprog-cmd authored Sep 6, 2023
2 parents 00cf47d + 93ac3cc commit 2160209
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 54 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.45",
"version": "1.4.46",
"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());
}

/**
* 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;
};

0 comments on commit 2160209

Please sign in to comment.