diff --git a/docs/api/cozy-stack-client.md b/docs/api/cozy-stack-client.md
index c7376f77f9..dd81f3acd1 100644
--- a/docs/api/cozy-stack-client.md
+++ b/docs/api/cozy-stack-client.md
@@ -1769,6 +1769,7 @@ Implements the `DocumentCollection` API along with specific methods for
* [.getDiscoveryLink(sharingId, sharecode)](#SharingCollection+getDiscoveryLink) ⇒ string
* [.addRecipients(options)](#SharingCollection+addRecipients)
* [.revokeRecipient(sharing, recipientIndex)](#SharingCollection+revokeRecipient)
+ * [.revokeGroup(sharing, groupIndex)](#SharingCollection+revokeGroup)
* [.revokeSelf(sharing)](#SharingCollection+revokeSelf)
* [.revokeAllRecipients(sharing)](#SharingCollection+revokeAllRecipients)
@@ -1853,9 +1854,21 @@ Revoke only one recipient of the sharing.
| Param | Type | Description |
| --- | --- | --- |
-| sharing | object
| Sharing Object |
+| sharing | [Sharing
](#Sharing) | Sharing Object |
| recipientIndex | number
| Index of this recipient in the members array of the sharing |
+
+
+### sharingCollection.revokeGroup(sharing, groupIndex)
+Revoke only one group of the sharing.
+
+**Kind**: instance method of [SharingCollection
](#SharingCollection)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| sharing | [Sharing
](#Sharing) | Sharing Object |
+| groupIndex | number
| Index of this group in the groups array of the sharing |
+
### sharingCollection.revokeSelf(sharing)
@@ -1865,7 +1878,7 @@ Remove self from the sharing.
| Param | Type | Description |
| --- | --- | --- |
-| sharing | object
| Sharing Object |
+| sharing | [Sharing
](#Sharing) | Sharing Object |
@@ -1877,7 +1890,7 @@ from the owner's cozy
| Param | Type | Description |
| --- | --- | --- |
-| sharing | object
| Sharing Objects |
+| sharing | [Sharing
](#Sharing) | Sharing Objects |
diff --git a/packages/cozy-stack-client/src/SharingCollection.js b/packages/cozy-stack-client/src/SharingCollection.js
index 58be0e2dd1..a96e608fe1 100644
--- a/packages/cozy-stack-client/src/SharingCollection.js
+++ b/packages/cozy-stack-client/src/SharingCollection.js
@@ -18,21 +18,26 @@ const normalizeSharing = sharing => normalizeDoc(sharing, SHARING_DOCTYPE)
* @property {string=} update
* @property {string=} remove
*/
+
/**
* @typedef {object} Recipient An io.cozy.contact
*/
+
/**
* @typedef {object} Sharing An io.cozy.sharings document
*/
+
/**
* @typedef {object} SharingPolicy Define the add/update/remove policies for a sharing
* @property {string} add
* @property {string} update
* @property {string} remove
*/
+
/**
* @typedef {(undefined|'one-way'|'two-way')} SharingType Define how a document is synced between sharing's owner and receivers.
*/
+
/**
* @typedef {object} RelationshipItem Define a recipient that can be used as target of a sharing
* @property {string} id - Recipient's ID
@@ -205,7 +210,7 @@ class SharingCollection extends DocumentCollection {
/**
* Revoke only one recipient of the sharing.
*
- * @param {object} sharing Sharing Object
+ * @param {Sharing} sharing Sharing Object
* @param {number} recipientIndex Index of this recipient in the members array of the sharing
*/
revokeRecipient(sharing, recipientIndex) {
@@ -214,10 +219,24 @@ class SharingCollection extends DocumentCollection {
uri`/sharings/${sharing._id}/recipients/${recipientIndex}`
)
}
+
+ /**
+ * Revoke only one group of the sharing.
+ *
+ * @param {Sharing} sharing Sharing Object
+ * @param {number} groupIndex Index of this group in the groups array of the sharing
+ */
+ revokeGroup(sharing, groupIndex) {
+ return this.stackClient.fetchJSON(
+ 'DELETE',
+ uri`/sharings/${sharing._id}/groups/${groupIndex}`
+ )
+ }
+
/**
* Remove self from the sharing.
*
- * @param {object} sharing Sharing Object
+ * @param {Sharing} sharing Sharing Object
*/
revokeSelf(sharing) {
return this.stackClient.fetchJSON(
@@ -229,7 +248,7 @@ class SharingCollection extends DocumentCollection {
* Revoke the sharing for all the members. Must be called
* from the owner's cozy
*
- * @param {object} sharing Sharing Objects
+ * @param {Sharing} sharing Sharing Objects
*/
revokeAllRecipients(sharing) {
return this.stackClient.fetchJSON(
diff --git a/packages/cozy-stack-client/src/SharingCollection.spec.js b/packages/cozy-stack-client/src/SharingCollection.spec.js
index 14a71ae188..2d619eb175 100644
--- a/packages/cozy-stack-client/src/SharingCollection.spec.js
+++ b/packages/cozy-stack-client/src/SharingCollection.spec.js
@@ -449,6 +449,21 @@ describe('SharingCollection', () => {
})
})
+ describe('revokeGroup', () => {
+ beforeEach(() => {
+ client.fetch.mockReset()
+ client.fetchJSON.mockResolvedValue({ data: [] })
+ })
+
+ it('should call the right route', async () => {
+ await collection.revokeGroup(SHARING, 1)
+ expect(client.fetchJSON).toHaveBeenCalledWith(
+ 'DELETE',
+ `/sharings/${SHARING._id}/groups/1`
+ )
+ })
+ })
+
describe('addRecipients', () => {
beforeEach(() => {
client.fetch.mockReset()