@vonage/accounts
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -1,38 +0,20 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Accounts = void 0; | ||
const server_client_1 = require("@vonage/server-client"); | ||
class Accounts extends server_client_1.Client { | ||
import { AuthenticationType, Client } from '@vonage/server-client'; | ||
export class Accounts extends Client { | ||
constructor() { | ||
super(...arguments); | ||
this.authType = server_client_1.AuthenticationType.QUERY_KEY_SECRET; | ||
this.authType = AuthenticationType.QUERY_KEY_SECRET; | ||
} | ||
getBalance() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendGetRequest(`${this.config.restHost}/account/get-balance`); | ||
return response.data; | ||
}); | ||
async getBalance() { | ||
const response = await this.sendGetRequest(`${this.config.restHost}/account/get-balance`); | ||
return response.data; | ||
} | ||
topUpBalance(trx) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx }); | ||
return response.data; | ||
}); | ||
async topUpBalance(trx) { | ||
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/top-up`, { trx }); | ||
return response.data; | ||
} | ||
updateAccountCallbacks(callbacks) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks); | ||
return response.data; | ||
}); | ||
async updateAccountCallbacks(callbacks) { | ||
const response = await this.sendFormSubmitRequest(`${this.config.restHost}/account/settings`, callbacks); | ||
return response.data; | ||
} | ||
} | ||
exports.Accounts = Accounts; | ||
//# sourceMappingURL=accounts.js.map |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Secrets = exports.Accounts = void 0; | ||
var accounts_1 = require("./accounts"); | ||
Object.defineProperty(exports, "Accounts", { enumerable: true, get: function () { return accounts_1.Accounts; } }); | ||
var secrets_1 = require("./secrets"); | ||
Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_1.Secrets; } }); | ||
export { Accounts } from './accounts'; | ||
export { Secrets } from './secrets'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=AccountCallbacks.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=AccountUpdateResponse.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=APISecretResponse.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=GetBalanceResponse.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=ListAPISecretsResponse.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=TopUpBalanceResponse.js.map |
@@ -1,43 +0,23 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Secrets = void 0; | ||
const server_client_1 = require("@vonage/server-client"); | ||
class Secrets extends server_client_1.Client { | ||
import { AuthenticationType, Client } from '@vonage/server-client'; | ||
export class Secrets extends Client { | ||
constructor() { | ||
super(...arguments); | ||
this.authType = server_client_1.AuthenticationType.BASIC; | ||
this.authType = AuthenticationType.BASIC; | ||
} | ||
createSecret(apiKey, secret) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret }); | ||
return response.data; | ||
}); | ||
async createSecret(apiKey, secret) { | ||
const response = await this.sendPostRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`, { secret }); | ||
return response.data; | ||
} | ||
deleteSecret(apiKey, id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`); | ||
}); | ||
async deleteSecret(apiKey, id) { | ||
await this.sendDeleteRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`); | ||
} | ||
getSecret(apiKey, id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`); | ||
return response.data; | ||
}); | ||
async getSecret(apiKey, id) { | ||
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets/${id}`); | ||
return response.data; | ||
} | ||
listSecrets(apiKey) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`); | ||
return response.data; | ||
}); | ||
async listSecrets(apiKey) { | ||
const response = await this.sendGetRequest(`${this.config.apiHost}/accounts/${apiKey}/secrets`); | ||
return response.data; | ||
} | ||
} | ||
exports.Secrets = Secrets; | ||
//# sourceMappingURL=secrets.js.map |
{ | ||
"name": "@vonage/accounts", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Vonage Account Management API", | ||
@@ -26,18 +26,16 @@ "homepage": "https://developer.vonage.com", | ||
"build": "npm run clean && npm run compile", | ||
"clean": "tsc -b --clean", | ||
"compile": "tsc -p tsconfig.json", | ||
"format": "prettier --write \"lib/**/*.ts\"", | ||
"lint": "tslint -p tsconfig.json", | ||
"prepublishOnly": "npm run build && npm run test && npm run lint", | ||
"test": "npx jest", | ||
"test-watch": "npx jest --watch", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A lib" | ||
"clean": "npx shx rm -rf dist tsconfig.tsbuildinfo", | ||
"compile": "npx tsc --build --verbose" | ||
}, | ||
"dependencies": { | ||
"@vonage/server-client": "^1.0.6" | ||
"@vonage/server-client": "^1.0.7" | ||
}, | ||
"devDependencies": { | ||
"@vonage/auth": "^1.0.4", | ||
"nock": "^13.2.9" | ||
}, | ||
"publishConfig": { | ||
"directory": "dist" | ||
} | ||
}, | ||
"gitHead": "328f18e5c8a458cb4d06d7955ec2399a6ce6f5d8" | ||
} |
# Vonage Accounts SDK for Node.js | ||
![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) | ||
![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/npm/v/@vonage/accounts) | ||
[![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/accounts?label=License&style=flat-square)][license] | ||
[![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] | ||
<img src="https://developer.nexmo.com/images/logos/vbc-logo.svg" height="48px" alt="Vonage" /> | ||
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]. | ||
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]. | ||
We recommend using this package as part of the overall [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk). | ||
We recommend using this package as part of the overall | ||
[`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk). | ||
For full API documentation refer to [developer.nexmo.com](https://developer.nexmo.com/). | ||
For full API documentation refer to [developer.vonage.com](https://developer.vonage.com/). | ||
* [Installation](#installation) | ||
* [Constructor](#constructor) | ||
* [Callbacks](#callbacks) | ||
* [Usage](#using-the-vonage-accounts-sdk) | ||
* [Promises](#promises) | ||
* [Testing](#testing) | ||
* [Examples](#examples) | ||
* [Supported APIs](#supported-apis) | ||
## Installation | ||
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. | ||
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. | ||
You can also use this SDK standalone if you only need access to just the Accounts API. | ||
### With NPM | ||
```bash | ||
npm install @vonage/account | ||
npm install @vonage/accounts | ||
``` | ||
@@ -36,3 +42,3 @@ | ||
```bash | ||
yarn add @vonage/account | ||
yarn add @vonage/accounts | ||
``` | ||
@@ -44,3 +50,4 @@ | ||
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. | ||
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. | ||
@@ -64,3 +71,7 @@ ```js | ||
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. | ||
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. | ||
@@ -71,38 +82,19 @@ ```js | ||
const accountClient = new Accounts(new Auth({ | ||
const credentials = new Auth({ | ||
apiKey: API_KEY, | ||
apiSecret: API_SECRET, | ||
}), options); | ||
``` | ||
}); | ||
* `apiKey` - API Key from Vonage API. If `applicationId` and `privateKey` are present, `apiKey` is optional. | ||
* `apiSecret` - API SECRET from Vonage API. If `applicationId` and `privateKey` are present, `apiSecret` is optional. | ||
* `options` is an object that can contain: | ||
const options = {} | ||
```js | ||
{ | ||
// If true, log information to the console | ||
debug: true|false, | ||
// append info the the User-Agent sent to Nexmo | ||
// e.g. pass 'my-app' for /nexmo-node/1.0.0/4.2.7/my-app | ||
appendToUserAgent: string, | ||
// Set a custom logger | ||
logger: { | ||
log: function() {level, args...} | ||
info: function() {args...}, | ||
warn: function() {args...} | ||
}, | ||
// Set a custom timeout for requests to Nexmo in milliseconds. Defaults to the standard for Node http requests, which is 120,000 ms. | ||
timeout: integer, | ||
// Set a custom host for requests instead of api.nexmo.com | ||
apiHost: string, | ||
// Set a custom host for requests instead of rest.nexmo.com | ||
restHost: string | ||
} | ||
const accountClient = new Accounts(credentials, options); | ||
``` | ||
`credentials` is any option from [`@vonage/auth`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/auth#options), | ||
and `options` is any option from [`@vonage/server-client`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/server-client#options) | ||
## Promises | ||
Most methods that interact with the Vonage API uses Promises. You can either resolve these yourself, or use `await` to | ||
wait for a response. | ||
Most methods that interact with the Vonage API uses Promises. You can either | ||
resolve these yourself, or use `await` to wait for a response. | ||
@@ -109,0 +101,0 @@ ```js |
29
11964
2
111
115
Updated@vonage/server-client@^1.0.7