@vonage/accounts 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,46 +1,53 @@
1
1
  # Vonage Accounts SDK for Node.js
2
2
 
3
- ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/vonage/vonage-node-sdk/Vonage/3.x?logo=github&style=flat-square&label=Workflow%20Build) [![Codecov](https://img.shields.io/codecov/c/github/vonage/vonage-node-sdk?label=Codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/Vonage/vonage-server-sdk) ![Latest Release](https://img.shields.io/github/v/release/vonage/vonage-node-sdk?logo=npm&style=flat-square)
4
-
5
- [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](../../CODE_OF_CONDUCT.md) [![License](https://img.shields.io/npm/l/@vonage/server-sdk?label=License&style=flat-square)][../../LICENSE.TXT]
3
+ ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/vonage/vonage-node-sdk/Vonage/3.x?logo=github&style=flat-square&label=Workflow%20Build)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/vonage/vonage-node-sdk?label=Codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/Vonage/vonage-server-sdk)
5
+ ![Latest Release](https://img.shields.io/npm/v/@vonage/accounts)
6
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](../../CODE_OF_CONDUCT.md)
7
+ [![License](https://img.shields.io/npm/l/@vonage/accounts?label=License&style=flat-square)][license]
6
8
 
7
9
  <img src="https://developer.nexmo.com/images/logos/vbc-logo.svg" height="48px" alt="Vonage" />
8
10
 
9
- This is the Vonage Account SDK for Node.js for use with [Vonage APIs](https://www.vonage.com/). To use it you will need a Vonage account. Sign up [for free at vonage.com][signup].
11
+ This is the Vonage Account SDK for Node.js for use with
12
+ [Vonage APIs](https://www.vonage.com/). To use it you will need a Vonage
13
+ account. Sign up [for free at vonage.com][signup].
10
14
 
11
- We recommend using this package as part of the overall [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk).
15
+ We recommend using this package as part of the overall
16
+ [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk).
12
17
 
13
- For full API documentation refer to [developer.nexmo.com](https://developer.nexmo.com/).
18
+ For full API documentation refer to [developer.vonage.com](https://developer.vonage.com/).
14
19
 
15
20
  * [Installation](#installation)
16
- * [Constructor](#constructor)
17
- * [Callbacks](#callbacks)
21
+ * [Usage](#using-the-vonage-accounts-sdk)
22
+ * [Promises](#promises)
18
23
  * [Testing](#testing)
19
- * [Examples](#examples)
20
- * [Supported APIs](#supported-apis)
21
24
 
22
25
  ## Installation
23
26
 
24
- We recommend using this SDK as part of the overall [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk). Please see the main package for installation.
27
+ We recommend using this SDK as part of the overall
28
+ [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk).
29
+ Please see the main package for installation.
25
30
 
26
31
  You can also use this SDK standalone if you only need access to just the Accounts API.
32
+
27
33
  ### With NPM
28
34
 
29
35
  ```bash
30
- npm install @vonage/account
36
+ npm install @vonage/accounts
31
37
  ```
32
38
 
33
39
  ### With Yarn
34
40
 
35
41
  ```bash
36
- yarn add @vonage/account
42
+ yarn add @vonage/accounts
37
43
  ```
38
44
 
39
45
  ## Using the Vonage Accounts SDK
40
46
 
41
47
  ### As part of the Vonage Server SDK
42
48
 
43
- If you are using this SDK as part of the Vonage Server SDK, you can access it as the `accounts` property off of the client that you instantiate.
49
+ If you are using this SDK as part of the Vonage Server SDK, you can access it
50
+ as the `accounts` property off of the client that you instantiate.
44
51
 
45
52
  ```js
46
53
  const { Vonage } = require('@vonage/server-sdk');
@@ -59,48 +66,33 @@ const balance = await vonage.accounts.getBalance();
59
66
 
60
67
  ### Standalone
61
68
 
62
- The SDK can be used standalone from the main [Vonage Server SDK for Node.js](https://github.com/vonage/vonage-node-sdk) if you only need to use the Account APIs. All you need to do is `require('@vonage/account')`, and use the returned object to create your own client.
69
+ The SDK can be used standalone from the main
70
+ [Vonage Server SDK for Node.js](https://github.com/vonage/vonage-node-sdk) if
71
+ you only need to use the Account APIs. All you need to do is
72
+ `require('@vonage/account')`, and use the returned object to create your own
73
+ client.
63
74
 
64
75
  ```js
65
76
  const { Auth } = require('@vonage/auth');
66
77
  const { Accounts } = require('@vonage/account');
67
78
 
68
- const accountClient = new Accounts(new Auth({
79
+ const credentials = new Auth({
69
80
  apiKey: API_KEY,
70
81
  apiSecret: API_SECRET,
71
- }), options);
72
- ```
82
+ });
73
83
 
74
- * `apiKey` - API Key from Vonage API. If `applicationId` and `privateKey` are present, `apiKey` is optional.
75
- * `apiSecret` - API SECRET from Vonage API. If `applicationId` and `privateKey` are present, `apiSecret` is optional.
76
- * `options` is an object that can contain:
84
+ const options = {}
77
85
 
78
- ```js
79
- {
80
- // If true, log information to the console
81
- debug: true|false,
82
- // append info the the User-Agent sent to Nexmo
83
- // e.g. pass 'my-app' for /nexmo-node/1.0.0/4.2.7/my-app
84
- appendToUserAgent: string,
85
- // Set a custom logger
86
- logger: {
87
- log: function() {level, args...}
88
- info: function() {args...},
89
- warn: function() {args...}
90
- },
91
- // Set a custom timeout for requests to Nexmo in milliseconds. Defaults to the standard for Node http requests, which is 120,000 ms.
92
- timeout: integer,
93
- // Set a custom host for requests instead of api.nexmo.com
94
- apiHost: string,
95
- // Set a custom host for requests instead of rest.nexmo.com
96
- restHost: string
97
- }
86
+ const accountClient = new Accounts(credentials, options);
98
87
  ```
99
88
 
89
+ `credentials` is any option from [`@vonage/auth`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/auth#options),
90
+ and `options` is any option from [`@vonage/server-client`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/server-client#options)
91
+
100
92
  ## Promises
101
93
 
102
- Most methods that interact with the Vonage API uses Promises. You can either resolve these yourself, or use `await` to
103
- wait for a response.
94
+ Most methods that interact with the Vonage API uses Promises. You can either
95
+ resolve these yourself, or use `await` to wait for a response.
104
96
 
105
97
  ```js
106
98
  const balance = await accountClient.getBalance();
package/dist/accounts.js CHANGED
@@ -1,38 +1,20 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Accounts = void 0;
13
- const server_client_1 = require("@vonage/server-client");
14
- class Accounts extends server_client_1.Client {
1
+ import { AuthenticationType, Client } from '@vonage/server-client';
2
+ export class Accounts extends Client {
15
3
  constructor() {
16
4
  super(...arguments);
17
- this.authType = server_client_1.AuthenticationType.QUERY_KEY_SECRET;
5
+ this.authType = AuthenticationType.QUERY_KEY_SECRET;
18
6
  }
19
- getBalance() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const response = yield this.sendGetRequest(`${this.config.restHost}/account/get-balance`);
22
- return response.data;
23
- });
7
+ async getBalance() {
8
+ const response = await this.sendGetRequest(`${this.config.restHost}/account/get-balance`);
9
+ return response.data;
24
10
  }
25
- topUpBalance(trx) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const response = yield this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx });
28
- return response.data;
29
- });
11
+ async topUpBalance(trx) {
12
+ const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx });
13
+ return response.data;
30
14
  }
31
- updateAccountCallbacks(callbacks) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const response = yield this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks);
34
- return response.data;
35
- });
15
+ async updateAccountCallbacks(callbacks) {
16
+ const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks);
17
+ return response.data;
36
18
  }
37
19
  }
38
- exports.Accounts = Accounts;
20
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../lib/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAMlE,MAAM,OAAO,QAAS,SAAQ,MAAM;IAApC;;QACc,aAAQ,GAAG,kBAAkB,CAAC,gBAAgB,CAAA;IA2B5D,CAAC;IAzBU,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"}
package/dist/index.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Secrets = exports.Accounts = void 0;
4
- var accounts_1 = require("./accounts");
5
- Object.defineProperty(exports, "Accounts", { enumerable: true, get: function () { return accounts_1.Accounts; } });
6
- var secrets_1 = require("./secrets");
7
- Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_1.Secrets; } });
1
+ export { Accounts } from './accounts';
2
+ export { Secrets } from './secrets';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=AccountCallbacks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountCallbacks.js","sourceRoot":"","sources":["../../lib/interfaces/AccountCallbacks.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=APISecretResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APISecretResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/APISecretResponse.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=AccountUpdateResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountUpdateResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/AccountUpdateResponse.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=GetBalanceResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetBalanceResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/GetBalanceResponse.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=ListAPISecretsResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListAPISecretsResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/ListAPISecretsResponse.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=TopUpBalanceResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TopUpBalanceResponse.js","sourceRoot":"","sources":["../../../lib/interfaces/Response/TopUpBalanceResponse.ts"],"names":[],"mappings":""}
package/dist/secrets.js CHANGED
@@ -1,43 +1,23 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Secrets = void 0;
13
- const server_client_1 = require("@vonage/server-client");
14
- class Secrets extends server_client_1.Client {
1
+ import { AuthenticationType, Client } from '@vonage/server-client';
2
+ export class Secrets extends Client {
15
3
  constructor() {
16
4
  super(...arguments);
17
- this.authType = server_client_1.AuthenticationType.BASIC;
5
+ this.authType = AuthenticationType.BASIC;
18
6
  }
19
- createSecret(apiKey, secret) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const response = yield this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret });
22
- return response.data;
23
- });
7
+ async createSecret(apiKey, secret) {
8
+ const response = await this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret });
9
+ return response.data;
24
10
  }
