@vonage/accounts 1.8.2 → 1.10.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/dist/accounts.d.ts +86 -4
- package/dist/accounts.js +89 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -1
- package/dist/secrets.d.ts +79 -2
- package/dist/secrets.js +82 -2
- package/dist/types/AccountCallbacks.d.ts +22 -0
- package/dist/{interfaces → types}/AccountCallbacks.js +0 -1
- package/dist/types/Response/APISecretResponse.d.ts +21 -0
- package/dist/{interfaces → types}/Response/APISecretResponse.js +0 -1
- package/dist/types/Response/AccountUpdateResponse.d.ts +28 -0
- package/dist/types/Response/AccountUpdateResponse.js +2 -0
- package/dist/types/Response/GetBalanceResponse.d.ts +13 -0
- package/dist/{interfaces → types}/Response/GetBalanceResponse.js +0 -1
- package/dist/types/Response/ListAPISecretsResponse.d.ts +26 -0
- package/dist/types/Response/ListAPISecretsResponse.js +2 -0
- package/dist/types/Response/TopUpBalanceResponse.d.ts +21 -0
- package/dist/{interfaces → types}/Response/TopUpBalanceResponse.js +0 -1
- package/dist/types/Response/index.d.ts +5 -0
- package/dist/types/Response/index.js +21 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +18 -0
- package/package.json +18 -8
- package/dist/accounts.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interfaces/AccountCallbacks.d.ts +0 -4
- package/dist/interfaces/AccountCallbacks.js.map +0 -1
- package/dist/interfaces/Response/APISecretResponse.d.ts +0 -9
- package/dist/interfaces/Response/APISecretResponse.js.map +0 -1
- package/dist/interfaces/Response/AccountUpdateResponse.d.ts +0 -7
- package/dist/interfaces/Response/AccountUpdateResponse.js +0 -3
- package/dist/interfaces/Response/AccountUpdateResponse.js.map +0 -1
- package/dist/interfaces/Response/GetBalanceResponse.d.ts +0 -4
- package/dist/interfaces/Response/GetBalanceResponse.js.map +0 -1
- package/dist/interfaces/Response/ListAPISecretsResponse.d.ts +0 -11
- package/dist/interfaces/Response/ListAPISecretsResponse.js +0 -3
- package/dist/interfaces/Response/ListAPISecretsResponse.js.map +0 -1
- package/dist/interfaces/Response/TopUpBalanceResponse.d.ts +0 -4
- package/dist/interfaces/Response/TopUpBalanceResponse.js.map +0 -1
- package/dist/secrets.js.map +0 -1
package/dist/accounts.d.ts
CHANGED
|
@@ -1,11 +1,93 @@
|
|
|
1
1
|
import { AuthenticationType, Client } from '@vonage/server-client';
|
|
2
|
-
import { AccountCallbacks } from './
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { AccountCallbacks, AccountUpdateResponse, GetBalanceResponse, TopUpBalanceResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client class to interact with the Account API which enables users to manage
|
|
5
|
+
* their Vonage API Account programmatically.
|
|
6
|
+
* @see {@link https://developer.nexmo.com/en/account/overview}
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Create a standalone Account client
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Accounts } from '@vonage/account';
|
|
13
|
+
*
|
|
14
|
+
* const accountClient = new Accounts({
|
|
15
|
+
* apiKey: VONAGE_API_KEY,
|
|
16
|
+
* apiSecret: VONAGE_API_SECRET
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* Create an Account client from the Vonage client
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { Vonage } from '@vonage/server-client';
|
|
25
|
+
*
|
|
26
|
+
* const vonage = new Vonage({
|
|
27
|
+
* apiKey: VONAGE_API_KEY,
|
|
28
|
+
* apiSecret: VONAGE_API_SECRET
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const accountClient = vonage.account;
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
6
34
|
export declare class Accounts extends Client {
|
|
35
|
+
/**
|
|
36
|
+
* @see {@link Client.authType}
|
|
37
|
+
*/
|
|
7
38
|
protected authType: AuthenticationType;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the current balance of the Vonage API account.
|
|
41
|
+
* @see {@link https://rest.nexmo.com/account/get-balance}
|
|
42
|
+
* @return {Promise<GetBalanceResponse>} The current balance of the account in EUR.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* const balance = await accontClient.getBalance();
|
|
47
|
+
*
|
|
48
|
+
* console.log(`The current account balance is ${balance.value} ${balance.currency}`);
|
|
49
|
+
* console.log(`Auto-reload is ${balance.autoReload ? 'enabled' : 'disabled'}`);
|
|
50
|
+
*/
|
|
8
51
|
getBalance(): Promise<GetBalanceResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Tops up the account balance when auto-reload is enabled.
|
|
54
|
+
* The top-up amount corresponds to the amount added when auto-reload was enabled.
|
|
55
|
+
* @see {@link https://rest.nexmo.com/account/top-up}
|
|
56
|
+
* @param {string} trx - The transaction reference for the balance addition and auto-reload activation.
|
|
57
|
+
* @return {Promise<TopUpBalanceResponse>} Response indicating the success of the operation.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* const response = await accountClient.topUpBalance('00X123456Y7890123Z');
|
|
62
|
+
*
|
|
63
|
+
* if (response['error-code'] === '200') {
|
|
64
|
+
* console.log(`The account balance has been topped up`);
|
|
65
|
+
* } else {
|
|
66
|
+
* console.log(`The account balance could not be topped up`);
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
9
70
|
topUpBalance(trx: string): Promise<TopUpBalanceResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Updates the default webhook URLs associated with the account for:
|
|
73
|
+
* - Inbound SMS messages
|
|
74
|
+
* - Delivery receipts
|
|
75
|
+
* @see {@link https://rest.nexmo.com/account/settings}
|
|
76
|
+
* @param {AccountCallbacks} callbacks - The new callback URLs for the account.
|
|
77
|
+
* @return {Promise<AccountUpdateResponse>} Details of the updated or current settings.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
*
|
|
81
|
+
* const callbacks = {
|
|
82
|
+
* moCallBackUrl: 'https://example.com/webhooks/inbound-sms',
|
|
83
|
+
* drCallBackUrl: 'https://example.com/webhooks/delivery-receipts',
|
|
84
|
+
* };
|
|
85
|
+
*
|
|
86
|
+
* const response = await accountClient.updateAccountCallbacks(callbacks);
|
|
87
|
+
*
|
|
88
|
+
* for (const [key, value] of Object.entries(response)) {
|
|
89
|
+
* console.log(`New ${key}: ${value}`);
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
10
92
|
updateAccountCallbacks(callbacks: AccountCallbacks): Promise<AccountUpdateResponse>;
|
|
11
93
|
}
|
package/dist/accounts.js
CHANGED
|
@@ -2,20 +2,107 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Accounts = void 0;
|
|
4
4
|
const server_client_1 = require("@vonage/server-client");
|
|
5
|
+
/**
|
|
6
|
+
* Client class to interact with the Account API which enables users to manage
|
|
7
|
+
* their Vonage API Account programmatically.
|
|
8
|
+
* @see {@link https://developer.nexmo.com/en/account/overview}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* Create a standalone Account client
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Accounts } from '@vonage/account';
|
|
15
|
+
*
|
|
16
|
+
* const accountClient = new Accounts({
|
|
17
|
+
* apiKey: VONAGE_API_KEY,
|
|
18
|
+
* apiSecret: VONAGE_API_SECRET
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Create an Account client from the Vonage client
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { Vonage } from '@vonage/server-client';
|
|
27
|
+
*
|
|
28
|
+
* const vonage = new Vonage({
|
|
29
|
+
* apiKey: VONAGE_API_KEY,
|
|
30
|
+
* apiSecret: VONAGE_API_SECRET
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const accountClient = vonage.account;
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
5
36
|
class Accounts extends server_client_1.Client {
|
|
6
|
-
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
/**
|
|
40
|
+
* @see {@link Client.authType}
|
|
41
|
+
*/
|
|
42
|
+
this.authType = server_client_1.AuthenticationType.QUERY_KEY_SECRET;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the current balance of the Vonage API account.
|
|
46
|
+
* @see {@link https://rest.nexmo.com/account/get-balance}
|
|
47
|
+
* @return {Promise<GetBalanceResponse>} The current balance of the account in EUR.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
*
|
|
51
|
+
* const balance = await accontClient.getBalance();
|
|
52
|
+
*
|
|
53
|
+
* console.log(`The current account balance is ${balance.value} ${balance.currency}`);
|
|
54
|
+
* console.log(`Auto-reload is ${balance.autoReload ? 'enabled' : 'disabled'}`);
|
|
55
|
+
*/
|
|
7
56
|
async getBalance() {
|
|
8
57
|
const response = await this.sendGetRequest(`${this.config.restHost}/account/get-balance`);
|
|
9
58
|
return response.data;
|
|
10
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Tops up the account balance when auto-reload is enabled.
|
|
62
|
+
* The top-up amount corresponds to the amount added when auto-reload was enabled.
|
|
63
|
+
* @see {@link https://rest.nexmo.com/account/top-up}
|
|
64
|
+
* @param {string} trx - The transaction reference for the balance addition and auto-reload activation.
|
|
65
|
+
* @return {Promise<TopUpBalanceResponse>} Response indicating the success of the operation.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
*
|
|
69
|
+
* const response = await accountClient.topUpBalance('00X123456Y7890123Z');
|
|
70
|
+
*
|
|
71
|
+
* if (response['error-code'] === '200') {
|
|
72
|
+
* console.log(`The account balance has been topped up`);
|
|
73
|
+
* } else {
|
|
74
|
+
* console.log(`The account balance could not be topped up`);
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
11
78
|
async topUpBalance(trx) {
|
|
12
79
|
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx });
|
|
13
80
|
return response.data;
|
|
14
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Updates the default webhook URLs associated with the account for:
|
|
84
|
+
* - Inbound SMS messages
|
|
85
|
+
* - Delivery receipts
|
|
86
|
+
* @see {@link https://rest.nexmo.com/account/settings}
|
|
87
|
+
* @param {AccountCallbacks} callbacks - The new callback URLs for the account.
|
|
88
|
+
* @return {Promise<AccountUpdateResponse>} Details of the updated or current settings.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
*
|
|
92
|
+
* const callbacks = {
|
|
93
|
+
* moCallBackUrl: 'https://example.com/webhooks/inbound-sms',
|
|
94
|
+
* drCallBackUrl: 'https://example.com/webhooks/delivery-receipts',
|
|
95
|
+
* };
|
|
96
|
+
*
|
|
97
|
+
* const response = await accountClient.updateAccountCallbacks(callbacks);
|
|
98
|
+
*
|
|
99
|
+
* for (const [key, value] of Object.entries(response)) {
|
|
100
|
+
* console.log(`New ${key}: ${value}`);
|
|
101
|
+
* }
|
|
102
|
+
*/
|
|
15
103
|
async updateAccountCallbacks(callbacks) {
|
|
16
104
|
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks);
|
|
17
105
|
return response.data;
|
|
18
106
|
}
|
|
19
107
|
}
|
|
20
108
|
exports.Accounts = Accounts;
|
|
21
|
-
//# sourceMappingURL=accounts.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.Secrets = exports.Accounts = void 0;
|
|
4
18
|
var accounts_1 = require("./accounts");
|
|
5
19
|
Object.defineProperty(exports, "Accounts", { enumerable: true, get: function () { return accounts_1.Accounts; } });
|
|
6
20
|
var secrets_1 = require("./secrets");
|
|
7
21
|
Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_1.Secrets; } });
|
|
8
|
-
|
|
22
|
+
__exportStar(require("./types"), exports);
|
package/dist/secrets.d.ts
CHANGED
|
@@ -1,10 +1,87 @@
|
|
|
1
1
|
import { AuthenticationType, Client } from '@vonage/server-client';
|
|
2
|
-
import { APISecretResponse } from './
|
|
3
|
-
|
|
2
|
+
import { APISecretResponse, ListAPISecretsResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client class to interact with the Account API to create secrets in
|
|
5
|
+
* their Vonage API Account programmatically.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This client is only available as a standalone client. It cannot be
|
|
9
|
+
* instantiated from the server-sdk package.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* Create a standalone Secret client
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Secrets } from '@vonage/account';
|
|
16
|
+
*
|
|
17
|
+
* const secretClient = new Secrets({
|
|
18
|
+
* apiKey: VONAGE_API_KEY,
|
|
19
|
+
* apiSecret: VONAGE_API_SECRET
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
4
24
|
export declare class Secrets extends Client {
|
|
5
25
|
protected authType: AuthenticationType;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new API secret for a given API key.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
30
|
+
* @param {string} secret - The new secret. It must follow the provided rules:
|
|
31
|
+
* - Minimum 8 characters.
|
|
32
|
+
* - Maximum 25 characters.
|
|
33
|
+
* - At least 1 lowercase character.
|
|
34
|
+
* - At least 1 uppercase character.
|
|
35
|
+
* - At least 1 digit.
|
|
36
|
+
*
|
|
37
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the created API secret.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const { id } = await secretClient.createSecret(
|
|
41
|
+
* 'new-api-key',
|
|
42
|
+
* 'SuperSecret123!'
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* console.log(`Created secret with ID ${id}`);
|
|
46
|
+
*/
|
|
6
47
|
createSecret(apiKey: string, secret: string): Promise<APISecretResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Revoke (delete) an existing API secret for a given API key.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
52
|
+
* @param {string} id - The ID of the API secret to revoke.
|
|
53
|
+
* @return {Promise<void>} A promise that resolves when the secret has been revoked.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* await secretClient.deleteSecret('my-api-key', 'my-secret-id');
|
|
57
|
+
*/
|
|
7
58
|
deleteSecret(apiKey: string, id: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieve the details of a specific API secret for a given API key.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
63
|
+
* @param {string} id - The ID of the API secret to retrieve.
|
|
64
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the API secret.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const { id } = await secretClient.getSecret('my-api-key', 'my-secret-id');
|
|
68
|
+
* console.log(`Secret with ID ${id} has been retrieved`);
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
8
71
|
getSecret(apiKey: string, id: string): Promise<APISecretResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* List all the secrets associated with a particular API key.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} apiKey - The API key for which to list secrets.
|
|
76
|
+
*
|
|
77
|
+
* @return {Promise<ListAPISecretsResponse>} A promise that resolves to an object containing a list of API secrets.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const response = await secretClient.listSecrets('my-api-key');
|
|
81
|
+
*
|
|
82
|
+
* for (const secret of response._embedded.secrets) {
|
|
83
|
+
* console.log(`Secret with ID ${secret.id} has been retrieved`);
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
9
86
|
listSecrets(apiKey: string): Promise<ListAPISecretsResponse>;
|
|
10
87
|
}
|
package/dist/secrets.js
CHANGED
|
@@ -2,23 +2,103 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Secrets = void 0;
|
|
4
4
|
const server_client_1 = require("@vonage/server-client");
|
|
5
|
+
/**
|
|
6
|
+
* Client class to interact with the Account API to create secrets in
|
|
7
|
+
* their Vonage API Account programmatically.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This client is only available as a standalone client. It cannot be
|
|
11
|
+
* instantiated from the server-sdk package.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* Create a standalone Secret client
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Secrets } from '@vonage/account';
|
|
18
|
+
*
|
|
19
|
+
* const secretClient = new Secrets({
|
|
20
|
+
* apiKey: VONAGE_API_KEY,
|
|
21
|
+
* apiSecret: VONAGE_API_SECRET
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
5
26
|
class Secrets extends server_client_1.Client {
|
|
6
|
-
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.authType = server_client_1.AuthenticationType.BASIC;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new API secret for a given API key.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
35
|
+
* @param {string} secret - The new secret. It must follow the provided rules:
|
|
36
|
+
* - Minimum 8 characters.
|
|
37
|
+
* - Maximum 25 characters.
|
|
38
|
+
* - At least 1 lowercase character.
|
|
39
|
+
* - At least 1 uppercase character.
|
|
40
|
+
* - At least 1 digit.
|
|
41
|
+
*
|
|
42
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the created API secret.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const { id } = await secretClient.createSecret(
|
|
46
|
+
* 'new-api-key',
|
|
47
|
+
* 'SuperSecret123!'
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* console.log(`Created secret with ID ${id}`);
|
|
51
|
+
*/
|
|
7
52
|
async createSecret(apiKey, secret) {
|
|
8
53
|
const response = await this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret });
|
|
9
54
|
return response.data;
|
|
10
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Revoke (delete) an existing API secret for a given API key.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
60
|
+
* @param {string} id - The ID of the API secret to revoke.
|
|
61
|
+
* @return {Promise<void>} A promise that resolves when the secret has been revoked.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* await secretClient.deleteSecret('my-api-key', 'my-secret-id');
|
|
65
|
+
*/
|
|
11
66
|
async deleteSecret(apiKey, id) {
|
|
12
67
|
await this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
|
|
13
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve the details of a specific API secret for a given API key.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
73
|
+
* @param {string} id - The ID of the API secret to retrieve.
|
|
74
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the API secret.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const { id } = await secretClient.getSecret('my-api-key', 'my-secret-id');
|
|
78
|
+
* console.log(`Secret with ID ${id} has been retrieved`);
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
14
81
|
async getSecret(apiKey, id) {
|
|
15
82
|
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
|
|
16
83
|
return response.data;
|
|
17
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* List all the secrets associated with a particular API key.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} apiKey - The API key for which to list secrets.
|
|
89
|
+
*
|
|
90
|
+
* @return {Promise<ListAPISecretsResponse>} A promise that resolves to an object containing a list of API secrets.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* const response = await secretClient.listSecrets('my-api-key');
|
|
94
|
+
*
|
|
95
|
+
* for (const secret of response._embedded.secrets) {
|
|
96
|
+
* console.log(`Secret with ID ${secret.id} has been retrieved`);
|
|
97
|
+
* }
|
|
98
|
+
*/
|
|
18
99
|
async listSecrets(apiKey) {
|
|
19
100
|
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`);
|
|
20
101
|
return response.data;
|
|
21
102
|
}
|
|
22
103
|
}
|
|
23
104
|
exports.Secrets = Secrets;
|
|
24
|
-
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the callbacks associated with an account.
|
|
3
|
+
*/
|
|
4
|
+
export type AccountCallbacks = {
|
|
5
|
+
/**
|
|
6
|
+
* The default webhook URL for inbound SMS. If an SMS is received at a Vonage
|
|
7
|
+
* number that does not have its own inboud SMS webhook configured, Vonage
|
|
8
|
+
* makes a request here.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Send an empty string to unset this value.
|
|
12
|
+
*/
|
|
13
|
+
moCallBackUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The webhook URL that Vonage makes a request to when a
|
|
16
|
+
* delivery receipt is available for an SMS sent by one of your Vonage numbers.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Send an empty string to unset this value.
|
|
20
|
+
*/
|
|
21
|
+
drCallBackUrl?: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { APILinks } from '@vonage/server-client';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the response structure for an individual API secret.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Many of the Vonage APIs are accessed using an API key and secret. It is recommended to manage
|
|
7
|
+
* and occasionally rotate these secrets for security purposes. This structure provides details
|
|
8
|
+
* for a single API secret.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link APILinks}
|
|
11
|
+
*/
|
|
12
|
+
export type APISecretResponse = APILinks & {
|
|
13
|
+
/**
|
|
14
|
+
* The unique identifier for the API secret.
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* The timestamp indicating when the API secret was created.
|
|
19
|
+
*/
|
|
20
|
+
created_at: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the response structure when updating account settings.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Settings were updated if supplied; the details of the current settings are included in the response.
|
|
6
|
+
*/
|
|
7
|
+
export type AccountUpdateResponse = {
|
|
8
|
+
/**
|
|
9
|
+
* The current or updated inbound message webhook URI.
|
|
10
|
+
*/
|
|
11
|
+
'mo-callback-url': string;
|
|
12
|
+
/**
|
|
13
|
+
* The current or updated delivery receipt webhook URI.
|
|
14
|
+
*/
|
|
15
|
+
'dr-callback-url': string;
|
|
16
|
+
/**
|
|
17
|
+
* The maximum number of outbound messages per second.
|
|
18
|
+
*/
|
|
19
|
+
'max-outbound-request': number;
|
|
20
|
+
/**
|
|
21
|
+
* The maximum number of inbound messages per second.
|
|
22
|
+
*/
|
|
23
|
+
'max-inbound-request': number;
|
|
24
|
+
/**
|
|
25
|
+
* The maximum number of API calls per second.
|
|
26
|
+
*/
|
|
27
|
+
'max-calls-per-second': number;
|
|
28
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the response structure when querying for account balance.
|
|
3
|
+
*/
|
|
4
|
+
export type GetBalanceResponse = {
|
|
5
|
+
/**
|
|
6
|
+
* The current balance value.
|
|
7
|
+
*/
|
|
8
|
+
value: number;
|
|
9
|
+
/**
|
|
10
|
+
* Indicates if the auto-reload feature is enabled.
|
|
11
|
+
*/
|
|
12
|
+
autoReload: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { APISecretResponse } from './APISecretResponse';
|
|
2
|
+
import { APILinks } from '@vonage/server-client';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the response structure when listing API secrets.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
*
|
|
8
|
+
* Many of the Vonage APIs are accessed using an API key and secret. It is recommended that you
|
|
9
|
+
* change or "rotate" your secrets from time to time for security purposes. This section provides
|
|
10
|
+
* the API interface for achieving this. Note: to work on secrets for your secondary accounts,
|
|
11
|
+
* you may authenticate with your primary credentials and supply the secondary API keys as URL
|
|
12
|
+
* parameters to these API endpoints.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export type ListAPISecretsResponse = APILinks & {
|
|
16
|
+
/**
|
|
17
|
+
* Contains the embedded secrets information.
|
|
18
|
+
*/
|
|
19
|
+
_embedded: {
|
|
20
|
+
/**
|
|
21
|
+
* An array of API secrets.
|
|
22
|
+
* @see {@link APISecretResponse}
|
|
23
|
+
*/
|
|
24
|
+
secrets: APISecretResponse[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the response structure when performing a top-up operation for account balance.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* You can top up your account using this API when you have enabled auto-reload in the dashboard.
|
|
6
|
+
* The amount added by the top-up operation will be the same amount as was added in the payment when
|
|
7
|
+
* auto-reload was enabled. Your account balance is checked every 5-10 minutes and if it falls below
|
|
8
|
+
* the threshold and auto-reload is enabled, then it will be topped up automatically. Use this endpoint
|
|
9
|
+
* if you need to top up at times when your credit may be exhausted more quickly than the auto-reload
|
|
10
|
+
* may occur.
|
|
11
|
+
*/
|
|
12
|
+
export type TopUpBalanceResponse = {
|
|
13
|
+
/**
|
|
14
|
+
* The code associated with any potential errors during the top-up process.
|
|
15
|
+
*/
|
|
16
|
+
'error-code': string;
|
|
17
|
+
/**
|
|
18
|
+
* A descriptive label for the error code.
|
|
19
|
+
*/
|
|
20
|
+
'error-code-label': string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./APISecretResponse"), exports);
|
|
18
|
+
__exportStar(require("./AccountUpdateResponse"), exports);
|
|
19
|
+
__exportStar(require("./GetBalanceResponse"), exports);
|
|
20
|
+
__exportStar(require("./ListAPISecretsResponse"), exports);
|
|
21
|
+
__exportStar(require("./TopUpBalanceResponse"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AccountCallbacks"), exports);
|
|
18
|
+
__exportStar(require("./Response"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
2
3
|
"name": "@vonage/accounts",
|
|
3
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
4
5
|
"description": "Vonage Account Management API",
|
|
5
6
|
"homepage": "https://developer.vonage.com",
|
|
6
7
|
"bugs": {
|
|
@@ -11,7 +12,16 @@
|
|
|
11
12
|
"url": "git+https://github.com/Vonage/vonage-node-sdk.git"
|
|
12
13
|
},
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
|
-
"
|
|
15
|
+
"contributors": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Chris Tankersley",
|
|
18
|
+
"url": "https://github.com/dragonmantank"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Chuck \"MANCHUCK\" Reeves",
|
|
22
|
+
"url": "https://github.com/manchuck"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
15
25
|
"main": "dist/index.js",
|
|
16
26
|
"types": "dist/index.d.ts",
|
|
17
27
|
"directories": {
|
|
@@ -24,17 +34,17 @@
|
|
|
24
34
|
"scripts": {
|
|
25
35
|
"build": "npm run clean && npm run compile",
|
|
26
36
|
"clean": "npx shx rm -rf dist tsconfig.tsbuildinfo",
|
|
27
|
-
"compile": "npx tsc --build --verbose"
|
|
37
|
+
"compile": "npx tsc --build --verbose",
|
|
38
|
+
"prepublishOnly": "npm run build"
|
|
28
39
|
},
|
|
29
40
|
"dependencies": {
|
|
30
|
-
"@vonage/server-client": "^1.
|
|
41
|
+
"@vonage/server-client": "^1.10.0"
|
|
31
42
|
},
|
|
32
43
|
"devDependencies": {
|
|
33
|
-
"@vonage/auth": "^1.
|
|
34
|
-
"nock": "^13.3.
|
|
44
|
+
"@vonage/auth": "^1.8.0",
|
|
45
|
+
"nock": "^13.3.4"
|
|
35
46
|
},
|
|
36
47
|
"publishConfig": {
|
|
37
48
|
"directory": "dist"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "328f18e5c8a458cb4d06d7955ec2399a6ce6f5d8"
|
|
49
|
+
}
|
|
40
50
|
}
|
package/dist/accounts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../lib/accounts.ts"],"names":[],"mappings":";;;AAAA,yDAAkE;AAMlE,MAAa,QAAS,SAAQ,sBAAM;IACtB,QAAQ,GAAG,kCAAkB,CAAC,gBAAgB,CAAA;IAEjD,KAAK,CAAC,UAAU;QACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CACtC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,sBAAsB,CAChD,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,GAAW;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAC7C,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,iBAAiB,EACxC,EAAE,GAAG,EAAE,CACV,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAC/B,SAA2B;QAE3B,MAAM,QAAQ,GACV,MAAM,IAAI,CAAC,qBAAqB,CAC5B,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,mBAAmB,EAC1C,SAAS,CACZ,CAAA;QACL,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;CACJ;AA5BD,4BA4BC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountCallbacks.js","sourceRoot":"","sources":["../../lib/interfaces/AccountCallbacks.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"APISecretResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/APISecretResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountUpdateResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/AccountUpdateResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetBalanceResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/GetBalanceResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListAPISecretsResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/ListAPISecretsResponse.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TopUpBalanceResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/TopUpBalanceResponse.ts"],"names":[],"mappings":""}
|
package/dist/secrets.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../lib/secrets.ts"],"names":[],"mappings":";;;AAAA,yDAAkE;AAIlE,MAAa,OAAQ,SAAQ,sBAAM;IACrB,QAAQ,GAAG,kCAAkB,CAAC,KAAK,CAAA;IAEtC,KAAK,CAAC,YAAY,CACrB,MAAc,EACd,MAAc;QAEd,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CACvC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,aAAa,MAAM,UAAU,EACnD,EAAE,MAAM,EAAE,CACb,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,EAAU;QAChD,MAAM,IAAI,CAAC,iBAAiB,CACxB,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,aAAa,MAAM,YAAY,EAAE,EAAE,CAC5D,CAAA;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CAClB,MAAc,EACd,EAAU;QAEV,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CACtC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,aAAa,MAAM,YAAY,EAAE,EAAE,CAC5D,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,MAAc;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CACtC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,aAAa,MAAM,UAAU,CACtD,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;CACJ;AApCD,0BAoCC"}
|