@fonoster/sdk 0.6.1 → 0.6.2

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.
Files changed (70) hide show
  1. package/README.md +2301 -169
  2. package/dist/node/Acls.d.ts +150 -0
  3. package/dist/node/Acls.js +227 -0
  4. package/dist/node/Agents.d.ts +163 -0
  5. package/dist/node/Agents.js +211 -0
  6. package/dist/node/ApiKeys.d.ts +120 -0
  7. package/dist/node/ApiKeys.js +178 -0
  8. package/dist/node/Applications.d.ts +31 -27
  9. package/dist/node/Applications.js +30 -26
  10. package/dist/node/Calls.d.ts +109 -0
  11. package/dist/node/Calls.js +165 -0
  12. package/dist/node/Credentials.d.ts +148 -0
  13. package/dist/node/Credentials.js +194 -0
  14. package/dist/node/Domains.d.ts +152 -0
  15. package/dist/node/Domains.js +198 -0
  16. package/dist/node/Numbers.d.ts +152 -0
  17. package/dist/node/Numbers.js +198 -0
  18. package/dist/node/Secrets.d.ts +144 -0
  19. package/dist/node/Secrets.js +190 -0
  20. package/dist/node/Trunks.d.ts +181 -0
  21. package/dist/node/Trunks.js +275 -0
  22. package/dist/node/Users.d.ts +132 -0
  23. package/dist/node/Users.js +169 -0
  24. package/dist/node/Workspaces.d.ts +195 -0
  25. package/dist/node/Workspaces.js +265 -0
  26. package/dist/node/client/AbstractClient.d.ts +16 -2
  27. package/dist/node/client/AbstractClient.js +0 -1
  28. package/dist/node/client/Client.d.ts +8 -0
  29. package/dist/node/client/Client.js +48 -0
  30. package/dist/node/client/types/AclsClient.d.ts +10 -0
  31. package/dist/node/client/types/AgentsClient.d.ts +10 -0
  32. package/dist/node/client/types/AgentsClient.js +2 -0
  33. package/dist/node/client/types/ApplicationsClient.d.ts +10 -0
  34. package/dist/node/client/types/ApplicationsClient.js +2 -0
  35. package/dist/node/client/types/CallsClient.d.ts +8 -0
  36. package/dist/node/client/types/CallsClient.js +2 -0
  37. package/dist/node/client/types/CredentialsClient.d.ts +10 -0
  38. package/dist/node/client/types/CredentialsClient.js +2 -0
  39. package/dist/node/client/types/DomainsClient.d.ts +10 -0
  40. package/dist/node/client/types/DomainsClient.js +2 -0
  41. package/dist/node/client/types/FonosterClient.d.ts +27 -0
  42. package/dist/node/client/types/FonosterClient.js +2 -0
  43. package/dist/node/client/types/IdentityClient.d.ts +24 -0
  44. package/dist/node/client/types/IdentityClient.js +2 -0
  45. package/dist/node/client/types/NumbersClient.d.ts +10 -0
  46. package/dist/node/client/types/NumbersClient.js +2 -0
  47. package/dist/node/client/types/SecretsClient.d.ts +10 -0
  48. package/dist/node/client/types/SecretsClient.js +2 -0
  49. package/dist/node/client/types/TrunksClient.d.ts +10 -0
  50. package/dist/node/client/types/TrunksClient.js +2 -0
  51. package/dist/node/client/types/common.d.ts +4 -0
  52. package/dist/node/client/types/common.js +2 -0
  53. package/dist/node/client/types/index.d.ts +6 -0
  54. package/dist/node/client/types/index.js +40 -0
  55. package/dist/node/generated/node/identity_pb.js +9 -9
  56. package/dist/node/generated/node/trunks_grpc_pb.js +8 -8
  57. package/dist/node/generated/node/trunks_pb.js +25 -25
  58. package/dist/node/generated/web/TrunksServiceClientPb.ts +5 -5
  59. package/dist/node/generated/web/identity_pb.d.ts +5 -5
  60. package/dist/node/generated/web/identity_pb.js +9 -9
  61. package/dist/node/generated/web/trunks_pb.d.ts +9 -9
  62. package/dist/node/generated/web/trunks_pb.js +25 -25
  63. package/dist/node/node.d.ts +11 -0
  64. package/dist/node/node.js +11 -0
  65. package/dist/node/tsconfig.node.tsbuildinfo +1 -1
  66. package/dist/web/fonoster.min.js +1 -1
  67. package/dist/web/index.esm.js +1 -1
  68. package/package.json +3 -3
  69. package/dist/node/client/types.d.ts +0 -26
  70. /package/dist/node/client/{types.js → types/AclsClient.js} +0 -0
