@fonoster/sdk 0.7.42 → 0.7.44

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/README.md CHANGED
@@ -157,12 +157,13 @@ Constructs a new Acls object.
157
157
  const SDK = require("@fonoster/sdk");
158
158
 
159
159
  async function main(request) {
160
- const API_KEY = "your-api-key";
161
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
160
+ const apiKey = "your-api-key";
161
+ const apiSecret = "your-api-secret"
162
+ const accessKeyId = "WO00000000000000000000000000000000";
162
163
 
163
164
  try {
164
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
165
- await client.loginWithApiKey(API_KEY);
165
+ const client = SDK.Client({ accessKeyId });
166
+ await client.loginWithApiKey(apiKey, apiSecret);
166
167
 
167
168
  const acls = new SDK.Acls(client);
168
169
  const response = await acls.createAcl(request);
@@ -175,11 +176,10 @@ async function main(request) {
175
176
 
176
177
  const request = {
177
178
  name: "My ACL",
178
- allow: ["47.132.130.31"], // Allow only this IP
179
- deny: ["0.0.0.0/0"] // Deny all other IPs
179
+ allow: ["47.132.130.31"] // Allow only this IP
180
180
  };
181
181
 
182
- main(request).catch(console.error);
182
+ main(request);
183
183
  ```
184
184
  <a name="Acls+createAcl"></a>
185
185
 
@@ -194,7 +194,6 @@ Creates a new Acl in the Workspace.
194
194
  | request | <code>CreateAclRequest</code> | The request object that contains the necessary information to create a new Acl |
195
195
  | request.name | <code>string</code> | The name of the Acl |
196
196
  | request.allow | <code>Array.&lt;string&gt;</code> | The list of IPs to allow |
197
- | request.deny | <code>Array.&lt;string&gt;</code> | The list of IPs to deny |
198
197
 
199
198
  **Example**
200
199
  ```js
@@ -202,8 +201,7 @@ const acls = new SDK.Acls(client); // Existing client object
202
201
 
203
202
  const request = {
204
203
  name: "My ACL",
205
- allow: ["47.132.130.31"], // Allow only this IP
206
- deny: ["0.0.0.0/0"] // Deny all other IPs
204
+ allow: ["47.132.130.31"] // Allow only this IP
207
205
  };
208
206
 
209
207
  acls
@@ -248,7 +246,6 @@ Updates an existing Acl in the Workspace.
248
246
  | request.ref | <code>string</code> | The reference of the Acl to update |
249
247
  | request.name | <code>string</code> | The name of the Acl |
250
248
  | request.allow | <code>Array.&lt;string&gt;</code> | The list of IPs to allow |
251
- | request.deny | <code>Array.&lt;string&gt;</code> | The list of IPs to deny |
252
249
 
253
250
  **Example**
254
251
  ```js
@@ -258,7 +255,6 @@ const request = {
258
255
  ref: "00000000-0000-0000-0000-000000000000",
259
256
  name: "My ACL",
260
257
  allow: ["47.132.130.31"] // Allow only this IP
261
- deny: ["0.0.0.0/0"] // Deny all other IPs
262
258
  };
263
259
 
264
260
  acls
@@ -356,12 +352,13 @@ Constructs a new Agents object.
356
352
  const SDK = require("@fonoster/sdk");
357
353
 
358
354
  async function main(request) {
359
- const API_KEY = "your-api-key";
360
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
355
+ const apiKey = "your-api-key";
356
+ const apiSecret = "your-api-secret"
357
+ const accessKeyId = "WO00000000000000000000000000000000";
361
358
 
362
359
  try {
363
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
364
- await client.loginWithApiKey(API_KEY);
360
+ const client = SDK.Client({ accessKeyId });
361
+ await client.loginWithApiKey(apiKey, apiSecret);
365
362
 
366
363
  const agents = new SDK.Agents(client);
367
364
  const response = await agents.createAgent(request);
@@ -381,7 +378,7 @@ const request = {
381
378
  domainRef: "00000000-0000-0000-0000-000000000000"
382
379
  };
383
380
 
384
- main(request).catch(console.error);
381
+ main(request);
385
382
  ```
386
383
  <a name="Agents+createAgent"></a>
387
384
 
@@ -567,12 +564,13 @@ Constructs a new ApiKeys object.
567
564
  const SDK = require("@fonoster/sdk");
568
565
 
569
566
  async function main(request) {
570
- const API_KEY = "your-api-key";
571
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
567
+ const apiKey = "your-api-key";
568
+ const apiSecret = "your-api-secret"
569
+ const accessKeyId = "WO00000000000000000000000000000000";
572
570
 
573
571
  try {
574
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
575
- await client.loginWithApiKey(apiKey);
572
+ const client = SDK.Client({ accessKeyId });
573
+ await client.loginWithApiKey(apiKey, apiSecret);
576
574
 
577
575
  const apiKeys = new SDK.ApiKeys(client);
578
576
  const response = await apiKeys.createApiKey(request);
@@ -587,7 +585,7 @@ const request = {
587
585
  role: "WORKSPACE_ADMIN"
588
586
  };
589
587
 
590
- main(request).catch(console.error);
588
+ main(request);
591
589
  ```
592
590
  <a name="ApiKeys+createApiKey"></a>
593
591
 
@@ -729,12 +727,13 @@ Constructs a new Applications object.
729
727
  const SDK = require("@fonoster/sdk");
730
728
 
731
729
  async function main(request) {
732
- const API_KEY = "your-api-key";
733
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
730
+ const apiKey = "your-api-key";
731
+ const apiSecret = "your-api-secret"
732
+ const accessKeyId = "WO00000000000000000000000000000000";
734
733
 
735
734
  try {
736
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
737
- await client.loginWithApiKey(apiKey);
735
+ const client = SDK.Client({ accessKeyId });
736
+ await client.loginWithApiKey(apiKey, apiSecret);
738
737
 
739
738
  const apps = new SDK.Applications(client);
740
739
  const response = await apps.createApplication(request);
@@ -772,7 +771,7 @@ const request = {
772
771
  }
773
772
  };
774
773
 
775
- main(request).catch(console.error);
774
+ main(request);
776
775
  ```
777
776
  <a name="Applications+createApplication"></a>
778
777
 
@@ -986,15 +985,16 @@ Constructs a new Calls object.
986
985
  const SDK = require("@fonoster/sdk");
987
986
 
988
987
  async function main(request) {
989
- const API_KEY = "your-api-key";
990
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
988
+ const apiKey = "your-api-key";
989
+ const apiSecret = "your-api-secret"
990
+ const accessKeyId = "WO00000000000000000000000000000000";
991
991
 
992
992
  try {
993
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
994
- await client.loginWithApiKey(apiKey);
993
+ const client = SDK.Client({ accessKeyId });
994
+ await client.loginWithApiKey(apiKey, apiSecret);
995
995
 
996
996
  const calls = new SDK.Calls(client);
997
- const response = await apiKeys.createCall(request);
997
+ const response = await calls.createCall(request);
998
998
 
999
999
  console.log(response); // successful response
1000
1000
  } catch (e) {
@@ -1008,7 +1008,7 @@ const request = {
1008
1008
  appRef: "00000000-0000-0000-0000-000000000000"
1009
1009
  };
1010
1010
 
1011
- main(request).catch(console.error);
1011
+ main(request);
1012
1012
  ```
1013
1013
  <a name="Calls+createCall"></a>
1014
1014
 
@@ -1136,12 +1136,13 @@ Constructs a new Credentials object.
1136
1136
  const SDK = require("@fonoster/sdk");
1137
1137
 
1138
1138
  async function main(request) {
1139
- const API_KEY = "your-api-key";
1140
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
1139
+ const apiKey = "your-api-key";
1140
+ const apiSecret = "your-api-secret"
1141
+ const accessKeyId = "WO00000000000000000000000000000000";
1141
1142
 
1142
1143
  try {
1143
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
1144
- await client.loginWithApiKey(apiKey);
1144
+ const client = SDK.Client({ accessKeyId });
1145
+ await client.loginWithApiKey(apiKey, apiSecret);
1145
1146
 
1146
1147
  const credentials = new SDK.Credentials(client);
1147
1148
  const response = await apiKeys.createCredentials(request);
@@ -1158,7 +1159,7 @@ const request = {
1158
1159
  password: "mysecret"
1159
1160
  };
1160
1161
 
1161
- main(request).catch(console.error);
1162
+ main(request);
1162
1163
  ```
1163
1164
  <a name="Credentials+createCredentials"></a>
1164
1165
 
@@ -1333,12 +1334,13 @@ Constructs a new Domains object.
1333
1334
  const SDK = require("@fonoster/sdk");
1334
1335
 
1335
1336
  async function main(request) {
1336
- const API_KEY = "your-api-key";
1337
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
1337
+ const apiKey = "your-api-key";
1338
+ const apiSecret = "your-api-secret"
1339
+ const accessKeyId = "WO00000000000000000000000000000000";
1338
1340
 
1339
1341
  try {
1340
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
1341
- await client.loginWithApiKey(apiKey);
1342
+ const client = SDK.Client({ accessKeyId });
1343
+ await client.loginWithApiKey(apiKey, apiSecret);
1342
1344
 
1343
1345
  const domains = new SDK.Domains(client);
1344
1346
  const response = await domains.createDomain(request);
@@ -1354,7 +1356,7 @@ const request = {
1354
1356
  domainUri: "sip.project.fonoster.io"
1355
1357
  };
1356
1358
 
1357
- main(request).catch(console.error);
1359
+ main(request);
1358
1360
  ```
1359
1361
  <a name="Domains+createDomain"></a>
1360
1362
 
@@ -1534,12 +1536,13 @@ Constructs a new Numbers object.
1534
1536
  const SDK = require("@fonoster/sdk");
1535
1537
 
1536
1538
  async function main(request) {
1537
- const API_KEY = "your-api-key";
1538
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
1539
+ const apiKey = "your-api-key";
1540
+ const apiSecret = "your-api-secret"
1541
+ const accessKeyId = "WO00000000000000000000000000000000";
1539
1542
 
1540
1543
  try {
1541
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
1542
- await client.loginWithApiKey(apiKey);
1544
+ const client = SDK.Client({ accessKeyId });
1545
+ await client.loginWithApiKey(apiKey, apiSecret);
1543
1546
 
1544
1547
  const numbers = new SDK.Numbers(client);
1545
1548
  const response = await numbers.createNumber(request);
@@ -1558,7 +1561,7 @@ const request = {
1558
1561
  countryIsoCode: "US"
1559
1562
  };
1560
1563
 
1561
- main(request).catch(console.error);
1564
+ main(request);
1562
1565
  ```
1563
1566
  <a name="Numbers+createNumber"></a>
1564
1567
 
@@ -1735,12 +1738,13 @@ Constructs a new Secrets object.
1735
1738
  const SDK = require("@fonoster/sdk");
1736
1739
 
1737
1740
  async function main(request) {
1738
- const API_KEY = "your-api-key";
1739
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
1741
+ const apiKey = "your-api-key";
1742
+ const apiSecret = "your-api-secret"
1743
+ const accessKeyId = "WO00000000000000000000000000000000";
1740
1744
 
1741
1745
  try {
1742
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
1743
- await client.loginWithApiKey(apiKey);
1746
+ const client = SDK.Client({ accessKeyId });
1747
+ await client.loginWithApiKey(apiKey, apiSecret);
1744
1748
 
1745
1749
  const secrets = new SDK.Secrets(client);
1746
1750
  const response = await secrets.creteSecret(request);
@@ -1756,7 +1760,7 @@ const request = {
1756
1760
  secret: "mysecret"
1757
1761
  };
1758
1762
 
1759
- main(request).catch(console.error);
1763
+ main(request);
1760
1764
  ```
1761
1765
  <a name="Secrets+createSecret"></a>
1762
1766
 
@@ -1928,12 +1932,13 @@ Constructs a new Trunks object.
1928
1932
  const SDK = require("@fonoster/sdk");
1929
1933
 
1930
1934
  async function main(request) {
1931
- const API_KEY = "your-api-key";
1932
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
1935
+ const apiKey = "your-api-key";
1936
+ const apiSecret = "your-api-secret"
1937
+ const accessKeyId = "WO00000000000000000000000000000000";
1933
1938
 
1934
1939
  try {
1935
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
1936
- await client.loginWithApiKey(apiKey);
1940
+ const client = SDK.Client({ accessKeyId });
1941
+ await client.loginWithApiKey(apiKey, apiSecret);
1937
1942
 
1938
1943
  const trunks = new SDK.Trunks(client);
1939
1944
  const response = await trunks.createTrunk(request);
@@ -1949,7 +1954,7 @@ const request = {
1949
1954
  inboundUri: "sip.company.fonoster.io"
1950
1955
  };
1951
1956
 
1952
- main(request).catch(console.error);
1957
+ main(request);
1953
1958
  ```
1954
1959
  <a name="Trunks+createTrunk"></a>
1955
1960
 
@@ -2163,12 +2168,13 @@ Constructs a new Users object.
2163
2168
  const SDK = require("@fonoster/sdk");
2164
2169
 
2165
2170
  async function main(request) {
2166
- const API_KEY = "your-api-key";
2167
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
2171
+ const apiKey = "your-api-key";
2172
+ const apiSecret = "your-api-secret"
2173
+ const accessKeyId = "WO00000000000000000000000000000000";
2168
2174
 
2169
2175
  try {
2170
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
2171
- await client.loginWithApiKey(apiKey);
2176
+ const client = SDK.Client({ accessKeyId });
2177
+ await client.loginWithApiKey(apiKey, apiSecret);
2172
2178
 
2173
2179
  const users = new SDK.Users(client);
2174
2180
  const response = await users.createUser(request);
@@ -2186,7 +2192,7 @@ const request = {
2186
2192
  avatar: "https://example.com/avatar.jpg"
2187
2193
  };
2188
2194
 
2189
- main(request).catch(console.error);
2195
+ main(request);
2190
2196
  ```
2191
2197
  <a name="Users+createUser"></a>
2192
2198
 
@@ -2340,12 +2346,13 @@ Constructs a new Workspaces object.
2340
2346
  const SDK = require("@fonoster/sdk");
2341
2347
 
2342
2348
  async function main(request) {
2343
- const API_KEY = "your-api-key";
2344
- const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
2349
+ const apiKey = "your-api-key";
2350
+ const apiSecret = "your-api-secret"
2351
+ const accessKeyId = "WO00000000000000000000000000000000";
2345
2352
 
2346
2353
  try {
2347
- const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
2348
- await client.loginWithApiKey(apiKey);
2354
+ const client = SDK.Client({ accessKeyId });
2355
+ await client.loginWithApiKey(apiKey, apiSecret);
2349
2356
 
2350
2357
  const workspaces = new SDK.Workspaces(client);
2351
2358
  const response = await workspaces.createWorkspace(request);
@@ -2360,7 +2367,7 @@ const request = {
2360
2367
  name: "My Workspace"
2361
2368
  };
2362
2369
 
2363
- main(request).catch(console.error);
2370
+ main(request);
2364
2371
  ```
2365
2372
  <a name="Workspaces+createWorkspace"></a>
2366
2373
 
@@ -1,4 +1,4 @@
1
- import { BaseApiObject, CreateAclRequest, ListAclsRequest, ListAclsResponse, UpdateAclRequest } from "@fonoster/types";
1
+ import { Acl, BaseApiObject, CreateAclRequest, ListAclsRequest, ListAclsResponse, UpdateAclRequest } from "@fonoster/types";
2
2
  import { FonosterClient } from "./client/types";
3
3
  /**
4
4
  * @classdesc Fonoster Acls, part of the Fonoster SIP Proxy subsystem,
@@ -79,7 +79,7 @@ declare class Acls {
79
79
  * .then(console.log) // successful response
80
80
  * .catch(console.error); // an error occurred
81
81
  */
82
- getAcl(ref: string): Promise<unknown>;
82
+ getAcl(ref: string): Promise<Acl>;
83
83
  /**
84
84
  * Updates an existing Acl in the Workspace.
85
85
  *
@@ -107,13 +107,22 @@ class Agents {
107
107
  */
108
108
  async getAgent(ref) {
109
109
  const client = this.client.getAgentsClient();
110
- return await (0, makeRpcRequest_1.makeRpcRequest)({
110
+ const response = await (0, makeRpcRequest_1.makeRpcRequest)({
111
111
  method: client.getAgent.bind(client),
112
112
  requestPBObjectConstructor: agents_pb_1.GetAgentRequest,
113
113
  metadata: this.client.getMetadata(),
114
114
  request: { ref },
115
115
  enumMapping: [["privacy", agents_pb_1.Privacy]]
116
116
  });
117
+ const credentials = response?.credentials?.toObject();
118
+ const domain = response?.domain?.toObject();
119
+ return response
120
+ ? {
121
+ ...response,
122
+ credentials,
123
+ domain
124
+ }
125
+ : null;
117
126
  }
118
127
  /**
119
128
  * Updates an existing Agent in the Workspace.
@@ -104,12 +104,19 @@ class Numbers {
104
104
  */
105
105
  async getNumber(ref) {
106
106
  const client = this.client.getNumbersClient();
107
- return await (0, makeRpcRequest_1.makeRpcRequest)({
107
+ const response = await (0, makeRpcRequest_1.makeRpcRequest)({
108
108
  method: client.getNumber.bind(client),
109
109
  requestPBObjectConstructor: numbers_pb_1.GetNumberRequest,
110
110
  metadata: this.client.getMetadata(),
111
111
  request: { ref }
112
112
  });
113
+ const trunk = response?.trunk?.toObject();
114
+ return response
115
+ ? {
116
+ ...response,
117
+ trunk
118
+ }
119
+ : null;
113
120
  }
114
121
  /**
115
122
  * Updates an existing Number in the Workspace.
@@ -1,4 +1,4 @@
1
- import { BaseApiObject, CreateTrunkRequest, ListTrunksRequest, ListTrunksResponse, UpdateTrunkRequest } from "@fonoster/types";
1
+ import { BaseApiObject, CreateTrunkRequest, ListTrunksRequest, ListTrunksResponse, Trunk, UpdateTrunkRequest } from "@fonoster/types";
2
2
  import { FonosterClient } from "./client/types";
3
3
  /**
4
4
  * @classdesc Fonoster Trunks, part of the Fonoster SIP Proxy subsystem,
@@ -102,7 +102,7 @@ declare class Trunks {
102
102
  * .then(console.log) // successful response
103
103
  * .catch(console.error); // an error occurred
104
104
  */
105
- getTrunk(ref: string): Promise<unknown>;
105
+ getTrunk(ref: string): Promise<Trunk>;
106
106
  /**
107
107
  * Updates an existing Trunk in the Workspace.
108
108
  *
@@ -149,12 +149,14 @@ class Trunks {
149
149
  const obj = response.toObject();
150
150
  const outObj = {
151
151
  ...obj,
152
+ accessControlListRef: obj.accessControlList?.ref,
153
+ inboundCredentialsRef: obj.inboundCredentials?.ref,
154
+ outboundCredentialsRef: obj.outboundCredentials?.ref,
152
155
  uris: obj.urisList,
153
156
  createdAt: new Date(obj.createdAt * 1000),
154
157
  updatedAt: new Date(obj.updatedAt * 1000)
155
158
  };
156
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
- const { urisList, ...rest } = outObj;
159
+ const { urisList, accessControlList, inboundCredentials, outboundCredentials, ...rest } = outObj;
158
160
  resolve(rest);
159
161
  });
160
162
  });