@open-xchange/soap-client 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/soap-client",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "SOAP client for OX App Suite",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2,10 +2,12 @@ import * as contextService from './context.js'
2
2
  import * as userService from './user.js'
3
3
  import { getFilestorageId } from './util.js'
4
4
  import * as secondaryAccountService from '../secondaryAccount.js'
5
+ import * as sharedAccountService from '../sharedAccount.js'
5
6
 
6
7
  export {
7
8
  contextService,
8
9
  userService,
9
10
  secondaryAccountService,
11
+ sharedAccountService,
10
12
  getFilestorageId
11
13
  }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
3
+ * @license AGPL-3.0
4
+ *
5
+ * This code is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
17
+ *
18
+ * Any use of the work other than as authorized under this license or copyright law is prohibited.
19
+ */
20
+
21
+ import { createClientAsync } from '../soap.js'
22
+
23
+ const OXSharedAccountService = createClientAsync('OXSharedAccountService')
24
+
25
+ /**
26
+ * Creates a shared account using the OX Shared Account Service
27
+ *
28
+ * @param {Object} context - The context object where the account will be created
29
+ * @param {Object} sharedAccountData - The data for the shared account to be created
30
+ * @returns {Promise<Object>} The created shared account object
31
+ * @throws {Error} If the shared account creation fails
32
+ */
33
+ export async function create (context, sharedAccountData) {
34
+ return (await OXSharedAccountService).createAsync({
35
+ ctx: { id: context.id },
36
+ sharedAccountData, // display_name, given_name, imapServer, language, mailenabled, name, sur_name, primaryEmail, email1, smtpServer, timezone, password
37
+ auth: context.admin
38
+ })
39
+ }
40
+
41
+ /**
42
+ * Add users and groups with specified permissions and capabilities to an existing shared account using the OX Shared Account Service.
43
+ *
44
+ * @param {Object} context - The context of the users and groups
45
+ * @param {Object} sharedAccountContext - The context of the shared account
46
+ * @param {Object} sharedAccountData - The shared account
47
+ * @param {Object} mailConfig - The mail configuration (permissionLevel, grantedCapability, deniedCapability)
48
+ * @param {Object} calendarConfig - The calendar configuration (permissionLevel, grantedCapability, deniedCapability)
49
+ * @param {Object[]} users - The users to be added to the shared account
50
+ * @param {Object[]} groups - The groups to be added to the shared account
51
+ * @returns {Promise<Object>} The shared account object
52
+ * @throws {Error} If the creation of the shared account permissions fails
53
+ */
54
+ export async function createSharedAccountPermissions (context, sharedAccountContext, sharedAccountData, mailConfig, calendarConfig, users = [], groups = []) {
55
+ return (await OXSharedAccountService).createSharedAccountPermissionsAsync({
56
+ ctx: { id: context.id },
57
+ groups,
58
+ users: users.map(user => { return { id: user.userdata.id } }),
59
+ mailConfig,
60
+ calendarConfig,
61
+ sharedAccountCtx: { id: sharedAccountContext.id },
62
+ sharedAccount: { id: sharedAccountData.id },
63
+ auth: context.admin
64
+ })
65
+ }
66
+
67
+ /**
68
+ * List all shared accounts in the specified context
69
+ *
70
+ * @param {Object} context - The context object whose shared account will be listed
71
+ * @param {*} pattern - An optional search pattern for the contexts
72
+ * @returns {Promise<Object[]>} The list of shared account objects
73
+ */
74
+ export async function list (context, pattern = '*') {
75
+ return (await OXSharedAccountService).listAsync({
76
+ ctx: { id: context.id },
77
+ search_pattern: pattern,
78
+ auth: context.admin
79
+ })
80
+ }
81
+
82
+ /**
83
+ * Get all data of a specified shared account in the specified context
84
+ *
85
+ * @param {*} context - The context where the shared account exists
86
+ * @param {*} sharedAccountData - The requested shared account
87
+ * @returns {Promise<Object>} The shared account object
88
+ */
89
+ export async function getData (context, sharedAccountData) {
90
+ return (await OXSharedAccountService).getDataAsync({
91
+ ctx: { id: context.id },
92
+ sharedAccount: { id: sharedAccountData.id },
93
+ auth: context.admin
94
+ })
95
+ }
96
+
97
+ /**
98
+ * Remove a specified shared account in the specified context
99
+ *
100
+ * @param {*} context - The context object where the account will be removed
101
+ * @param {*} sharedAccountData - The shared account to be removed
102
+ * @returns {Promise<void>}
103
+ */
104
+ export async function remove (context, sharedAccountData) {
105
+ return (await OXSharedAccountService).deleteAsync({
106
+ ctx: { id: context.id },
107
+ sharedAccount: { id: sharedAccountData.id },
108
+ auth: context.admin
109
+ })
110
+ }