@@ -0,0 +1,181 @@
1
+ import { BaseApiObject, CreateTrunkRequest, ListTrunksRequest, ListTrunksResponse, UpdateTrunkRequest } from "@fonoster/types";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Trunks, part of the Fonoster SIP Proxy subsystem,
5
+ * allows you to create, update, retrieve, and delete SIP Trunks for your deployment.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * async function main(request) {
13
+ * const apiKey = "your-api-key";
14
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
15
+ *
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId });
18
+ * await client.loginWithApiKey(apiKey);
19
+ *
20
+ * const trunks = new SDK.Trunks(client);
21
+ * const response = await trunks.createTrunk(request);
22
+ *
23
+ * console.log(response); // successful response
24
+ * } catch (e) {
25
+ * console.error(e); // an error occurred
26
+ * }
27
+ * }
28
+ *
29
+ * const request = {
30
+ * name: "My Trunk",
31
+ * inboundUri: "sip.company.fonoster.io"
32
+ * };
33
+ *
34
+ * main(request).catch(console.error);
35
+ */
36
+ declare class Trunks {
37
+ private client;
38
+ /**
39
+ * Constructs a new Trunks object.
40
+ *
41
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
42
+ * @see AbstractClient
43
+ * @see FonosterClient
44
+ */
45
+ constructor(client: FonosterClient);
46
+ /**
47
+ * Creates a new Trunk in the Workspace.
48
+ *
49
+ * @param {CreateTrunkRequest} request - The request object that contains the necessary information to create a new Trunk
50
+ * @param {string} request.name - The name of the Trunk
51
+ * @param {string} request.inboundUri - The inboundUri of the Trunk
52
+ * @param {boolean} request.sendRegister - The sendRegister of the Trunk
53
+ * @param {string} request.accessControlListRef - The accessControlListRef of the Trunk
54
+ * @param {string} request.inboundCredentialsRef - The inboundCredentialsRef of the Trunk
55
+ * @param {string} request.outboundCredentialsRef - The outboundCredentialsRef of the Trunk
56
+ * @param {TrunkUri[]} request.uris - The uris of the Trunk
57
+ * @param {string} request.uris[].host - The host of the Trunk
58
+ * @param {number} request.uris[].port - The port of the Trunk
59
+ * @param {Transport} request.uris[].transport - The transport of the Trunk
60
+ * @param {string} request.uris[].user - Optional user of the Trunk
61
+ * @param {number} request.uris[].weight - Optional weight of the Trunk
62
+ * @param {number} request.uris[].priority - Optional priority of the Trunk
63
+ * @param {boolean} request.uris[].enabled - Optional enabled of the Trunk
64
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Trunk
65
+ * @example
66
+ *
67
+ * const request = {
68
+ * name: "My Trunk",
69
+ * inboundUri: "sip.company.fonoster.io"
70
+ * sendRegister: true
71
+ * uris: [{
72
+ * host: "sip.company.fonoster.io",
73
+ * port: 5060,
74
+ * transport: "UDP",
75
+ * user: "user",
76
+ * weight: 0,
77
+ * priority: 0,
78
+ * enabled: true
79
+ * }]
80
+ * };
81
+ *
82
+ * const trunks = new SDK.Trunks(client); // Existing client object
83
+ *
84
+ * trunks.createTrunk(request)
85
+ * .then(console.log) // successful response
86
+ * .catch(console.error); // an error occurred
87
+ */
88
+ createTrunk(request: CreateTrunkRequest): Promise<BaseApiObject>;
89
+ /**
90
+ * Retrieves an existing Trunk in the Workspace.
91
+ *
92
+ * @param {string} ref - The reference of the Trunk to retrieve
93
+ * @return {Promise<Acl>} - The response object that contains the Trunk
94
+ * @example
95
+ *
96
+ * const ref = "00000000-0000-0000-0000-000000000000"
97
+ *
98
+ * const trunks = new SDK.Trunks(client); // Existing client object
99
+ *
100
+ * trunks.getTrunk(ref)
101
+ * .then(console.log) // successful response
102
+ * .catch(console.error); // an error occurred
103
+ */
104
+ getTrunk(ref: string): Promise<unknown>;
105
+ /**
106
+ * Updates an existing Trunk in the Workspace.
107
+ *
108
+ * @param {UpdateTrunkRequest} request - The request object that contains the necessary information to update an existing Trunk
109
+ * @param {string} request.ref - The reference of the Trunk to update
110
+ * @param {string} request.name - The name of the Trunk
111
+ * @param {boolean} request.sendRegister - The sendRegister of the Trunk
112
+ * @param {string} request.accessControlListRef - The accessControlListRef of the Trunk
113
+ * @param {string} request.inboundCredentialsRef - The inboundCredentialsRef of the Trunk
114
+ * @param {string} request.outboundCredentialsRef - The outboundCredentialsRef of the Trunk
115
+ * @param {TrunkUri[]} request.uris - The uris of the Trunk
116
+ * @param {string} request.uris[].host - The host of the Trunk
117
+ * @param {number} request.uris[].port - The port of the Trunk
118
+ * @param {Transport} request.uris[].transport - The transport of the Trunk
119
+ * @param {string} request.uris[].user - Optional user of the Trunk
120
+ * @param {number} request.uris[].weight - Optional weight of the Trunk
121
+ * @param {number} request.uris[].priority - Optional priority of the Trunk
122
+ * @param {boolean} request.uris[].enabled - Optional enabled of the Trunk
123
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Trunk
124
+ * @example
125
+ *
126
+ * const request = {
127
+ * ref: "00000000-0000-0000-0000-000000000000",
128
+ * name: "My Trunk",
129
+ * sendRegister: true
130
+ * uris: [{
131
+ * host: "sip.company.fonoster.io",
132
+ * port: 5060,
133
+ * transport: "UDP",
134
+ * user: "user",
135
+ * weight: 0,
136
+ * priority: 0,
137
+ * enabled: true
138
+ * }]
139
+ * };
140
+ */
141
+ updateTrunk(request: UpdateTrunkRequest): Promise<BaseApiObject>;
142
+ /**
143
+ * Retrieves a list of Trunks from a Workspace.
144
+ *
145
+ * @param {ListTrunksRequest} request - The request object that contains the necessary information to retrieve a list of Trunks
146
+ * @param {number} request.pageSize - The trunk of Trunks to retrieve
147
+ * @param {string} request.pageToken - The token to retrieve the next page of Trunks
148
+ * @return {Promise<ListTrunksResponse>} - The response object that contains the list of Trunks
149
+ * @example
150
+ *
151
+ * const request = {
152
+ * pageSize: 10,
153
+ * pageToken: "00000000-0000-0000-0000-000000000000"
154
+ * };
155
+ *
156
+ * const trunks = new SDK.Trunks(client); // Existing client object
157
+ *
158
+ * trunks.listTrunks(request)
159
+ * .then(console.log) // successful response
160
+ * .catch(console.error); // an error occurred
161
+ */
162
+ listTrunks(request: ListTrunksRequest): Promise<ListTrunksResponse>;
163
+ /**
164
+ * Deletes an existing Trunk from Fonoster.
165
+ * Note that this operation is irreversible.
166
+ *
167
+ * @param {string} ref - The reference of the Trunk to delete
168
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Trunk
169
+ * @example
170
+ *
171
+ * const ref = "00000000-0000-0000-0000-000000000000"
172
+ *
173
+ * const trunks = new SDK.Trunks(client); // Existing client object
174
+ *
175
+ * trunks.deleteTrunk(ref)
176
+ * .then(console.log) // successful response
177
+ * .catch(console.error); // an error occurred
178
+ */
179
+ deleteTrunk(ref: string): Promise<BaseApiObject>;
180
+ }
181
+ export { Trunks };
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Trunks = void 0;
4
+ const makeRpcRequest_1 = require("./client/makeRpcRequest");
5
+ const trunks_pb_1 = require("./generated/node/trunks_pb");
6
+ /**
7
+ * @classdesc Fonoster Trunks, part of the Fonoster SIP Proxy subsystem,
8
+ * allows you to create, update, retrieve, and delete SIP Trunks for your deployment.
9
+ * Note that an active Fonoster deployment is required.
10
+ *
11
+ * @example
12
+ *
13
+ * const SDK = require("@fonoster/sdk");
14
+ *
15
+ * async function main(request) {
16
+ * const apiKey = "your-api-key";
17
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
18
+ *
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId });
21
+ * await client.loginWithApiKey(apiKey);
22
+ *
23
+ * const trunks = new SDK.Trunks(client);
24
+ * const response = await trunks.createTrunk(request);
25
+ *
26
+ * console.log(response); // successful response
27
+ * } catch (e) {
28
+ * console.error(e); // an error occurred
29
+ * }
30
+ * }
31
+ *
32
+ * const request = {
33
+ * name: "My Trunk",
34
+ * inboundUri: "sip.company.fonoster.io"
35
+ * };
36
+ *
37
+ * main(request).catch(console.error);
38
+ */
39
+ class Trunks {
40
+ client;
41
+ /**
42
+ * Constructs a new Trunks object.
43
+ *
44
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
45
+ * @see AbstractClient
46
+ * @see FonosterClient
47
+ */
48
+ constructor(client) {
49
+ this.client = client;
50
+ }
51
+ /**
52
+ * Creates a new Trunk in the Workspace.
53
+ *
54
+ * @param {CreateTrunkRequest} request - The request object that contains the necessary information to create a new Trunk
55
+ * @param {string} request.name - The name of the Trunk
56
+ * @param {string} request.inboundUri - The inboundUri of the Trunk
57
+ * @param {boolean} request.sendRegister - The sendRegister of the Trunk
58
+ * @param {string} request.accessControlListRef - The accessControlListRef of the Trunk
59
+ * @param {string} request.inboundCredentialsRef - The inboundCredentialsRef of the Trunk
60
+ * @param {string} request.outboundCredentialsRef - The outboundCredentialsRef of the Trunk
61
+ * @param {TrunkUri[]} request.uris - The uris of the Trunk
62
+ * @param {string} request.uris[].host - The host of the Trunk
63
+ * @param {number} request.uris[].port - The port of the Trunk
64
+ * @param {Transport} request.uris[].transport - The transport of the Trunk
65
+ * @param {string} request.uris[].user - Optional user of the Trunk
66
+ * @param {number} request.uris[].weight - Optional weight of the Trunk
67
+ * @param {number} request.uris[].priority - Optional priority of the Trunk
68
+ * @param {boolean} request.uris[].enabled - Optional enabled of the Trunk
69
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Trunk
70
+ * @example
71
+ *
72
+ * const request = {
73
+ * name: "My Trunk",
74
+ * inboundUri: "sip.company.fonoster.io"
75
+ * sendRegister: true
76
+ * uris: [{
77
+ * host: "sip.company.fonoster.io",
78
+ * port: 5060,
79
+ * transport: "UDP",
80
+ * user: "user",
81
+ * weight: 0,
82
+ * priority: 0,
83
+ * enabled: true
84
+ * }]
85
+ * };
86
+ *
87
+ * const trunks = new SDK.Trunks(client); // Existing client object
88
+ *
89
+ * trunks.createTrunk(request)
90
+ * .then(console.log) // successful response
91
+ * .catch(console.error); // an error occurred
92
+ */
93
+ async createTrunk(request) {
94
+ const client = this.client.getTrunksClient();
95
+ const createTrunkRequest = new trunks_pb_1.CreateTrunkRequest();
96
+ createTrunkRequest.setName(request.name);
97
+ createTrunkRequest.setInboundUri(request.inboundUri);
98
+ createTrunkRequest.setSendRegister(request.sendRegister);
99
+ // createAclRequest.setAccessControlListRef(?);
100
+ // createAclRequest.setInboundCredentialsRef(?);
101
+ // createAclRequest.setOutboundCredentialsRef(?);
102
+ // request.uris.forEach(uri => {
103
+ // const uri = new CreateTrunkRequestPB.Uris();
104
+ // createTrunkRequest.addUris(uri);
105
+ // }
106
+ return new Promise((resolve, reject) => {
107
+ client.createTrunk(createTrunkRequest, this.client.getMetadata(), (err, response) => {
108
+ if (err) {
109
+ reject(err);
110
+ return;
111
+ }
112
+ resolve(response.toObject());
113
+ });
114
+ });
115
+ }
116
+ /**
117
+ * Retrieves an existing Trunk in the Workspace.
118
+ *
119
+ * @param {string} ref - The reference of the Trunk to retrieve
120
+ * @return {Promise<Acl>} - The response object that contains the Trunk
121
+ * @example
122
+ *
123
+ * const ref = "00000000-0000-0000-0000-000000000000"
124
+ *
125
+ * const trunks = new SDK.Trunks(client); // Existing client object
126
+ *
127
+ * trunks.getTrunk(ref)
128
+ * .then(console.log) // successful response
129
+ * .catch(console.error); // an error occurred
130
+ */
131
+ async getTrunk(ref) {
132
+ const client = this.client.getTrunksClient();
133
+ const getTrunkRequest = new trunks_pb_1.GetTrunkRequest();
134
+ getTrunkRequest.setRef(ref);
135
+ return new Promise((resolve, reject) => {
136
+ client.getTrunk(getTrunkRequest, this.client.getMetadata(), (err, response) => {
137
+ if (err) {
138
+ reject(err);
139
+ return;
140
+ }
141
+ resolve(response.toObject());
142
+ });
143
+ });
144
+ }
145
+ /**
146
+ * Updates an existing Trunk in the Workspace.
147
+ *
148
+ * @param {UpdateTrunkRequest} request - The request object that contains the necessary information to update an existing Trunk
149
+ * @param {string} request.ref - The reference of the Trunk to update
150
+ * @param {string} request.name - The name of the Trunk
151
+ * @param {boolean} request.sendRegister - The sendRegister of the Trunk
152
+ * @param {string} request.accessControlListRef - The accessControlListRef of the Trunk
153
+ * @param {string} request.inboundCredentialsRef - The inboundCredentialsRef of the Trunk
154
+ * @param {string} request.outboundCredentialsRef - The outboundCredentialsRef of the Trunk
155
+ * @param {TrunkUri[]} request.uris - The uris of the Trunk
156
+ * @param {string} request.uris[].host - The host of the Trunk
157
+ * @param {number} request.uris[].port - The port of the Trunk
158
+ * @param {Transport} request.uris[].transport - The transport of the Trunk
159
+ * @param {string} request.uris[].user - Optional user of the Trunk
160
+ * @param {number} request.uris[].weight - Optional weight of the Trunk
161
+ * @param {number} request.uris[].priority - Optional priority of the Trunk
162
+ * @param {boolean} request.uris[].enabled - Optional enabled of the Trunk
163
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Trunk
164
+ * @example
165
+ *
166
+ * const request = {
167
+ * ref: "00000000-0000-0000-0000-000000000000",
168
+ * name: "My Trunk",
169
+ * sendRegister: true
170
+ * uris: [{
171
+ * host: "sip.company.fonoster.io",
172
+ * port: 5060,
173
+ * transport: "UDP",
174
+ * user: "user",
175
+ * weight: 0,
176
+ * priority: 0,
177
+ * enabled: true
178
+ * }]
179
+ * };
180
+ */
181
+ async updateTrunk(request) {
182
+ const client = this.client.getTrunksClient();
183
+ const updateTrunkRequest = new trunks_pb_1.UpdateTrunkRequest();
184
+ updateTrunkRequest.setRef(request.ref);
185
+ updateTrunkRequest.setName(request.name);
186
+ updateTrunkRequest.setSendRegister(request.sendRegister);
187
+ // updateAclRequest.setAccessControlListRef(?);
188
+ // updateAclRequest.setInboundCredentialsRef(?);
189
+ // updateAclRequest.setOutboundCredentialsRef(?);
190
+ // request.uris.forEach(uri => {
191
+ // const uri = new UpdateTrunkRequestPB.Uris();
192
+ // updateTrunkRequest.addUris(uri);
193
+ // }
194
+ return new Promise((resolve, reject) => {
195
+ client.updateTrunk(updateTrunkRequest, this.client.getMetadata(), (err, response) => {
196
+ if (err) {
197
+ reject(err);
198
+ return;
199
+ }
200
+ resolve(response.toObject());
201
+ });
202
+ });
203
+ }
204
+ /**
205
+ * Retrieves a list of Trunks from a Workspace.
206
+ *
207
+ * @param {ListTrunksRequest} request - The request object that contains the necessary information to retrieve a list of Trunks
208
+ * @param {number} request.pageSize - The trunk of Trunks to retrieve
209
+ * @param {string} request.pageToken - The token to retrieve the next page of Trunks
210
+ * @return {Promise<ListTrunksResponse>} - The response object that contains the list of Trunks
211
+ * @example
212
+ *
213
+ * const request = {
214
+ * pageSize: 10,
215
+ * pageToken: "00000000-0000-0000-0000-000000000000"
216
+ * };
217
+ *
218
+ * const trunks = new SDK.Trunks(client); // Existing client object
219
+ *
220
+ * trunks.listTrunks(request)
221
+ * .then(console.log) // successful response
222
+ * .catch(console.error); // an error occurred
223
+ */
224
+ async listTrunks(request) {
225
+ const client = this.client.getTrunksClient();
226
+ const listTrunksRequest = new trunks_pb_1.ListTrunksRequest();
227
+ listTrunksRequest.setPageSize(request.pageSize);
228
+ listTrunksRequest.setPageToken(request.pageToken);
229
+ return new Promise((resolve, reject) => {
230
+ client.listTrunks(listTrunksRequest, this.client.getMetadata(), (err, response) => {
231
+ if (err) {
232
+ reject(err);
233
+ return;
234
+ }
235
+ const items = response.getItemsList().map((item) => {
236
+ const obj = item.toObject();
237
+ return {
238
+ ...obj
239
+ };
240
+ });
241
+ resolve({
242
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
243
+ items: items,
244
+ nextPageToken: response.getNextPageToken()
245
+ });
246
+ });
247
+ });
248
+ }
249
+ /**
250
+ * Deletes an existing Trunk from Fonoster.
251
+ * Note that this operation is irreversible.
252
+ *
253
+ * @param {string} ref - The reference of the Trunk to delete
254
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Trunk
255
+ * @example
256
+ *
257
+ * const ref = "00000000-0000-0000-0000-000000000000"
258
+ *
259
+ * const trunks = new SDK.Trunks(client); // Existing client object
260
+ *
261
+ * trunks.deleteTrunk(ref)
262
+ * .then(console.log) // successful response
263
+ * .catch(console.error); // an error occurred
264
+ */
265
+ async deleteTrunk(ref) {
266
+ const applicationsClient = this.client.getTrunksClient();
267
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
268
+ method: applicationsClient.deleteTrunk.bind(applicationsClient),
269
+ requestPBObjectConstructor: trunks_pb_1.DeleteTrunkRequest,
270
+ metadata: this.client.getMetadata(),
271
+ request: { ref }
272
+ });
273
+ }
274
+ }
275
+ exports.Trunks = Trunks;
@@ -0,0 +1,132 @@
1
+ import { BaseApiObject, CreateUserRequest, UpdateUserRequest, User } from "@fonoster/types";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Users, part of the Fonoster Identity subsystem,
5
+ * allows you to create, update, retrieve, and delete a Users in the system.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * async function main(request) {
13
+ * const apiKey = "your-api-key";
14
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
15
+ *
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId });
18
+ * await client.loginWithApiKey(apiKey);
19
+ *
20
+ * const users = new SDK.Users(client);
21
+ * const response = await users.createUser(request);
22
+ *
23
+ * console.log(response); // successful response
24
+ * } catch (e) {
25
+ * console.error(e); // an error occurred
26
+ * }
27
+ * }
28
+ *
29
+ * const request = {
30
+ * name: "John Doe",
31
+ * email: "john.doe@example.com",
32
+ * password: "password",
33
+ * avatar: "https://example.com/avatar.jpg"
34
+ * };
35
+ *
36
+ * main(request).catch(console.error);
37
+ */
38
+ declare class Users {
39
+ private client;
40
+ /**
41
+ * Constructs a new Users object.
42
+ *
43
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
44
+ * @see AbstractClient
45
+ * @see FonosterClient
46
+ */
47
+ constructor(client: FonosterClient);
48
+ /**
49
+ * Creates a new User in the Workspace.
50
+ *
51
+ * @param {CreateUserRequest} request - The request object that contains the necessary information to create a new User
52
+ * @param {string} request.name - The name of the User
53
+ * @param {string} request.email - The email of the User
54
+ * @param {string} request.password - The password of the User
55
+ * @param {string} request.avatar - The avatar of the User
56
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created User
57
+ * @example
58
+ *
59
+ * const request = {
60
+ * name: "John Doe",
61
+ * email: "john.doe@example.com",
62
+ * password: "password",
63
+ * avatar: "https://example.com/avatar.jpg"
64
+ * };
65
+ *
66
+ * const users = new SDK.Users(client); // Existing client object
67
+ *
68
+ * users.createUser(request)
69
+ * .then(console.log) // successful response
70
+ * .catch(console.error); // an error occurred
71
+ */
72
+ createUser(request: CreateUserRequest): Promise<BaseApiObject>;
73
+ /**
74
+ * Retrieves an existing User in the Workspace.
75
+ *
76
+ * @param {string} ref - The reference of the User to retrieve
77
+ * @return {Promise<Acl>} - The response object that contains the User
78
+ * @example
79
+ *
80
+ * const ref = "00000000-0000-0000-0000-000000000000"
81
+ *
82
+ * const users = new SDK.Users(client); // Existing client object
83
+ *
84
+ * users.getUser(ref)
85
+ * .then(console.log) // successful response
86
+ * .catch(console.error); // an error occurred
87
+ */
88
+ getUser(ref: string): Promise<User>;
89
+ /**
90
+ * Updates an existing User in the Workspace.
91
+ *
92
+ * @param {UpdateUserRequest} request - The request object that contains the necessary information to update a User
93
+ * @param {string} request.ref - The reference of the User to update
94
+ * @param {string} request.name - The name of the User
95
+ * @param {string} request.password - The password of the User
96
+ * @param {string} request.avatar - The avatar of the User
97
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated User
98
+ * @example
99
+ *
100
+ * const request = {
101
+ * ref: "00000000-0000-0000-0000-000000000000",
102
+ * name: "John Doe",
103
+ * password: "password",
104
+ * avatar: "https://example.com/avatar.jpg"
105
+ * };
106
+ *
107
+ * const users = new SDK.Users(client); // Existing client object
108
+ *
109
+ * users.updateUser(request)
110
+ * .then(console.log) // successful response
111
+ * .catch(console.error); // an error occurred
112
+ */
113
+ updateUser(request: UpdateUserRequest): Promise<BaseApiObject>;
114
+ /**
115
+ * Deletes an existing User from Fonoster.
116
+ * Note that this operation is irreversible.
117
+ *
118
+ * @param {string} ref - The reference of the User to delete
119
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted User
120
+ * @example
121
+ *
122
+ * const ref = "00000000-0000-0000-0000-000000000000"
123
+ *
124
+ * const users = new SDK.Users(client); // Existing client object
125
+ *
126
+ * users.deleteUser(ref)
127
+ * .then(console.log) // successful response
128
+ * .catch(console.error); // an error occurred
129
+ */
130
+ deleteUser(ref: string): Promise<BaseApiObject>;
131
+ }
132
+ export { Users };