Skip to content

Commit

Permalink
Merge pull request #177 from internxt/feat/update-sharing-type
Browse files Browse the repository at this point in the history
[PB-995]: feat/add sharing update and get sharing type endpoint
  • Loading branch information
CandelR authored Nov 3, 2023
2 parents ffb5c30 + a633f2a commit c93b4d3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
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.55",
"version": "1.4.56",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
42 changes: 42 additions & 0 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,48 @@ export class Share {
);
}

/**
* Change Sharing Mode.
* @param {string} options.itemType - folder | file
* @param {string} options.itemId - id of folder or file
* @param {string} options.sharingType - New Sharing type.
* @returns {Promise<void>} A promise that resolves when sharing mode has been updated.
*/

public updateSharingType({
itemId,
itemType,
sharingType,
}: {
itemId: string;
itemType: string;
sharingType: string;
}): Promise<void> {
const headers = this.headers();

return this.client.put(
`sharings/${itemType}/${itemId}/type`,
{
sharingType,
},
headers,
);
}

/**
* Get Sharing type
* @param {string} options.itemType - folder | file
* @param {string} options.itemId - id of folder or file
* @returns {Promise<SharingMeta>} A promise that returns the sharing data.
*/

public getSharingType({ itemId, itemType }: { itemId: string; itemType: string }): Promise<SharingMeta> {
const headers = this.headers();

return this.client.get(`sharings/${itemType}/${itemId}/type`, headers);
}

public declineSharedFolderInvite(invitationId: string, token?: string): Promise<void> {
const headers = this.getRequestHeaders(token);
return this.client.delete(`sharings/invites/${invitationId}`, headers);
Expand Down
2 changes: 2 additions & 0 deletions src/drive/share/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type ShareFolderWithUserPayload = {
encryptionKey?: string;
encryptionAlgorithm?: string;
roleId: string;
persistPreviousSharing?: boolean;
};

export type CreateSharingPayload = {
Expand All @@ -173,6 +174,7 @@ export type CreateSharingPayload = {
encryptionKey: string;
encryptionAlgorithm: string;
encryptedCode: string;
persistPreviousSharing?: boolean;
};

export type AcceptInvitationToSharedFolderPayload = {
Expand Down

0 comments on commit c93b4d3

Please sign in to comment.