@fonoster/sdk 0.6.5 → 0.7.0
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 +524 -459
- package/dist/node/Acls.d.ts +43 -44
- package/dist/node/Acls.js +62 -49
- package/dist/node/Agents.d.ts +44 -45
- package/dist/node/Agents.js +47 -46
- package/dist/node/ApiKeys.d.ts +29 -29
- package/dist/node/ApiKeys.js +29 -29
- package/dist/node/Applications.d.ts +43 -43
- package/dist/node/Applications.js +56 -44
- package/dist/node/Calls.d.ts +42 -30
- package/dist/node/Calls.js +78 -54
- package/dist/node/Credentials.d.ts +39 -39
- package/dist/node/Credentials.js +39 -39
- package/dist/node/Domains.d.ts +37 -37
- package/dist/node/Domains.js +37 -37
- package/dist/node/Numbers.d.ts +40 -40
- package/dist/node/Numbers.js +40 -40
- package/dist/node/Secrets.d.ts +37 -37
- package/dist/node/Secrets.js +37 -37
- package/dist/node/Trunks.d.ts +58 -52
- package/dist/node/Trunks.js +104 -70
- package/dist/node/Users.d.ts +34 -34
- package/dist/node/Users.js +34 -34
- package/dist/node/Workspaces.d.ts +55 -54
- package/dist/node/Workspaces.js +61 -54
- package/dist/node/client/jsonToObject.js +1 -1
- package/dist/node/client/makeRpcRequest.js +1 -1
- package/dist/node/client/objectToJson.d.ts +1 -1
- package/dist/node/client/objectToJson.js +12 -2
- package/dist/node/client/types/CallsClient.d.ts +3 -2
- package/dist/node/client/types/IdentityClient.d.ts +2 -2
- package/dist/node/client/types/common.d.ts +8 -1
- package/dist/node/client/utils.js +6 -3
- package/dist/node/generated/node/acls_pb.js +6 -6
- package/dist/node/generated/node/agents_grpc_pb.js +0 -2
- package/dist/node/generated/node/agents_pb.js +450 -30
- package/dist/node/generated/node/applications_pb.js +24 -24
- package/dist/node/generated/node/calls_grpc_pb.js +0 -3
- package/dist/node/generated/node/calls_pb.js +103 -104
- package/dist/node/generated/node/credentials_pb.js +15 -45
- package/dist/node/generated/node/domains_pb.js +34 -34
- package/dist/node/generated/node/identity_grpc_pb.js +14 -14
- package/dist/node/generated/node/identity_pb.js +55 -55
- package/dist/node/generated/node/numbers_grpc_pb.js +0 -1
- package/dist/node/generated/node/numbers_pb.js +197 -17
- package/dist/node/generated/node/secrets_pb.js +6 -6
- package/dist/node/generated/node/trunks_grpc_pb.js +0 -2
- package/dist/node/generated/node/trunks_pb.js +532 -37
- package/dist/node/generated/web/IdentityServiceClientPb.ts +5 -5
- package/dist/node/generated/web/acls_pb.js +6 -6
- package/dist/node/generated/web/agents_pb.d.ts +62 -10
- package/dist/node/generated/web/agents_pb.js +450 -30
- package/dist/node/generated/web/applications_pb.d.ts +9 -9
- package/dist/node/generated/web/applications_pb.js +24 -24
- package/dist/node/generated/web/calls_pb.d.ts +37 -37
- package/dist/node/generated/web/calls_pb.js +103 -104
- package/dist/node/generated/web/credentials_pb.d.ts +0 -4
- package/dist/node/generated/web/credentials_pb.js +15 -45
- package/dist/node/generated/web/domains_pb.js +34 -34
- package/dist/node/generated/web/identity_pb.d.ts +13 -13
- package/dist/node/generated/web/identity_pb.js +55 -55
- package/dist/node/generated/web/numbers_pb.d.ts +26 -4
- package/dist/node/generated/web/numbers_pb.js +197 -17
- package/dist/node/generated/web/secrets_pb.js +6 -6
- package/dist/node/generated/web/trunks_pb.d.ts +71 -11
- package/dist/node/generated/web/trunks_pb.js +532 -37
- package/dist/node/tsconfig.node.tsbuildinfo +1 -1
- package/dist/node/utils.d.ts +5 -3
- package/dist/node/utils.js +56 -0
- package/dist/web/fonoster.min.js +1 -1
- package/dist/web/index.esm.js +1 -1
- package/package.json +4 -4
package/dist/node/Calls.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DialStatus } from "@fonoster/common";
|
|
2
|
+
import { CallDetailRecord, CreateCallRequest, ListCallsRequest, ListCallsResponse } from "@fonoster/types";
|
|
2
3
|
import { FonosterClient } from "./client/types";
|
|
3
4
|
/**
|
|
4
5
|
* @classdesc Fonoster Calls, part of the Fonoster Media subsystem,
|
|
@@ -10,13 +11,12 @@ import { FonosterClient } from "./client/types";
|
|
|
10
11
|
* const SDK = require("@fonoster/sdk");
|
|
11
12
|
*
|
|
12
13
|
* async function main(request) {
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
14
|
+
* const API_KEY = "your-api-key";
|
|
15
|
+
* const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* const client = SDK.Client({ accessKeyId });
|
|
19
|
-
* await client.
|
|
17
|
+
* try {
|
|
18
|
+
* const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
|
|
19
|
+
* await client.loginWithApiKey(apiKey);
|
|
20
20
|
*
|
|
21
21
|
* const calls = new SDK.Calls(client);
|
|
22
22
|
* const response = await apiKeys.createCall(request);
|
|
@@ -52,36 +52,48 @@ declare class Calls {
|
|
|
52
52
|
* @param {string} request.from - The number that originated the call
|
|
53
53
|
* @param {string} request.to - The number that received the call
|
|
54
54
|
* @param {string} request.appRef - The reference of the App that will handle the call
|
|
55
|
-
* @
|
|
55
|
+
* @param {number} request.timeout - The time in seconds to wait for the call to be answered. Default is 60 seconds
|
|
56
|
+
* @return {{ref: string, statusStream: AsyncGenerator<{ status: DialStatus }>}} - The response object that contains the Call reference and a stream of status updates
|
|
57
|
+
* @see DialStatus
|
|
56
58
|
* @example
|
|
59
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
57
60
|
*
|
|
58
61
|
* const request = {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
+
* from: "8287854037",
|
|
63
|
+
* to: "+17853178070",
|
|
64
|
+
* appRef: "00000000-0000-0000-0000-000000000000",
|
|
65
|
+
* timeout: 30
|
|
62
66
|
* };
|
|
63
67
|
*
|
|
64
|
-
* const
|
|
68
|
+
* const response = await calls.createCall(request);
|
|
69
|
+
* const { ref, statusStream } = response;
|
|
70
|
+
*
|
|
71
|
+
* console.log(ref); // Call reference
|
|
65
72
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
73
|
+
* for await (const status of statusStream) {
|
|
74
|
+
* console.log(status); // Streamed status
|
|
75
|
+
* }
|
|
69
76
|
*/
|
|
70
|
-
createCall(request: CreateCallRequest): Promise<
|
|
77
|
+
createCall(request: CreateCallRequest): Promise<{
|
|
78
|
+
ref: string;
|
|
79
|
+
statusStream: AsyncGenerator<{
|
|
80
|
+
status: DialStatus;
|
|
81
|
+
}>;
|
|
82
|
+
}>;
|
|
71
83
|
/**
|
|
72
84
|
* Retrieves an existing Call in the Workspace.
|
|
73
85
|
*
|
|
74
86
|
* @param {string} ref - The reference of the Call to retrieve
|
|
75
|
-
* @return {Promise<
|
|
87
|
+
* @return {Promise<CallDetailRecord>} - The response object that contains the Call detail
|
|
76
88
|
* @example
|
|
77
|
-
*
|
|
78
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
79
|
-
*
|
|
80
89
|
* const calls = new SDK.Calls(client); // Existing client object
|
|
81
90
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
91
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
92
|
+
*
|
|
93
|
+
* calls
|
|
94
|
+
* .getCall(ref)
|
|
95
|
+
* .then(console.log) // successful response
|
|
96
|
+
* .catch(console.error); // an error occurred
|
|
85
97
|
*/
|
|
86
98
|
getCall(ref: string): Promise<CallDetailRecord>;
|
|
87
99
|
/**
|
|
@@ -92,17 +104,17 @@ declare class Calls {
|
|
|
92
104
|
* @param {string} request.pageToken - The token to retrieve the next page of Calls
|
|
93
105
|
* @return {Promise<ListCallsResponse>} - The response object that contains the list of Calls
|
|
94
106
|
* @example
|
|
107
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
95
108
|
*
|
|
96
109
|
* const request = {
|
|
97
|
-
*
|
|
98
|
-
*
|
|
110
|
+
* pageSize: 10,
|
|
111
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
99
112
|
* };
|
|
100
113
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* .catch(console.error); // an error occurred
|
|
114
|
+
* calls
|
|
115
|
+
* .listCalls(request)
|
|
116
|
+
* .then(console.log) // successful response
|
|
117
|
+
* .catch(console.error); // an error occurred
|
|
106
118
|
*/
|
|
107
119
|
listCalls(request: ListCallsRequest): Promise<ListCallsResponse>;
|
|
108
120
|
}
|
package/dist/node/Calls.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Calls = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Fonoster
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License (the "License");
|
|
11
|
-
* you may not use this file except in compliance with
|
|
12
|
-
* the License. You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* https://opensource.org/licenses/MIT
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
const types_1 = require("@fonoster/types");
|
|
23
4
|
const makeRpcRequest_1 = require("./client/makeRpcRequest");
|
|
24
5
|
const calls_pb_1 = require("./generated/node/calls_pb");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
25
7
|
/**
|
|
26
8
|
* @classdesc Fonoster Calls, part of the Fonoster Media subsystem,
|
|
27
9
|
* allows you to create, list, and track calls in your deployment.
|
|
@@ -32,13 +14,12 @@ const calls_pb_1 = require("./generated/node/calls_pb");
|
|
|
32
14
|
* const SDK = require("@fonoster/sdk");
|
|
33
15
|
*
|
|
34
16
|
* async function main(request) {
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* const accessKeyId = "00000000-0000-0000-0000-000000000000";
|
|
17
|
+
* const API_KEY = "your-api-key";
|
|
18
|
+
* const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
|
|
38
19
|
*
|
|
39
|
-
*
|
|
40
|
-
* const client = SDK.Client({ accessKeyId });
|
|
41
|
-
* await client.
|
|
20
|
+
* try {
|
|
21
|
+
* const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
|
|
22
|
+
* await client.loginWithApiKey(apiKey);
|
|
42
23
|
*
|
|
43
24
|
* const calls = new SDK.Calls(client);
|
|
44
25
|
* const response = await apiKeys.createCall(request);
|
|
@@ -76,45 +57,84 @@ class Calls {
|
|
|
76
57
|
* @param {string} request.from - The number that originated the call
|
|
77
58
|
* @param {string} request.to - The number that received the call
|
|
78
59
|
* @param {string} request.appRef - The reference of the App that will handle the call
|
|
79
|
-
* @
|
|
60
|
+
* @param {number} request.timeout - The time in seconds to wait for the call to be answered. Default is 60 seconds
|
|
61
|
+
* @return {{ref: string, statusStream: AsyncGenerator<{ status: DialStatus }>}} - The response object that contains the Call reference and a stream of status updates
|
|
62
|
+
* @see DialStatus
|
|
80
63
|
* @example
|
|
64
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
81
65
|
*
|
|
82
66
|
* const request = {
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
67
|
+
* from: "8287854037",
|
|
68
|
+
* to: "+17853178070",
|
|
69
|
+
* appRef: "00000000-0000-0000-0000-000000000000",
|
|
70
|
+
* timeout: 30
|
|
86
71
|
* };
|
|
87
72
|
*
|
|
88
|
-
* const
|
|
73
|
+
* const response = await calls.createCall(request);
|
|
74
|
+
* const { ref, statusStream } = response;
|
|
89
75
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
76
|
+
* console.log(ref); // Call reference
|
|
77
|
+
*
|
|
78
|
+
* for await (const status of statusStream) {
|
|
79
|
+
* console.log(status); // Streamed status
|
|
80
|
+
* }
|
|
93
81
|
*/
|
|
94
82
|
async createCall(request) {
|
|
95
83
|
const client = this.client.getCallsClient();
|
|
96
|
-
|
|
84
|
+
const response = await (0, makeRpcRequest_1.makeRpcRequest)({
|
|
97
85
|
method: client.createCall.bind(client),
|
|
98
86
|
requestPBObjectConstructor: calls_pb_1.CreateCallRequest,
|
|
99
87
|
metadata: this.client.getMetadata(),
|
|
100
|
-
request
|
|
101
|
-
enumMapping: [["type", types_1.CallType]]
|
|
88
|
+
request
|
|
102
89
|
});
|
|
90
|
+
const trackCallRequest = new calls_pb_1.TrackCallRequest();
|
|
91
|
+
trackCallRequest.setRef(response.ref);
|
|
92
|
+
const call = client.trackCall(trackCallRequest, this.client.getMetadata());
|
|
93
|
+
async function* statusStreamGenerator() {
|
|
94
|
+
const queue = [];
|
|
95
|
+
let done = false;
|
|
96
|
+
call.on("data", (response) => {
|
|
97
|
+
const data = response.toObject();
|
|
98
|
+
queue.push(data);
|
|
99
|
+
});
|
|
100
|
+
call.on("end", () => {
|
|
101
|
+
done = true;
|
|
102
|
+
});
|
|
103
|
+
call.on("error", () => {
|
|
104
|
+
done = true;
|
|
105
|
+
throw new Error("An error occurred while tracking the call");
|
|
106
|
+
});
|
|
107
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
108
|
+
while (!done) {
|
|
109
|
+
if (queue.length > 0) {
|
|
110
|
+
const data = queue.shift();
|
|
111
|
+
if (!data) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
yield { status: (0, utils_1.dialStatusToString)(data.status) };
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const statusStream = statusStreamGenerator();
|
|
122
|
+
return { ref: response.ref, statusStream };
|
|
103
123
|
}
|
|
104
124
|
/**
|
|
105
125
|
* Retrieves an existing Call in the Workspace.
|
|
106
126
|
*
|
|
107
127
|
* @param {string} ref - The reference of the Call to retrieve
|
|
108
|
-
* @return {Promise<
|
|
128
|
+
* @return {Promise<CallDetailRecord>} - The response object that contains the Call detail
|
|
109
129
|
* @example
|
|
110
|
-
*
|
|
111
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
112
|
-
*
|
|
113
130
|
* const calls = new SDK.Calls(client); // Existing client object
|
|
114
131
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
132
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
133
|
+
*
|
|
134
|
+
* calls
|
|
135
|
+
* .getCall(ref)
|
|
136
|
+
* .then(console.log) // successful response
|
|
137
|
+
* .catch(console.error); // an error occurred
|
|
118
138
|
*/
|
|
119
139
|
async getCall(ref) {
|
|
120
140
|
const client = this.client.getCallsClient();
|
|
@@ -124,10 +144,9 @@ class Calls {
|
|
|
124
144
|
metadata: this.client.getMetadata(),
|
|
125
145
|
request: { ref },
|
|
126
146
|
enumMapping: [
|
|
127
|
-
["type",
|
|
128
|
-
["
|
|
129
|
-
["
|
|
130
|
-
["callDirection", types_1.CallDirection]
|
|
147
|
+
["type", calls_pb_1.CallType],
|
|
148
|
+
["status", calls_pb_1.CallStatus],
|
|
149
|
+
["direction", calls_pb_1.CallDirection]
|
|
131
150
|
]
|
|
132
151
|
});
|
|
133
152
|
}
|
|
@@ -139,17 +158,17 @@ class Calls {
|
|
|
139
158
|
* @param {string} request.pageToken - The token to retrieve the next page of Calls
|
|
140
159
|
* @return {Promise<ListCallsResponse>} - The response object that contains the list of Calls
|
|
141
160
|
* @example
|
|
161
|
+
* const calls = new SDK.Calls(client); // Existing client object
|
|
142
162
|
*
|
|
143
163
|
* const request = {
|
|
144
|
-
*
|
|
145
|
-
*
|
|
164
|
+
* pageSize: 10,
|
|
165
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
146
166
|
* };
|
|
147
167
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* .catch(console.error); // an error occurred
|
|
168
|
+
* calls
|
|
169
|
+
* .listCalls(request)
|
|
170
|
+
* .then(console.log) // successful response
|
|
171
|
+
* .catch(console.error); // an error occurred
|
|
153
172
|
*/
|
|
154
173
|
async listCalls(request) {
|
|
155
174
|
const client = this.client.getCallsClient();
|
|
@@ -158,6 +177,11 @@ class Calls {
|
|
|
158
177
|
requestPBObjectConstructor: calls_pb_1.ListCallsRequest,
|
|
159
178
|
metadata: this.client.getMetadata(),
|
|
160
179
|
request,
|
|
180
|
+
enumMapping: [
|
|
181
|
+
["type", calls_pb_1.CallType],
|
|
182
|
+
["status", calls_pb_1.CallStatus],
|
|
183
|
+
["direction", calls_pb_1.CallDirection]
|
|
184
|
+
],
|
|
161
185
|
repeatableObjectMapping: [["itemsList", calls_pb_1.Call]]
|
|
162
186
|
});
|
|
163
187
|
}
|
|
@@ -10,11 +10,11 @@ import { FonosterClient } from "./client/types";
|
|
|
10
10
|
* const SDK = require("@fonoster/sdk");
|
|
11
11
|
*
|
|
12
12
|
* async function main(request) {
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* const API_KEY = "your-api-key";
|
|
14
|
+
* const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* const client = SDK.Client({ accessKeyId });
|
|
16
|
+
* try {
|
|
17
|
+
* const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
|
|
18
18
|
* await client.loginWithApiKey(apiKey);
|
|
19
19
|
*
|
|
20
20
|
* const credentials = new SDK.Credentials(client);
|
|
@@ -53,18 +53,18 @@ declare class Credentials {
|
|
|
53
53
|
* @param {string} request.password - The password of the Credentials
|
|
54
54
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Credentials
|
|
55
55
|
* @example
|
|
56
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
56
57
|
*
|
|
57
58
|
* const request = {
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* name: "My Credentials",
|
|
60
|
+
* username: "myusername",
|
|
61
|
+
* password: "mysecret"
|
|
61
62
|
* };
|
|
62
63
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* .catch(console.error); // an error occurred
|
|
64
|
+
* credentials
|
|
65
|
+
* .createCredentials(request)
|
|
66
|
+
* .then(console.log) // successful response
|
|
67
|
+
* .catch(console.error); // an error occurred
|
|
68
68
|
*/
|
|
69
69
|
createCredentials(request: CreateCredentialsRequest): Promise<BaseApiObject>;
|
|
70
70
|
/**
|
|
@@ -73,14 +73,14 @@ declare class Credentials {
|
|
|
73
73
|
* @param {string} ref - The reference of the Credentials to retrieve
|
|
74
74
|
* @return {Promise<Acl>} - The response object that contains the Credentials
|
|
75
75
|
* @example
|
|
76
|
-
*
|
|
77
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
78
|
-
*
|
|
79
76
|
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
80
77
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
78
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
79
|
+
*
|
|
80
|
+
* credentials
|
|
81
|
+
* .getCredentials(ref)
|
|
82
|
+
* .then(console.log) // successful response
|
|
83
|
+
* .catch(console.error); // an error occurred
|
|
84
84
|
*/
|
|
85
85
|
getCredentials(ref: string): Promise<CredentialsType>;
|
|
86
86
|
/**
|
|
@@ -92,18 +92,18 @@ declare class Credentials {
|
|
|
92
92
|
* @param {string} request.password - The password of the Credentials
|
|
93
93
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Credentials
|
|
94
94
|
* @example
|
|
95
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
95
96
|
*
|
|
96
97
|
* const request = {
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
98
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
99
|
+
* name: "My Credentials",
|
|
100
|
+
* password: "mysecret"
|
|
100
101
|
* };
|
|
101
102
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* .catch(console.error); // an error occurred
|
|
103
|
+
* credentials
|
|
104
|
+
* .updateCredentials(request)
|
|
105
|
+
* .then(console.log) // successful response
|
|
106
|
+
* .catch(console.error); // an error occurred
|
|
107
107
|
*/
|
|
108
108
|
updateCredentials(request: UpdateCredentialsRequest): Promise<BaseApiObject>;
|
|
109
109
|
/**
|
|
@@ -114,17 +114,17 @@ declare class Credentials {
|
|
|
114
114
|
* @param {string} request.pageToken - The token to retrieve the next page of Credentials
|
|
115
115
|
* @return {Promise<ListCredentialsResponse>} - The response object that contains the list of Credentials
|
|
116
116
|
* @example
|
|
117
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
117
118
|
*
|
|
118
119
|
* const request = {
|
|
119
|
-
*
|
|
120
|
-
*
|
|
120
|
+
* pageSize: 10,
|
|
121
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
121
122
|
* };
|
|
122
123
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* .catch(console.error); // an error occurred
|
|
124
|
+
* credentials
|
|
125
|
+
* .listCredentials(request)
|
|
126
|
+
* .then(console.log) // successful response
|
|
127
|
+
* .catch(console.error); // an error occurred
|
|
128
128
|
*/
|
|
129
129
|
listCredentials(request: ListCredentialsRequest): Promise<ListCredentialsResponse>;
|
|
130
130
|
/**
|
|
@@ -134,14 +134,14 @@ declare class Credentials {
|
|
|
134
134
|
* @param {string} ref - The reference of the Credentials to delete
|
|
135
135
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Credentials
|
|
136
136
|
* @example
|
|
137
|
-
*
|
|
138
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
139
|
-
*
|
|
140
137
|
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
141
138
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
139
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
140
|
+
*
|
|
141
|
+
* credentials
|
|
142
|
+
* .deleteCredentials(ref)
|
|
143
|
+
* .then(console.log) // successful response
|
|
144
|
+
* .catch(console.error); // an error occurred
|
|
145
145
|
*/
|
|
146
146
|
deleteCredentials(ref: string): Promise<BaseApiObject>;
|
|
147
147
|
}
|
package/dist/node/Credentials.js
CHANGED
|
@@ -13,11 +13,11 @@ const credentials_pb_1 = require("./generated/node/credentials_pb");
|
|
|
13
13
|
* const SDK = require("@fonoster/sdk");
|
|
14
14
|
*
|
|
15
15
|
* async function main(request) {
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* const API_KEY = "your-api-key";
|
|
17
|
+
* const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
* const client = SDK.Client({ accessKeyId });
|
|
19
|
+
* try {
|
|
20
|
+
* const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
|
|
21
21
|
* await client.loginWithApiKey(apiKey);
|
|
22
22
|
*
|
|
23
23
|
* const credentials = new SDK.Credentials(client);
|
|
@@ -58,18 +58,18 @@ class Credentials {
|
|
|
58
58
|
* @param {string} request.password - The password of the Credentials
|
|
59
59
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Credentials
|
|
60
60
|
* @example
|
|
61
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
61
62
|
*
|
|
62
63
|
* const request = {
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* name: "My Credentials",
|
|
65
|
+
* username: "myusername",
|
|
66
|
+
* password: "mysecret"
|
|
66
67
|
* };
|
|
67
68
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* .catch(console.error); // an error occurred
|
|
69
|
+
* credentials
|
|
70
|
+
* .createCredentials(request)
|
|
71
|
+
* .then(console.log) // successful response
|
|
72
|
+
* .catch(console.error); // an error occurred
|
|
73
73
|
*/
|
|
74
74
|
async createCredentials(request) {
|
|
75
75
|
const client = this.client.getCredentialsClient();
|
|
@@ -86,14 +86,14 @@ class Credentials {
|
|
|
86
86
|
* @param {string} ref - The reference of the Credentials to retrieve
|
|
87
87
|
* @return {Promise<Acl>} - The response object that contains the Credentials
|
|
88
88
|
* @example
|
|
89
|
-
*
|
|
90
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
91
|
-
*
|
|
92
89
|
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
93
90
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
91
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
92
|
+
*
|
|
93
|
+
* credentials
|
|
94
|
+
* .getCredentials(ref)
|
|
95
|
+
* .then(console.log) // successful response
|
|
96
|
+
* .catch(console.error); // an error occurred
|
|
97
97
|
*/
|
|
98
98
|
async getCredentials(ref) {
|
|
99
99
|
const client = this.client.getCredentialsClient();
|
|
@@ -113,18 +113,18 @@ class Credentials {
|
|
|
113
113
|
* @param {string} request.password - The password of the Credentials
|
|
114
114
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Credentials
|
|
115
115
|
* @example
|
|
116
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
116
117
|
*
|
|
117
118
|
* const request = {
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
119
|
+
* ref: "00000000-0000-0000-0000-000000000000",
|
|
120
|
+
* name: "My Credentials",
|
|
121
|
+
* password: "mysecret"
|
|
121
122
|
* };
|
|
122
123
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* .catch(console.error); // an error occurred
|
|
124
|
+
* credentials
|
|
125
|
+
* .updateCredentials(request)
|
|
126
|
+
* .then(console.log) // successful response
|
|
127
|
+
* .catch(console.error); // an error occurred
|
|
128
128
|
*/
|
|
129
129
|
async updateCredentials(request) {
|
|
130
130
|
const client = this.client.getCredentialsClient();
|
|
@@ -143,17 +143,17 @@ class Credentials {
|
|
|
143
143
|
* @param {string} request.pageToken - The token to retrieve the next page of Credentials
|
|
144
144
|
* @return {Promise<ListCredentialsResponse>} - The response object that contains the list of Credentials
|
|
145
145
|
* @example
|
|
146
|
+
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
146
147
|
*
|
|
147
148
|
* const request = {
|
|
148
|
-
*
|
|
149
|
-
*
|
|
149
|
+
* pageSize: 10,
|
|
150
|
+
* pageToken: "00000000-0000-0000-0000-000000000000"
|
|
150
151
|
* };
|
|
151
152
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* .catch(console.error); // an error occurred
|
|
153
|
+
* credentials
|
|
154
|
+
* .listCredentials(request)
|
|
155
|
+
* .then(console.log) // successful response
|
|
156
|
+
* .catch(console.error); // an error occurred
|
|
157
157
|
*/
|
|
158
158
|
async listCredentials(request) {
|
|
159
159
|
const client = this.client.getCredentialsClient();
|
|
@@ -172,14 +172,14 @@ class Credentials {
|
|
|
172
172
|
* @param {string} ref - The reference of the Credentials to delete
|
|
173
173
|
* @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Credentials
|
|
174
174
|
* @example
|
|
175
|
-
*
|
|
176
|
-
* const ref = "00000000-0000-0000-0000-000000000000"
|
|
177
|
-
*
|
|
178
175
|
* const credentials = new SDK.Credentials(client); // Existing client object
|
|
179
176
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
177
|
+
* const ref = "00000000-0000-0000-0000-000000000000";
|
|
178
|
+
*
|
|
179
|
+
* credentials
|
|
180
|
+
* .deleteCredentials(ref)
|
|
181
|
+
* .then(console.log) // successful response
|
|
182
|
+
* .catch(console.error); // an error occurred
|
|
183
183
|
*/
|
|
184
184
|
async deleteCredentials(ref) {
|
|
185
185
|
const applicationsClient = this.client.getCredentialsClient();
|