@vonage/accounts 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +116 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,122 @@
1
- # `@vonage/accounts`
1
+ # Vonage Accounts SDK for Node.js
2
2
 
3
- > TODO: description
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
4
 
5
- ## Usage
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]
6
6
 
7
+ <img src="https://developer.nexmo.com/images/logos/vbc-logo.svg" height="48px" alt="Vonage" />
8
+
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].
10
+
11
+ We recommend using this package as part of the overall [`@vonage/server-sdk` package](https://github.com/vonage/vonage-node-sdk).
12
+
13
+ For full API documentation refer to [developer.nexmo.com](https://developer.nexmo.com/).
14
+
15
+ * [Installation](#installation)
16
+ * [Constructor](#constructor)
17
+ * [Callbacks](#callbacks)
18
+ * [Testing](#testing)
19
+ * [Examples](#examples)
20
+ * [Supported APIs](#supported-apis)
21
+
22
+ ## Installation
23
+
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.
25
+
26
+ You can also use this SDK standalone if you only need access to just the Accounts API.
27
+ ### With NPM
28
+
29
+ ```bash
30
+ npm install @vonage/account
31
+ ```
32
+
33
+ ### With Yarn
34
+
35
+ ```bash
36
+ yarn add @vonage/account
37
+ ```
38
+
39
+ ## Using the Vonage Accounts SDK
40
+
41
+ ### As part of the Vonage Server SDK
42
+
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.
44
+
45
+ ```js
46
+ const { Vonage } = require('@vonage/server-sdk');
47
+
48
+ const vonage = new Vonage({
49
+ apiKey: API_KEY,
50
+ apiSecret: API_SECRET,
51
+ applicationId: APP_ID,
52
+ privateKey: PRIVATE_KEY_PATH,
53
+ signatureSecret: SIGNATURE_SECRET,
54
+ signatureMethod: SIGNATURE_METHOD
55
+ }, options);
56
+
57
+ const balance = await vonage.accounts.getBalance();
7
58
  ```
8
- const accounts = require('@vonage/accounts');
9
59
 
10
- // TODO: DEMONSTRATE API
60
+ ### Standalone
61
+
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.
63
+
64
+ ```js
65
+ const { Auth } = require('@vonage/auth');
66
+ const { Accounts } = require('@vonage/account');
67
+
68
+ const accountClient = new Accounts(new Auth({
69
+ apiKey: API_KEY,
70
+ apiSecret: API_SECRET,
71
+ }), options);
11
72
  ```
73
+
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:
77
+
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
+ }
98
+ ```
99
+
100
+ ## Promises
101
+
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.
104
+
105
+ ```js
106
+ const balance = await accountClient.getBalance();
107
+
108
+ accountClient.getBalance()
109
+ .then(resp => console.log(resp))
110
+ .catch(err => console.error(err));
111
+ ```
112
+
113
+ ## Testing
114
+
115
+ Run:
116
+
117
+ ```bash
118
+ npm run test
119
+ ```
120
+
121
+ [signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
122
+ [license]: ../../LICENSE.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/accounts",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vonage Account Management API",
5
5
  "homepage": "https://developer.vonage.com",
6
6
  "bugs": {
@@ -34,7 +34,7 @@
34
34
  "version": "npm run format && git add -A lib"
35
35
  },
36
36
  "dependencies": {
37
- "@vonage/server-client": "^1.0.0"
37
+ "@vonage/server-client": "^1.0.1"
38
38
  },
39
39
  "publishConfig": {
40
40
  "directory": "dist"