25
- deleteSecret(apiKey, id) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- yield this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
28
- });
11
+ async deleteSecret(apiKey, id) {
12
+ await this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
29
13
  }
30
- getSecret(apiKey, id) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const response = yield this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
33
- return response.data;
34
- });
14
+ async getSecret(apiKey, id) {
15
+ const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`);
16
+ return response.data;
35
17
  }
36
- listSecrets(apiKey) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const response = yield this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`);
39
- return response.data;
40
- });
18
+ async listSecrets(apiKey) {
19
+ const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`);
20
+ return response.data;
41
21
  }
42
22
  }
43
- exports.Secrets = Secrets;
23
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../lib/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAIlE,MAAM,OAAO,OAAQ,SAAQ,MAAM;IAAnC;;QACc,aAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAA;IAmCjD,CAAC;IAjCU,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/accounts",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Vonage Account Management API",
5
5
  "homepage": "https://developer.vonage.com",
6
6
  "bugs": {
@@ -23,20 +23,18 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "build": "npm run clean && npm run compile",
26
- "clean": "tsc -b --clean",
27
- "compile": "tsc -p tsconfig.json",
28
- "format": "prettier --write \"lib/**/*.ts\"",
29
- "lint": "tslint -p tsconfig.json",
30
- "prepublishOnly": "npm run build && npm run test && npm run lint",
31
- "test": "npx jest",
32
- "test-watch": "npx jest --watch",
33
- "preversion": "npm run lint",
34
- "version": "npm run format && git add -A lib"
26
+ "clean": "npx shx rm -rf dist tsconfig.tsbuildinfo",
27
+ "compile": "npx tsc --build --verbose"
35
28
  },
36
29
  "dependencies": {
37
- "@vonage/server-client": "^1.0.5"
30
+ "@vonage/server-client": "^1.0.7"
31
+ },
32
+ "devDependencies": {
33
+ "@vonage/auth": "^1.0.4",
34
+ "nock": "^13.2.9"
38
35
  },
39
36
  "publishConfig": {
40
37
  "directory": "dist"
41
- }
38
+ },
39
+ "gitHead": "328f18e5c8a458cb4d06d7955ec2399a6ce6f5d8"
42
40
  }