@signalhousellc/sdk 1.0.38 → 1.0.41
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 +1 -1
- package/src/SignalHouseSDK.js +2 -0
- package/src/domains/Numbers.js +5 -2
- package/src/domains/Onboarding.js +39 -0
- package/src/domains/Users.js +204 -204
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -15,6 +15,7 @@ import { Groups } from "./domains/Groups.js";
|
|
|
15
15
|
import { Landings } from "./domains/Landings.js";
|
|
16
16
|
import { Messages } from "./domains/Messages.js";
|
|
17
17
|
import { Numbers } from "./domains/Numbers.js";
|
|
18
|
+
import { Onboarding } from "./domains/Onboarding.js";
|
|
18
19
|
import { Shortlinks } from "./domains/Shortlinks.js";
|
|
19
20
|
import { Subgroups } from "./domains/Subgroups.js";
|
|
20
21
|
import { Subscriptions } from "./domains/Subscriptions.js";
|
|
@@ -58,6 +59,7 @@ export class SignalHouseSDK {
|
|
|
58
59
|
this.landings = new Landings(client, multipartClient, this.enableAdmin);
|
|
59
60
|
this.messages = new Messages(client, multipartClient, this.enableAdmin);
|
|
60
61
|
this.numbers = new Numbers(client, this.enableAdmin);
|
|
62
|
+
this.onboarding = new Onboarding(client, this.enableAdmin);
|
|
61
63
|
this.shortlinks = new Shortlinks(client, this.enableAdmin);
|
|
62
64
|
this.subgroups = new Subgroups(client, this.enableAdmin);
|
|
63
65
|
this.subscriptions = new Subscriptions(client, this.enableAdmin);
|
package/src/domains/Numbers.js
CHANGED
|
@@ -93,7 +93,10 @@ export class Numbers {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* Purchase phone numbers by providing a list of phone numbers and the subgroup ID to assign them to
|
|
96
|
+
* Purchase phone numbers by providing a list of phone numbers and the subgroup ID to assign them to.
|
|
97
|
+
*
|
|
98
|
+
* Each requested number is queued and processed independently. Per-number success or failure is
|
|
99
|
+
* delivered via `NUMBER_PURCHASE_SUCCESSFUL` / `NUMBER_PURCHASE_FAILED` webhooks — not in this response.
|
|
97
100
|
* @async
|
|
98
101
|
* @roles api, admin, developer, billing, user
|
|
99
102
|
* @param {Object} params - The parameters for purchasing phone numbers
|
|
@@ -101,7 +104,7 @@ export class Numbers {
|
|
|
101
104
|
* @param {string} params.subgroupId - The ID of the subgroup to assign the purchased phone numbers to
|
|
102
105
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
103
106
|
* @throws {Error} Throws an error if the phoneNumbers or subgroupId parameter is missing
|
|
104
|
-
* @returns {Promise<Object>} A promise that resolves to
|
|
107
|
+
* @returns {Promise<Object>} A promise that resolves to `{ message }` once the request is queued.
|
|
105
108
|
*/
|
|
106
109
|
async purchasePhoneNumber({ phoneNumbers, subgroupId, options = {} }) {
|
|
107
110
|
this.client._require({ phoneNumbers, subgroupId });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class Onboarding {
|
|
2
|
+
constructor(client, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.enableAdmin = enableAdmin;
|
|
5
|
+
|
|
6
|
+
// Hidden Admin namespace INSIDE the domain
|
|
7
|
+
if (enableAdmin) {
|
|
8
|
+
this.admin = {
|
|
9
|
+
/**
|
|
10
|
+
* Get all onboarding records (one per group). Staff-only.
|
|
11
|
+
* @async
|
|
12
|
+
* @roles signalhouse
|
|
13
|
+
* @param {Object} [params] - Optional parameters
|
|
14
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
15
|
+
* @returns {Promise<Object>} - Array of onboarding records
|
|
16
|
+
*/
|
|
17
|
+
getOnboardings: async ({ options = {} } = {}) => {
|
|
18
|
+
return this.client(`/group/onboarding`, { method: "GET", ...options });
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get a single onboarding record by group ID. Staff-only.
|
|
23
|
+
* @async
|
|
24
|
+
* @roles signalhouse
|
|
25
|
+
* @param {Object} params
|
|
26
|
+
* @param {string} params.groupId - The group ID whose onboarding record to retrieve
|
|
27
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
28
|
+
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
29
|
+
* @returns {Promise<Object>} - The onboarding record
|
|
30
|
+
*/
|
|
31
|
+
getOnboarding: async ({ groupId, options = {} }) => {
|
|
32
|
+
this.client._require({ groupId });
|
|
33
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
34
|
+
return this.client(`/group/onboarding/${safeGroupId}`, { method: "GET", ...options });
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/domains/Users.js
CHANGED
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} CreateUserData
|
|
3
|
-
* @property {string} groupId - The ID of the group to which the user belongs (must start with "G" and be at least 8 characters long)
|
|
4
|
-
* @property {string} role - The role of the user (admin, developer, billing, user)
|
|
5
|
-
* @property {string} password - The password for the user (must be at least 8 characters long)
|
|
6
|
-
* @property {string} email - The email address of the user (must be a valid email format)
|
|
7
|
-
* @property {string} [firstName] - The first name of the user (optional)
|
|
8
|
-
* @property {string} [lastName] - The last name of the user (optional)
|
|
9
|
-
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
10
|
-
* @property {string} [phone] - The phone number of the user (optional)
|
|
11
|
-
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
12
|
-
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
13
|
-
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
14
|
-
* @property {string} [city] - The city of the user's address (optional)
|
|
15
|
-
* @property {string} [state] - The state of the user's address (optional)
|
|
16
|
-
* @property {string} [country] - The country of the user's address (optional)
|
|
17
|
-
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
18
|
-
* @property {string} [signupSource] - The source from which the user signed up (optional)
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} CreateServiceUserData
|
|
23
|
-
* @property {string} groupId - The ID of the group to which the service user belongs (required)
|
|
24
|
-
* @property {string} name - The name of the service user (required)
|
|
25
|
-
* @property {string} role - The role of the service user (admin, developer, billing, user) (required)
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} UpdateUserData
|
|
30
|
-
* @property {string} [role] - The role of the user (admin, developer, billing, user)
|
|
31
|
-
* @property {string} [email] - The email address of the user (must be a valid email format if provided)
|
|
32
|
-
* @property {string} [firstName] - The first name of the user (optional)
|
|
33
|
-
* @property {string} [lastName] - The last name of the user (optional)
|
|
34
|
-
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
35
|
-
* @property {string} [phone] - The phone number of the user (optional)
|
|
36
|
-
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
37
|
-
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
38
|
-
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
39
|
-
* @property {string} [city] - The city of the user's address (optional)
|
|
40
|
-
* @property {string} [state] - The state of the user's address (optional)
|
|
41
|
-
* @property {string} [country] - The country of the user's address (optional)
|
|
42
|
-
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
43
|
-
* @property {string} [status] - The status of the user (e.g., "active", "inactive")
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
export class Users {
|
|
47
|
-
constructor(client, enableAdmin) {
|
|
48
|
-
this.client = client;
|
|
49
|
-
this.enableAdmin = enableAdmin;
|
|
50
|
-
|
|
51
|
-
if (enableAdmin) {
|
|
52
|
-
this.admin = {
|
|
53
|
-
/**
|
|
54
|
-
* Get a list of users with optional filters.
|
|
55
|
-
* @roles signalhouse
|
|
56
|
-
* @param {Object} params - The parameters for getting users
|
|
57
|
-
* @param {string} [params.email] - Filter users by email (partial match)
|
|
58
|
-
* @param {string} [params.userType] - Filter users by type (user, service)
|
|
59
|
-
* @param {number} [params.page] - Page number for pagination
|
|
60
|
-
* @param {number} [params.limit] - Items per page
|
|
61
|
-
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
62
|
-
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
63
|
-
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
64
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
65
|
-
* @returns {Promise<Object>} - A promise that resolves to the list of users
|
|
66
|
-
*/
|
|
67
|
-
getUsers: async ({ email, userType, page, limit, search, sortBy, sortOrder, options = {} }) => {
|
|
68
|
-
const filters = { email, userType, page, limit, search, sortBy, sortOrder };
|
|
69
|
-
const queryString = this.client._getQueryString(filters);
|
|
70
|
-
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Create a new internal user (admin or service user) with the specified data.
|
|
75
|
-
* @roles signalhouse
|
|
76
|
-
* @param {Object} params - The parameters for creating an internal user
|
|
77
|
-
* @param {CreateServiceUserData} params.data - The data for the new internal user
|
|
78
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
79
|
-
* @returns {Promise<Object>} - A promise that resolves to the created internal user
|
|
80
|
-
*/
|
|
81
|
-
createInternalUser: async ({ data, options = {} }) => {
|
|
82
|
-
this.client._require({ data: data });
|
|
83
|
-
return this.client(`/user/signalhouse`, { method: "POST", body: data, ...options });
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get a list of users with optional filters
|
|
91
|
-
* @async
|
|
92
|
-
* @roles api, admin, self
|
|
93
|
-
* @param {Object} params - The parameters for getting users
|
|
94
|
-
* @param {string} [params.id] - Filter by user ID
|
|
95
|
-
* @param {string} [params.groupId] - Filter by group ID
|
|
96
|
-
* @param {string} [params.userType] - Filter by user type (user, service)
|
|
97
|
-
* @param {number} [params.page] - Page number for pagination
|
|
98
|
-
* @param {number} [params.limit] - Items per page
|
|
99
|
-
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
100
|
-
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
101
|
-
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
102
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
103
|
-
* @returns {Promise<Object>} - A promise that resolves to the list of users
|
|
104
|
-
*/
|
|
105
|
-
async getUsers({ id, groupId, userType, page, limit, search, sortBy, sortOrder, options = {} }) {
|
|
106
|
-
const filters = { id, groupId, userType, page, limit, search, sortBy, sortOrder };
|
|
107
|
-
const queryString = this.client._getQueryString(filters);
|
|
108
|
-
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Create a new user with the specified user data
|
|
113
|
-
* @async
|
|
114
|
-
* @roles api, admin
|
|
115
|
-
* @param {Object} params - The parameters for creating a user (see CreateUserData typedef for details)
|
|
116
|
-
* @param {CreateUserData} params.data - The data for the new user
|
|
117
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
118
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
119
|
-
* @returns {Promise<Object>} - A promise that resolves to the created user
|
|
120
|
-
*/
|
|
121
|
-
async createUser({ data, options = {} }) {
|
|
122
|
-
this.client._require({ data: data });
|
|
123
|
-
return this.client(`/user`, { method: "POST", body: data, ...options });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Create a new service user with the specified user data. Used for creating API keys and other non-human users.
|
|
128
|
-
* @async
|
|
129
|
-
* @roles admin, developer
|
|
130
|
-
* @param {Object} params - The parameters for creating a service user (see CreateServiceUserData typedef for details)
|
|
131
|
-
* @param {CreateServiceUserData} params.data - The data for the new service user
|
|
132
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
133
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
134
|
-
* @returns {Promise<Object>} - A promise that resolves to the created service user
|
|
135
|
-
*/
|
|
136
|
-
async createServiceUser({ data, options = {} }) {
|
|
137
|
-
this.client._require({ data: data });
|
|
138
|
-
return this.client(`/user/serviceuser`, { method: "POST", body: data, ...options });
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Update an existing user's information with the specified user data
|
|
143
|
-
* @async
|
|
144
|
-
* @roles api, admin, self
|
|
145
|
-
* @param {Object} params - The parameters for updating a user (see UpdateUserData typedef for details)
|
|
146
|
-
* @param {string} params.id - The ID of the user to update
|
|
147
|
-
* @param {UpdateUserData} params.data - The data to update for the user
|
|
148
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
149
|
-
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
150
|
-
* @returns {Promise<Object>} - A promise that resolves to the updated user
|
|
151
|
-
*/
|
|
152
|
-
async updateUser({ id, data, options = {} }) {
|
|
153
|
-
this.client._require({ id, data: data });
|
|
154
|
-
const safeId = encodeURIComponent(id);
|
|
155
|
-
return this.client(`/user/${safeId}`, { method: "PUT", body: data, ...options });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Delete a user by their ID (mark as inactive)
|
|
160
|
-
* @async
|
|
161
|
-
* @roles api, admin
|
|
162
|
-
* @param {Object} params - The parameters for deleting a user
|
|
163
|
-
* @param {string} params.id - The ID of the user to delete
|
|
164
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
165
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
166
|
-
* @returns {Promise<Object>} - A promise that resolves to the deleted user
|
|
167
|
-
*/
|
|
168
|
-
async deleteUser({ id, options = {} }) {
|
|
169
|
-
this.client._require({ id });
|
|
170
|
-
const safeId = encodeURIComponent(id);
|
|
171
|
-
return this.client(`/user/${safeId}`, { method: "DELETE", ...options });
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get notification preferences for a user
|
|
176
|
-
* @async
|
|
177
|
-
* @roles api, admin, self
|
|
178
|
-
* @param {Object} params
|
|
179
|
-
* @param {string} params.id - The ID of the user
|
|
180
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
181
|
-
* @returns {Promise<Object>} The response from the server
|
|
182
|
-
*/
|
|
183
|
-
async getNotificationPreferences({ id, options = {} }) {
|
|
184
|
-
this.client._require({ id });
|
|
185
|
-
const safeId = encodeURIComponent(id);
|
|
186
|
-
return this.client(`/user/${safeId}/notification-preferences`, { method: "GET", ...options });
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Update notification preferences for a user
|
|
191
|
-
* @async
|
|
192
|
-
* @roles api, admin, self
|
|
193
|
-
* @param {Object} params
|
|
194
|
-
* @param {string} params.id - The ID of the user
|
|
195
|
-
* @param {Array<{name: string, web: boolean, email: boolean}>} params.notificationPreferences - Array of notification preference objects
|
|
196
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
197
|
-
* @returns {Promise<Object>} The response from the server
|
|
198
|
-
*/
|
|
199
|
-
async updateNotificationPreferences({ id, notificationPreferences, options = {} }) {
|
|
200
|
-
this.client._require({ id, notificationPreferences });
|
|
201
|
-
const safeId = encodeURIComponent(id);
|
|
202
|
-
return this.client(`/user/${safeId}/notification-preferences`, { method: "PUT", body: { notificationPreferences }, ...options });
|
|
203
|
-
}
|
|
204
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} CreateUserData
|
|
3
|
+
* @property {string} groupId - The ID of the group to which the user belongs (must start with "G" and be at least 8 characters long)
|
|
4
|
+
* @property {string} role - The role of the user (admin, developer, billing, user)
|
|
5
|
+
* @property {string} password - The password for the user (must be at least 8 characters long)
|
|
6
|
+
* @property {string} email - The email address of the user (must be a valid email format)
|
|
7
|
+
* @property {string} [firstName] - The first name of the user (optional)
|
|
8
|
+
* @property {string} [lastName] - The last name of the user (optional)
|
|
9
|
+
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
10
|
+
* @property {string} [phone] - The phone number of the user (optional)
|
|
11
|
+
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
12
|
+
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
13
|
+
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
14
|
+
* @property {string} [city] - The city of the user's address (optional)
|
|
15
|
+
* @property {string} [state] - The state of the user's address (optional)
|
|
16
|
+
* @property {string} [country] - The country of the user's address (optional)
|
|
17
|
+
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
18
|
+
* @property {string} [signupSource] - The source from which the user signed up (optional)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} CreateServiceUserData
|
|
23
|
+
* @property {string} groupId - The ID of the group to which the service user belongs (required)
|
|
24
|
+
* @property {string} name - The name of the service user (required)
|
|
25
|
+
* @property {string} role - The role of the service user (admin, developer, billing, user) (required)
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} UpdateUserData
|
|
30
|
+
* @property {string} [role] - The role of the user (admin, developer, billing, user)
|
|
31
|
+
* @property {string} [email] - The email address of the user (must be a valid email format if provided)
|
|
32
|
+
* @property {string} [firstName] - The first name of the user (optional)
|
|
33
|
+
* @property {string} [lastName] - The last name of the user (optional)
|
|
34
|
+
* @property {string} [companyName] - The company name associated with the user (optional)
|
|
35
|
+
* @property {string} [phone] - The phone number of the user (optional)
|
|
36
|
+
* @property {string} [profileImageLink] - A URL to the user's profile image (optional, must be a valid URL format if provided)
|
|
37
|
+
* @property {string} [addressLine1] - The first line of the user's address (optional)
|
|
38
|
+
* @property {string} [addressLine2] - The second line of the user's address (optional)
|
|
39
|
+
* @property {string} [city] - The city of the user's address (optional)
|
|
40
|
+
* @property {string} [state] - The state of the user's address (optional)
|
|
41
|
+
* @property {string} [country] - The country of the user's address (optional)
|
|
42
|
+
* @property {string} [postalCode] - The postal code of the user's address (optional)
|
|
43
|
+
* @property {string} [status] - The status of the user (e.g., "active", "inactive")
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export class Users {
|
|
47
|
+
constructor(client, enableAdmin) {
|
|
48
|
+
this.client = client;
|
|
49
|
+
this.enableAdmin = enableAdmin;
|
|
50
|
+
|
|
51
|
+
if (enableAdmin) {
|
|
52
|
+
this.admin = {
|
|
53
|
+
/**
|
|
54
|
+
* Get a list of users with optional filters.
|
|
55
|
+
* @roles signalhouse
|
|
56
|
+
* @param {Object} params - The parameters for getting users
|
|
57
|
+
* @param {string} [params.email] - Filter users by email (partial match)
|
|
58
|
+
* @param {string} [params.userType] - Filter users by type (user, service)
|
|
59
|
+
* @param {number} [params.page] - Page number for pagination
|
|
60
|
+
* @param {number} [params.limit] - Items per page
|
|
61
|
+
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
62
|
+
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
63
|
+
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
64
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
65
|
+
* @returns {Promise<Object>} - A promise that resolves to the list of users
|
|
66
|
+
*/
|
|
67
|
+
getUsers: async ({ email, userType, page, limit, search, sortBy, sortOrder, options = {} }) => {
|
|
68
|
+
const filters = { email, userType, page, limit, search, sortBy, sortOrder };
|
|
69
|
+
const queryString = this.client._getQueryString(filters);
|
|
70
|
+
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create a new internal user (admin or service user) with the specified data.
|
|
75
|
+
* @roles signalhouse
|
|
76
|
+
* @param {Object} params - The parameters for creating an internal user
|
|
77
|
+
* @param {CreateServiceUserData} params.data - The data for the new internal user
|
|
78
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
79
|
+
* @returns {Promise<Object>} - A promise that resolves to the created internal user
|
|
80
|
+
*/
|
|
81
|
+
createInternalUser: async ({ data, options = {} }) => {
|
|
82
|
+
this.client._require({ data: data });
|
|
83
|
+
return this.client(`/user/signalhouse`, { method: "POST", body: data, ...options });
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get a list of users with optional filters
|
|
91
|
+
* @async
|
|
92
|
+
* @roles api, admin, self
|
|
93
|
+
* @param {Object} params - The parameters for getting users
|
|
94
|
+
* @param {string} [params.id] - Filter by user ID
|
|
95
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
96
|
+
* @param {string} [params.userType] - Filter by user type (user, service)
|
|
97
|
+
* @param {number} [params.page] - Page number for pagination
|
|
98
|
+
* @param {number} [params.limit] - Items per page
|
|
99
|
+
* @param {string} [params.search] - Search users by email (case-insensitive)
|
|
100
|
+
* @param {string} [params.sortBy] - Field to sort by (createdAt, email, activeGroupId, companyName, status, _id)
|
|
101
|
+
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
102
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
103
|
+
* @returns {Promise<Object>} - A promise that resolves to the list of users
|
|
104
|
+
*/
|
|
105
|
+
async getUsers({ id, groupId, userType, page, limit, search, sortBy, sortOrder, options = {} }) {
|
|
106
|
+
const filters = { id, groupId, userType, page, limit, search, sortBy, sortOrder };
|
|
107
|
+
const queryString = this.client._getQueryString(filters);
|
|
108
|
+
return this.client(`/user${queryString}`, { method: "GET", ...options });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Create a new user with the specified user data
|
|
113
|
+
* @async
|
|
114
|
+
* @roles api, admin
|
|
115
|
+
* @param {Object} params - The parameters for creating a user (see CreateUserData typedef for details)
|
|
116
|
+
* @param {CreateUserData} params.data - The data for the new user
|
|
117
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
118
|
+
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
119
|
+
* @returns {Promise<Object>} - A promise that resolves to the created user
|
|
120
|
+
*/
|
|
121
|
+
async createUser({ data, options = {} }) {
|
|
122
|
+
this.client._require({ data: data });
|
|
123
|
+
return this.client(`/user`, { method: "POST", body: data, ...options });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Create a new service user with the specified user data. Used for creating API keys and other non-human users.
|
|
128
|
+
* @async
|
|
129
|
+
* @roles admin, developer
|
|
130
|
+
* @param {Object} params - The parameters for creating a service user (see CreateServiceUserData typedef for details)
|
|
131
|
+
* @param {CreateServiceUserData} params.data - The data for the new service user
|
|
132
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
133
|
+
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
134
|
+
* @returns {Promise<Object>} - A promise that resolves to the created service user
|
|
135
|
+
*/
|
|
136
|
+
async createServiceUser({ data, options = {} }) {
|
|
137
|
+
this.client._require({ data: data });
|
|
138
|
+
return this.client(`/user/serviceuser`, { method: "POST", body: data, ...options });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Update an existing user's information with the specified user data
|
|
143
|
+
* @async
|
|
144
|
+
* @roles api, admin, self
|
|
145
|
+
* @param {Object} params - The parameters for updating a user (see UpdateUserData typedef for details)
|
|
146
|
+
* @param {string} params.id - The ID of the user to update
|
|
147
|
+
* @param {UpdateUserData} params.data - The data to update for the user
|
|
148
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
149
|
+
* @throws {Error} Throws an error if required fields in the data parameter are missing
|
|
150
|
+
* @returns {Promise<Object>} - A promise that resolves to the updated user
|
|
151
|
+
*/
|
|
152
|
+
async updateUser({ id, data, options = {} }) {
|
|
153
|
+
this.client._require({ id, data: data });
|
|
154
|
+
const safeId = encodeURIComponent(id);
|
|
155
|
+
return this.client(`/user/${safeId}`, { method: "PUT", body: data, ...options });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Delete a user by their ID (mark as inactive)
|
|
160
|
+
* @async
|
|
161
|
+
* @roles api, admin
|
|
162
|
+
* @param {Object} params - The parameters for deleting a user
|
|
163
|
+
* @param {string} params.id - The ID of the user to delete
|
|
164
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
165
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
166
|
+
* @returns {Promise<Object>} - A promise that resolves to the deleted user
|
|
167
|
+
*/
|
|
168
|
+
async deleteUser({ id, options = {} }) {
|
|
169
|
+
this.client._require({ id });
|
|
170
|
+
const safeId = encodeURIComponent(id);
|
|
171
|
+
return this.client(`/user/${safeId}`, { method: "DELETE", ...options });
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Get notification preferences for a user
|
|
176
|
+
* @async
|
|
177
|
+
* @roles api, admin, self
|
|
178
|
+
* @param {Object} params
|
|
179
|
+
* @param {string} params.id - The ID of the user
|
|
180
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
181
|
+
* @returns {Promise<Object>} The response from the server
|
|
182
|
+
*/
|
|
183
|
+
async getNotificationPreferences({ id, options = {} }) {
|
|
184
|
+
this.client._require({ id });
|
|
185
|
+
const safeId = encodeURIComponent(id);
|
|
186
|
+
return this.client(`/user/${safeId}/notification-preferences`, { method: "GET", ...options });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Update notification preferences for a user
|
|
191
|
+
* @async
|
|
192
|
+
* @roles api, admin, self
|
|
193
|
+
* @param {Object} params
|
|
194
|
+
* @param {string} params.id - The ID of the user
|
|
195
|
+
* @param {Array<{name: string, web: boolean, email: boolean}>} params.notificationPreferences - Array of notification preference objects
|
|
196
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
197
|
+
* @returns {Promise<Object>} The response from the server
|
|
198
|
+
*/
|
|
199
|
+
async updateNotificationPreferences({ id, notificationPreferences, options = {} }) {
|
|
200
|
+
this.client._require({ id, notificationPreferences });
|
|
201
|
+
const safeId = encodeURIComponent(id);
|
|
202
|
+
return this.client(`/user/${safeId}/notification-preferences`, { method: "PUT", body: { notificationPreferences }, ...options });
|
|
203
|
+
}
|
|
204
|
+
}
|