@vonage/accounts 1.17.2 → 1.17.3
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/{types → cjs}/accounts.d.ts +9 -4
- package/dist/cjs/accounts.js +107 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +198 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{types → cjs}/secrets.d.ts +7 -4
- package/dist/cjs/secrets.js +114 -0
- package/dist/{types → cjs}/types/AccountCallbacks.d.ts +3 -2
- package/dist/cjs/types/AccountCallbacks.js +18 -0
- package/dist/{types → cjs}/types/Response/APISecretResponse.d.ts +4 -2
- package/dist/cjs/types/Response/APISecretResponse.js +18 -0
- package/dist/{types → cjs}/types/Response/AccountUpdateResponse.d.ts +3 -2
- package/dist/cjs/types/Response/AccountUpdateResponse.js +18 -0
- package/dist/{types → cjs}/types/Response/GetBalanceResponse.d.ts +3 -2
- package/dist/cjs/types/Response/GetBalanceResponse.js +18 -0
- package/dist/{types → cjs}/types/Response/ListAPISecretsResponse.d.ts +4 -2
- package/dist/cjs/types/Response/ListAPISecretsResponse.js +18 -0
- package/dist/{types → cjs}/types/Response/TopUpBalanceResponse.d.ts +3 -2
- package/dist/cjs/types/Response/TopUpBalanceResponse.js +18 -0
- package/dist/cjs/types/Response/index.d.ts +6 -0
- package/dist/cjs/types/Response/index.js +18 -0
- package/dist/cjs/types/index.d.ts +7 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/esm/{accounts.js → accounts.d.mts} +13 -16
- package/dist/esm/accounts.mjs +6 -0
- package/dist/esm/chunk-AH2I45CK.mjs +90 -0
- package/dist/esm/chunk-B47CNM5C.mjs +0 -0
- package/dist/esm/chunk-BKKPM5GV.mjs +0 -0
- package/dist/esm/chunk-DZH5TJEI.mjs +0 -0
- package/dist/esm/chunk-EX4P4VER.mjs +0 -0
- package/dist/esm/chunk-FH36GGNJ.mjs +0 -0
- package/dist/esm/chunk-QS5DQYR7.mjs +0 -0
- package/dist/esm/chunk-R3PGV5SN.mjs +83 -0
- package/dist/esm/chunk-XH3JJPB6.mjs +0 -0
- package/dist/esm/chunk-ZH2BJGUB.mjs +0 -0
- package/dist/esm/index.d.mts +9 -0
- package/dist/esm/index.mjs +18 -0
- package/dist/esm/{secrets.js → secrets.d.mts} +12 -19
- package/dist/esm/secrets.mjs +6 -0
- package/dist/esm/types/AccountCallbacks.d.mts +24 -0
- package/dist/esm/types/AccountCallbacks.mjs +1 -0
- package/dist/esm/types/Response/APISecretResponse.d.mts +24 -0
- package/dist/esm/types/Response/APISecretResponse.mjs +1 -0
- package/dist/esm/types/Response/AccountUpdateResponse.d.mts +30 -0
- package/dist/esm/types/Response/AccountUpdateResponse.mjs +1 -0
- package/dist/esm/types/Response/GetBalanceResponse.d.mts +15 -0
- package/dist/esm/types/Response/GetBalanceResponse.mjs +1 -0
- package/dist/esm/types/Response/ListAPISecretsResponse.d.mts +29 -0
- package/dist/esm/types/Response/ListAPISecretsResponse.mjs +1 -0
- package/dist/esm/types/Response/TopUpBalanceResponse.d.mts +23 -0
- package/dist/esm/types/Response/TopUpBalanceResponse.mjs +1 -0
- package/dist/esm/types/Response/index.d.mts +6 -0
- package/dist/esm/types/Response/index.mjs +6 -0
- package/dist/esm/types/index.d.mts +7 -0
- package/dist/esm/types/index.mjs +8 -0
- package/package.json +24 -29
- package/dist/cjs/accounts.cjs +0 -106
- package/dist/cjs/accounts.js.map +0 -1
- package/dist/cjs/index.cjs +0 -23
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/secrets.cjs +0 -102
- package/dist/cjs/secrets.js.map +0 -1
- package/dist/cjs/types/AccountCallbacks.cjs +0 -3
- package/dist/cjs/types/AccountCallbacks.js.map +0 -1
- package/dist/cjs/types/Response/APISecretResponse.cjs +0 -3
- package/dist/cjs/types/Response/APISecretResponse.js.map +0 -1
- package/dist/cjs/types/Response/AccountUpdateResponse.cjs +0 -3
- package/dist/cjs/types/Response/AccountUpdateResponse.js.map +0 -1
- package/dist/cjs/types/Response/GetBalanceResponse.cjs +0 -3
- package/dist/cjs/types/Response/GetBalanceResponse.js.map +0 -1
- package/dist/cjs/types/Response/ListAPISecretsResponse.cjs +0 -3
- package/dist/cjs/types/Response/ListAPISecretsResponse.js.map +0 -1
- package/dist/cjs/types/Response/TopUpBalanceResponse.cjs +0 -3
- package/dist/cjs/types/Response/TopUpBalanceResponse.js.map +0 -1
- package/dist/cjs/types/Response/index.cjs +0 -22
- package/dist/cjs/types/Response/index.js.map +0 -1
- package/dist/cjs/types/index.cjs +0 -19
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/esm/accounts.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/secrets.js.map +0 -1
- package/dist/esm/types/AccountCallbacks.js +0 -2
- package/dist/esm/types/AccountCallbacks.js.map +0 -1
- package/dist/esm/types/Response/APISecretResponse.js +0 -2
- package/dist/esm/types/Response/APISecretResponse.js.map +0 -1
- package/dist/esm/types/Response/AccountUpdateResponse.js +0 -2
- package/dist/esm/types/Response/AccountUpdateResponse.js.map +0 -1
- package/dist/esm/types/Response/GetBalanceResponse.js +0 -2
- package/dist/esm/types/Response/GetBalanceResponse.js.map +0 -1
- package/dist/esm/types/Response/ListAPISecretsResponse.js +0 -2
- package/dist/esm/types/Response/ListAPISecretsResponse.js.map +0 -1
- package/dist/esm/types/Response/TopUpBalanceResponse.js +0 -2
- package/dist/esm/types/Response/TopUpBalanceResponse.js.map +0 -1
- package/dist/esm/types/Response/index.js +0 -6
- package/dist/esm/types/Response/index.js.map +0 -1
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/index.js.map +0 -1
- package/dist/types/accounts.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/secrets.d.ts.map +0 -1
- package/dist/types/types/AccountCallbacks.d.ts.map +0 -1
- package/dist/types/types/Response/APISecretResponse.d.ts.map +0 -1
- package/dist/types/types/Response/AccountUpdateResponse.d.ts.map +0 -1
- package/dist/types/types/Response/GetBalanceResponse.d.ts.map +0 -1
- package/dist/types/types/Response/ListAPISecretsResponse.d.ts.map +0 -1
- package/dist/types/types/Response/TopUpBalanceResponse.d.ts.map +0 -1
- package/dist/types/types/Response/index.d.ts +0 -6
- package/dist/types/types/Response/index.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -3
- package/dist/types/types/index.d.ts.map +0 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* if you need to top up at times when your credit may be exhausted more quickly than the auto-reload
|
|
10
10
|
* may occur.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
type TopUpBalanceResponse = {
|
|
13
13
|
/**
|
|
14
14
|
* The code associated with any potential errors during the top-up process.
|
|
15
15
|
*/
|
|
@@ -19,4 +19,5 @@ export type TopUpBalanceResponse = {
|
|
|
19
19
|
*/
|
|
20
20
|
'error-code-label': string;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
export type { TopUpBalanceResponse };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// lib/types/Response/TopUpBalanceResponse.ts
|
|
17
|
+
var TopUpBalanceResponse_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(TopUpBalanceResponse_exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { APISecretResponse } from './APISecretResponse.js';
|
|
2
|
+
export { AccountUpdateResponse } from './AccountUpdateResponse.js';
|
|
3
|
+
export { GetBalanceResponse } from './GetBalanceResponse.js';
|
|
4
|
+
export { ListAPISecretsResponse } from './ListAPISecretsResponse.js';
|
|
5
|
+
export { TopUpBalanceResponse } from './TopUpBalanceResponse.js';
|
|
6
|
+
import '@vonage/server-client';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// lib/types/Response/index.ts
|
|
17
|
+
var Response_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(Response_exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AccountCallbacks } from './AccountCallbacks.js';
|
|
2
|
+
export { APISecretResponse } from './Response/APISecretResponse.js';
|
|
3
|
+
export { AccountUpdateResponse } from './Response/AccountUpdateResponse.js';
|
|
4
|
+
export { GetBalanceResponse } from './Response/GetBalanceResponse.js';
|
|
5
|
+
export { ListAPISecretsResponse } from './Response/ListAPISecretsResponse.js';
|
|
6
|
+
export { TopUpBalanceResponse } from './Response/TopUpBalanceResponse.js';
|
|
7
|
+
import '@vonage/server-client';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// lib/types/index.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Client, AuthenticationType } from '@vonage/server-client';
|
|
2
|
+
import { AccountCallbacks } from './types/AccountCallbacks.mjs';
|
|
3
|
+
import { AccountUpdateResponse } from './types/Response/AccountUpdateResponse.mjs';
|
|
4
|
+
import { GetBalanceResponse } from './types/Response/GetBalanceResponse.mjs';
|
|
5
|
+
import { TopUpBalanceResponse } from './types/Response/TopUpBalanceResponse.mjs';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* Client class to interact with the Account API which enables users to manage
|
|
4
9
|
* their Vonage API Account programmatically.
|
|
@@ -30,11 +35,11 @@ import { AuthenticationType, Client } from '@vonage/server-client';
|
|
|
30
35
|
* const accountClient = vonage.account;
|
|
31
36
|
* ```
|
|
32
37
|
*/
|
|
33
|
-
|
|
38
|
+
declare class Accounts extends Client {
|
|
34
39
|
/**
|
|
35
40
|
* @see {@link Client.authType}
|
|
36
41
|
*/
|
|
37
|
-
authType
|
|
42
|
+
protected authType: AuthenticationType;
|
|
38
43
|
/**
|
|
39
44
|
* Retrieves the current balance of the Vonage API account.
|
|
40
45
|
* @see {@link https://rest.nexmo.com/account/get-balance}
|
|
@@ -47,10 +52,7 @@ export class Accounts extends Client {
|
|
|
47
52
|
* console.log(`The current account balance is ${balance.value} ${balance.currency}`);
|
|
48
53
|
* console.log(`Auto-reload is ${balance.autoReload ? 'enabled' : 'disabled'}`);
|
|
49
54
|
*/
|
|
50
|
-
|
|
51
|
-
const response = await this.sendGetRequest(`${this.config.restHost}/account/get-balance`);
|
|
52
|
-
return response.data;
|
|
53
|
-
}
|
|
55
|
+
getBalance(): Promise<GetBalanceResponse>;
|
|
54
56
|
/**
|
|
55
57
|
* Tops up the account balance when auto-reload is enabled.
|
|
56
58
|
* The top-up amount corresponds to the amount added when auto-reload was enabled.
|
|
@@ -69,10 +71,7 @@ export class Accounts extends Client {
|
|
|
69
71
|
* }
|
|
70
72
|
*
|
|
71
73
|
*/
|
|
72
|
-
|
|
73
|
-
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx });
|
|
74
|
-
return response.data;
|
|
75
|
-
}
|
|
74
|
+
topUpBalance(trx: string): Promise<TopUpBalanceResponse>;
|
|
76
75
|
/**
|
|
77
76
|
* Updates the default webhook URLs associated with the account for:
|
|
78
77
|
* - Inbound SMS messages
|
|
@@ -94,9 +93,7 @@ export class Accounts extends Client {
|
|
|
94
93
|
* console.log(`New ${key}: ${value}`);
|
|
95
94
|
* }
|
|
96
95
|
*/
|
|
97
|
-
|
|
98
|
-
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks);
|
|
99
|
-
return response.data;
|
|
100
|
-
}
|
|
96
|
+
updateAccountCallbacks(callbacks: AccountCallbacks): Promise<AccountUpdateResponse>;
|
|
101
97
|
}
|
|
102
|
-
|
|
98
|
+
|
|
99
|
+
export { Accounts };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// lib/secrets.ts
|
|
2
|
+
import { AuthenticationType, Client } from "@vonage/server-client";
|
|
3
|
+
var Secrets = class extends Client {
|
|
4
|
+
authType = AuthenticationType.BASIC;
|
|
5
|
+
/**
|
|
6
|
+
* Create a new API secret for a given API key.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
9
|
+
* @param {string} secret - The new secret. It must follow the provided rules:
|
|
10
|
+
* - Minimum 8 characters.
|
|
11
|
+
* - Maximum 25 characters.
|
|
12
|
+
* - At least 1 lowercase character.
|
|
13
|
+
* - At least 1 uppercase character.
|
|
14
|
+
* - At least 1 digit.
|
|
15
|
+
*
|
|
16
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the created API secret.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const { id } = await secretClient.createSecret(
|
|
20
|
+
* 'new-api-key',
|
|
21
|
+
* 'SuperSecret123!'
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* console.log(`Created secret with ID ${id}`);
|
|
25
|
+
*/
|
|
26
|
+
async createSecret(apiKey, secret) {
|
|
27
|
+
const response = await this.sendPostRequest(
|
|
28
|
+
`${this.config.apiHost}/accounts/${apiKey}/secrets`,
|
|
29
|
+
{ secret }
|
|
30
|
+
);
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Revoke (delete) an existing API secret for a given API key.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} apiKey - The API key to manage secrets for.
|
|
37
|
+
* @param {string} id - The ID of the API secret to revoke.
|
|
38
|
+
* @return {Promise<void>} A promise that resolves when the secret has been revoked.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* await secretClient.deleteSecret('my-api-key', 'my-secret-id');
|
|
42
|
+
*/
|
|
43
|
+
async deleteSecret(apiKey, id) {
|
|
44
|
+
await this.sendDeleteRequest(
|
|
45
|
+
`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the details of a specific 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 retrieve.
|
|
53
|
+
* @return {Promise<APISecretResponse>} A promise that resolves to an object representing the API secret.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const { id } = await secretClient.getSecret('my-api-key', 'my-secret-id');
|
|
57
|
+
* console.log(`Secret with ID ${id} has been retrieved`);
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
async getSecret(apiKey, id) {
|
|
61
|
+
const response = await this.sendGetRequest(
|
|
62
|
+
`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`
|
|
63
|
+
);
|
|
64
|
+
return response.data;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* List all the secrets associated with a particular API key.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} apiKey - The API key for which to list secrets.
|
|
70
|
+
*
|
|
71
|
+
* @return {Promise<ListAPISecretsResponse>} A promise that resolves to an object containing a list of API secrets.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const response = await secretClient.listSecrets('my-api-key');
|
|
75
|
+
*
|
|
76
|
+
* for (const secret of response._embedded.secrets) {
|
|
77
|
+
* console.log(`Secret with ID ${secret.id} has been retrieved`);
|
|
78
|
+
* }
|
|
79
|
+
*/
|
|
80
|
+
async listSecrets(apiKey) {
|
|
81
|
+
const response = await this.sendGetRequest(
|
|
82
|
+
`${this.config.apiHost}/accounts/${apiKey}/secrets`
|
|
83
|
+
);
|
|
84
|
+
return response.data;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
Secrets
|
|
90
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// lib/accounts.ts
|
|
2
|
+
import { AuthenticationType, Client } from "@vonage/server-client";
|
|
3
|
+
var Accounts = class extends Client {
|
|
4
|
+
/**
|
|
5
|
+
* @see {@link Client.authType}
|
|
6
|
+
*/
|
|
7
|
+
authType = AuthenticationType.BASIC;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the current balance of the Vonage API account.
|
|
10
|
+
* @see {@link https://rest.nexmo.com/account/get-balance}
|
|
11
|
+
* @return {Promise<GetBalanceResponse>} The current balance of the account in EUR.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* const balance = await accontClient.getBalance();
|
|
16
|
+
*
|
|
17
|
+
* console.log(`The current account balance is ${balance.value} ${balance.currency}`);
|
|
18
|
+
* console.log(`Auto-reload is ${balance.autoReload ? 'enabled' : 'disabled'}`);
|
|
19
|
+
*/
|
|
20
|
+
async getBalance() {
|
|
21
|
+
const response = await this.sendGetRequest(
|
|
22
|
+
`${this.config.restHost}/account/get-balance`
|
|
23
|
+
);
|
|
24
|
+
return response.data;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tops up the account balance when auto-reload is enabled.
|
|
28
|
+
* The top-up amount corresponds to the amount added when auto-reload was enabled.
|
|
29
|
+
* @see {@link https://rest.nexmo.com/account/top-up}
|
|
30
|
+
* @param {string} trx - The transaction reference for the balance addition and auto-reload activation.
|
|
31
|
+
* @return {Promise<TopUpBalanceResponse>} Response indicating the success of the operation.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* const response = await accountClient.topUpBalance('00X123456Y7890123Z');
|
|
36
|
+
*
|
|
37
|
+
* if (response['error-code'] === '200') {
|
|
38
|
+
* console.log(`The account balance has been topped up`);
|
|
39
|
+
* } else {
|
|
40
|
+
* console.log(`The account balance could not be topped up`);
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
async topUpBalance(trx) {
|
|
45
|
+
const response = await this.sendFormSubmitRequest(
|
|
46
|
+
`${this.config.restHost}/account/top-up`,
|
|
47
|
+
{ trx }
|
|
48
|
+
);
|
|
49
|
+
return response.data;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Updates the default webhook URLs associated with the account for:
|
|
53
|
+
* - Inbound SMS messages
|
|
54
|
+
* - Delivery receipts
|
|
55
|
+
* @see {@link https://rest.nexmo.com/account/settings}
|
|
56
|
+
* @param {AccountCallbacks} callbacks - The new callback URLs for the account.
|
|
57
|
+
* @return {Promise<AccountUpdateResponse>} Details of the updated or current settings.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* const callbacks = {
|
|
62
|
+
* moCallBackUrl: 'https://example.com/webhooks/inbound-sms',
|
|
63
|
+
* drCallBackUrl: 'https://example.com/webhooks/delivery-receipts',
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* const response = await accountClient.updateAccountCallbacks(callbacks);
|
|
67
|
+
*
|
|
68
|
+
* for (const [key, value] of Object.entries(response)) {
|
|
69
|
+
* console.log(`New ${key}: ${value}`);
|
|
70
|
+
* }
|
|
71
|
+
*/
|
|
72
|
+
async updateAccountCallbacks(callbacks) {
|
|
73
|
+
const response = await this.sendFormSubmitRequest(
|
|
74
|
+
`${this.config.restHost}/account/settings`,
|
|
75
|
+
callbacks
|
|
76
|
+
);
|
|
77
|
+
return response.data;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
Accounts
|
|
83
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Accounts } from './accounts.mjs';
|
|
2
|
+
export { Secrets } from './secrets.mjs';
|
|
3
|
+
export { AccountCallbacks } from './types/AccountCallbacks.mjs';
|
|
4
|
+
export { APISecretResponse } from './types/Response/APISecretResponse.mjs';
|
|
5
|
+
export { AccountUpdateResponse } from './types/Response/AccountUpdateResponse.mjs';
|
|
6
|
+
export { GetBalanceResponse } from './types/Response/GetBalanceResponse.mjs';
|
|
7
|
+
export { ListAPISecretsResponse } from './types/Response/ListAPISecretsResponse.mjs';
|
|
8
|
+
export { TopUpBalanceResponse } from './types/Response/TopUpBalanceResponse.mjs';
|
|
9
|
+
import '@vonage/server-client';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Accounts
|
|
3
|
+
} from "./chunk-R3PGV5SN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Secrets
|
|
6
|
+
} from "./chunk-AH2I45CK.mjs";
|
|
7
|
+
import "./chunk-QS5DQYR7.mjs";
|
|
8
|
+
import "./chunk-ZH2BJGUB.mjs";
|
|
9
|
+
import "./chunk-XH3JJPB6.mjs";
|
|
10
|
+
import "./chunk-BKKPM5GV.mjs";
|
|
11
|
+
import "./chunk-DZH5TJEI.mjs";
|
|
12
|
+
import "./chunk-FH36GGNJ.mjs";
|
|
13
|
+
import "./chunk-EX4P4VER.mjs";
|
|
14
|
+
import "./chunk-B47CNM5C.mjs";
|
|
15
|
+
export {
|
|
16
|
+
Accounts,
|
|
17
|
+
Secrets
|
|
18
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Client, AuthenticationType } from '@vonage/server-client';
|
|
2
|
+
import { APISecretResponse } from './types/Response/APISecretResponse.mjs';
|
|
3
|
+
import { ListAPISecretsResponse } from './types/Response/ListAPISecretsResponse.mjs';
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Client class to interact with the Account API to create secrets in
|
|
4
7
|
* their Vonage API Account programmatically.
|
|
@@ -20,8 +23,8 @@ import { AuthenticationType, Client } from '@vonage/server-client';
|
|
|
20
23
|
* ```
|
|
21
24
|
*
|
|
22
25
|
*/
|
|
23
|
-
|
|
24
|
-
authType
|
|
26
|
+
declare class Secrets extends Client {
|
|
27
|
+
protected authType: AuthenticationType;
|
|
25
28
|
/**
|
|
26
29
|
* Create a new API secret for a given API key.
|
|
27
30
|
*
|
|
@@ -43,10 +46,7 @@ export class Secrets extends Client {
|
|
|
43
46
|
*
|
|
44
47
|
* console.log(`Created secret with ID ${id}`);
|
|
45
48
|
*/
|
|
46
|
-
|
|
47
|
-
const response = await this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret });
|
|
48
|
-
return response.data;
|
|
49
|
-
}
|
|
49
|
+
createSecret(apiKey: string, secret: string): Promise<APISecretResponse>;
|
|
50
50
|
/**
|
|
51
51
|
* Revoke (delete) an existing API secret for a given API key.
|
|
52
52
|
*
|
|
@@ -57,9 +57,7 @@ export class Secrets extends Client {
|
|
|
57
57
|
* @example
|
|
58
58
|
* await secretClient.deleteSecret('my-api-key', 'my-secret-id');
|
|
59
59
|
*/
|
|
60
|
-
|
|
61
|
-
await this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
|
|
62
|
-
}
|
|
60
|
+
deleteSecret(apiKey: string, id: string): Promise<void>;
|
|
63
61
|
/**
|
|
64
62
|
* Retrieve the details of a specific API secret for a given API key.
|
|
65
63
|
*
|
|
@@ -72,10 +70,7 @@ export class Secrets extends Client {
|
|
|
72
70
|
* console.log(`Secret with ID ${id} has been retrieved`);
|
|
73
71
|
*
|
|
74
72
|
*/
|
|
75
|
-
|
|
76
|
-
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
|
|
77
|
-
return response.data;
|
|
78
|
-
}
|
|
73
|
+
getSecret(apiKey: string, id: string): Promise<APISecretResponse>;
|
|
79
74
|
/**
|
|
80
75
|
* List all the secrets associated with a particular API key.
|
|
81
76
|
*
|
|
@@ -90,9 +85,7 @@ export class Secrets extends Client {
|
|
|
90
85
|
* console.log(`Secret with ID ${secret.id} has been retrieved`);
|
|
91
86
|
* }
|
|
92
87
|
*/
|
|
93
|
-
|
|
94
|
-
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`);
|
|
95
|
-
return response.data;
|
|
96
|
-
}
|
|
88
|
+
listSecrets(apiKey: string): Promise<ListAPISecretsResponse>;
|
|
97
89
|
}
|
|
98
|
-
|
|
90
|
+
|
|
91
|
+
export { Secrets };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the callbacks associated with an account.
|
|
3
|
+
*/
|
|
4
|
+
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
|
+
};
|
|
23
|
+
|
|
24
|
+
export type { AccountCallbacks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-DZH5TJEI.mjs";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { APILinks } from '@vonage/server-client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the response structure for an individual API secret.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Many of the Vonage APIs are accessed using an API key and secret. It is recommended to manage
|
|
8
|
+
* and occasionally rotate these secrets for security purposes. This structure provides details
|
|
9
|
+
* for a single API secret.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link APILinks}
|
|
12
|
+
*/
|
|
13
|
+
type APISecretResponse = APILinks & {
|
|
14
|
+
/**
|
|
15
|
+
* The unique identifier for the API secret.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* The timestamp indicating when the API secret was created.
|
|
20
|
+
*/
|
|
21
|
+
created_at: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type { APISecretResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../chunk-FH36GGNJ.mjs";
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
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
|
+
};
|
|
29
|
+
|
|
30
|
+
export type { AccountUpdateResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../chunk-EX4P4VER.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the response structure when querying for account balance.
|
|
3
|
+
*/
|
|
4
|
+
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
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { GetBalanceResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../chunk-B47CNM5C.mjs";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { APISecretResponse } from './APISecretResponse.mjs';
|
|
2
|
+
import { APILinks } from '@vonage/server-client';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents the response structure when listing API secrets.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
*
|
|
9
|
+
* Many of the Vonage APIs are accessed using an API key and secret. It is recommended that you
|
|
10
|
+
* change or "rotate" your secrets from time to time for security purposes. This section provides
|
|
11
|
+
* the API interface for achieving this. Note: to work on secrets for your secondary accounts,
|
|
12
|
+
* you may authenticate with your primary credentials and supply the secondary API keys as URL
|
|
13
|
+
* parameters to these API endpoints.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
type ListAPISecretsResponse = APILinks & {
|
|
17
|
+
/**
|
|
18
|
+
* Contains the embedded secrets information.
|
|
19
|
+
*/
|
|
20
|
+
_embedded: {
|
|
21
|
+
/**
|
|
22
|
+
* An array of API secrets.
|
|
23
|
+
* @see {@link APISecretResponse}
|
|
24
|
+
*/
|
|
25
|
+
secrets: APISecretResponse[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type { ListAPISecretsResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../chunk-XH3JJPB6.mjs";
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
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
|
+
};
|
|
22
|
+
|
|
23
|
+
export type { TopUpBalanceResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../chunk-BKKPM5GV.mjs";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { APISecretResponse } from './APISecretResponse.mjs';
|
|
2
|
+
export { AccountUpdateResponse } from './AccountUpdateResponse.mjs';
|
|
3
|
+
export { GetBalanceResponse } from './GetBalanceResponse.mjs';
|
|
4
|
+
export { ListAPISecretsResponse } from './ListAPISecretsResponse.mjs';
|
|
5
|
+
export { TopUpBalanceResponse } from './TopUpBalanceResponse.mjs';
|
|
6
|
+
import '@vonage/server-client';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AccountCallbacks } from './AccountCallbacks.mjs';
|
|
2
|
+
export { APISecretResponse } from './Response/APISecretResponse.mjs';
|
|
3
|
+
export { AccountUpdateResponse } from './Response/AccountUpdateResponse.mjs';
|
|
4
|
+
export { GetBalanceResponse } from './Response/GetBalanceResponse.mjs';
|
|
5
|
+
export { ListAPISecretsResponse } from './Response/ListAPISecretsResponse.mjs';
|
|
6
|
+
export { TopUpBalanceResponse } from './Response/TopUpBalanceResponse.mjs';
|
|
7
|
+
import '@vonage/server-client';
|