diff --git a/.gitignore b/.gitignore
index 5a12e7c92..08be92914 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,8 @@ yarn-error.log*
*.njsproj
*.sln
+/.pnpm-store/
+
.yarn/*
!.yarn/patches
!.yarn/releases
diff --git a/changelog/unreleased/enhancement-share-space-with-group b/changelog/unreleased/enhancement-share-space-with-group
new file mode 100644
index 000000000..87ff1224f
--- /dev/null
+++ b/changelog/unreleased/enhancement-share-space-with-group
@@ -0,0 +1,5 @@
+Enhancement: Share space with group
+
+We've added a helper to share a space with a group.
+
+https://github.com/owncloud/owncloud-sdk/pull/1207
diff --git a/src/helperFunctions.js b/src/helperFunctions.js
index 3382f1491..9f10392ae 100644
--- a/src/helperFunctions.js
+++ b/src/helperFunctions.js
@@ -31,7 +31,8 @@ class helpers {
this.OCS_SHARE_TYPE_GROUP = 1
this.OCS_SHARE_TYPE_LINK = 3
this.OCS_SHARE_TYPE_REMOTE = 6
- this.OCS_SHARE_TYPE_SPACE = 7
+ this.OCS_SHARE_TYPE_SPACE_USER = 7
+ this.OCS_SHARE_TYPE_SPACE_GROUP = 8
this.instance = null
this._authHeader = null
diff --git a/src/shareManagement.js b/src/shareManagement.js
index 5affd30df..e1fe72480 100644
--- a/src/shareManagement.js
+++ b/src/shareManagement.js
@@ -15,6 +15,7 @@ const { ShareInfo, USER_TYPE_GUEST, SHARE_TYPE_GUEST } = require('./shareInfo.js
*
shareFileWithUser
* shareSpaceWithUser
* shareFileWithGroup
+ * shareSpaceWithGroup
* getShares
* isShared
* getShare
@@ -143,9 +144,36 @@ class Shares {
* @returns {Promise.} string: error message, if any.
*/
shareSpaceWithUser (path, username, spaceId, optionalParams) {
+ return this.shareSpace(path, username, this.helpers.OCS_SHARE_TYPE_SPACE_USER, spaceId, optionalParams)
+ }
+
+ /**
+ * Shares a space with specified user
+ * @param {string} path path to the remote file share
+ * @param {string} groupName name of the group to share with
+ * @param {string} spaceId id of the space
+ * @param {object} optionalParams {permissions: integer, expirationDate: ISO Date, attributes: assoc array (at free disposal)}
+ * @returns {Promise.} instance of class ShareInfo
+ * @returns {Promise.} string: error message, if any.
+ */
+ shareSpaceWithGroup (path, groupName, spaceId, optionalParams) {
+ return this.shareSpace(path, groupName, this.helpers.OCS_SHARE_TYPE_SPACE_GROUP, spaceId, optionalParams)
+ }
+
+ /**
+ * Shares a space with specified user or group
+ * @param {string} path path to the remote file share
+ * @param {string} shareWith name of the user or group to share with
+ * @param {number} shareType share type for the new share
+ * @param {string} spaceId id of the space
+ * @param {object} optionalParams {permissions: integer, expirationDate: ISO Date, remoteUser: boolean, attributes: assoc array (at free disposal)}
+ * @returns {Promise.} instance of class ShareInfo
+ * @returns {Promise.} string: error message, if any.
+ */
+ shareSpace (path, shareWith, shareType, spaceId, optionalParams) {
let postData = {
- shareType: this.helpers.OCS_SHARE_TYPE_SPACE,
- shareWith: username,
+ shareType,
+ shareWith,
space_ref: spaceId
}