Skip to content

Commit

Permalink
Merge pull request #213 from internxt/feature/PB-2082-invite-user-flow
Browse files Browse the repository at this point in the history
[PB-2082] feature/update workspaces endpoints
  • Loading branch information
rafijv authored Jul 3, 2024
2 parents 5327a8e + 69c8327 commit 9540b38
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 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.89",
"version": "1.4.90",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions src/workspaces/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,15 @@ describe('Workspaces service tests', () => {
const encryptionAlgorithm = 'aes-256-gcm';
const { client, headers } = clientAndHeaders();
const postCall = sinon.stub(httpClient, 'post').resolves();
const message = 'Test message';

await client.inviteMemberToWorkspace({
workspaceId,
invitedUserEmail,
spaceLimitBytes,
encryptedMnemonicInBase64,
encryptionAlgorithm,
message,
});

expect(postCall.firstCall.args).toEqual([
Expand All @@ -374,6 +376,7 @@ describe('Workspaces service tests', () => {
spaceLimit: spaceLimitBytes,
encryptionKey: encryptedMnemonicInBase64,
encryptionAlgorithm: 'aes-256-gcm',
message: message,
},
headers,
]);
Expand Down
28 changes: 27 additions & 1 deletion src/workspaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
WorkspaceSetupInfo,
WorkspaceTeamResponse,
WorkspacesResponse,
WorkspacePendingInvitations,
} from './types';

export class Workspaces {
Expand Down Expand Up @@ -76,7 +77,10 @@ export class Workspaces {
}

public getPendingInvites(): Promise<PendingInvitesResponse> {
return this.client.get<PendingInvitesResponse>('workspaces/invitations', this.headers());
const limitQuery = '?limit=25';
const offsetQuery = '&offset=0';
const query = `${limitQuery}${offsetQuery}`;
return this.client.get<PendingInvitesResponse>(`workspaces/invitations/${query}`, this.headers());
}

public validateWorkspaceInvite(inviteId: string): Promise<string> {
Expand Down Expand Up @@ -199,6 +203,7 @@ export class Workspaces {
spaceLimitBytes,
encryptedMnemonicInBase64,
encryptionAlgorithm = 'aes-256-gcm',
message,
}: InviteMemberBody): Promise<void> {
return this.client.post<void>(
`workspaces/${workspaceId}/members/invite`,
Expand All @@ -207,6 +212,7 @@ export class Workspaces {
spaceLimit: spaceLimitBytes,
encryptionKey: encryptedMnemonicInBase64,
encryptionAlgorithm,
message: message,
},
this.headers(),
);
Expand Down Expand Up @@ -366,6 +372,22 @@ export class Workspaces {
return [promise, requestCanceler];
}

public getWorkspacePendingInvitations(
workspaceId: string,
limit: number,
offset: number,
): Promise<WorkspacePendingInvitations[]> {
const limitQuery = `?limit=${limit}`;
const offsetQuery = `&offset=${offset}`;

const query = `${limitQuery}${offsetQuery}`;

return this.client.get<WorkspacePendingInvitations[]>(
`workspaces/${workspaceId}/invitations/${query}`,
this.headers(),
);
}

/**
* Creates a new sharing for a workspace item.
*
Expand All @@ -390,6 +412,10 @@ export class Workspaces {
);
}

public validateWorkspaceInvitation(inviteId: string): Promise<{ uuid: string }> {
return this.client.get<{ uuid: string }>(`workspaces/invitations/${inviteId}/validate`, this.headers());
}

public getWorkspaceTeamSharedFiles(
workspaceId: string,
teamId: string,
Expand Down
20 changes: 20 additions & 0 deletions src/workspaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export type InviteMemberBody = {
spaceLimitBytes: number;
encryptedMnemonicInBase64: string;
encryptionAlgorithm: string;
message: string;
};

interface Invite {
Expand Down Expand Up @@ -215,6 +216,25 @@ export interface CreateFolderPayload {
parentFolderUuid: string;
}

export type WorkspacePendingInvitations = {
id: string;
workspaceId: string;
invitedUser: string;
encryptionAlgorithm: string;
encryptionKey: string;
spaceLimit: string;
createdAt: Date;
updatedAt: Date;
user: {
name: string;
lastname: string;
email: string;
uuid: string;
avatar: string | null;
};
isGuessInvite: boolean;
};

export type ItemType = 'file' | 'folder';

export interface CreateWorkspaceSharingPayload {
Expand Down

0 comments on commit 9540b38

Please sign in to comment.