Skip to content

Commit

Permalink
feat: audit package
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Jan 12, 2023
1 parent 628c931 commit 12bd547
Show file tree
Hide file tree
Showing 15 changed files with 707 additions and 67 deletions.
144 changes: 79 additions & 65 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,72 +1,86 @@
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
coverageDirectory: '<rootDir>/coverage/',
projects: [
{
displayName: "ACCOUNTS",
testMatch: ['<rootDir>/packages/accounts/__tests__/**/*.test.ts'],
},
{
displayName: "APPLICATIONS",
testMatch: ['<rootDir>/packages/applications/__tests__/**/*.test.ts'],
},
{
displayName: "AUTH",
testMatch: ['<rootDir>/packages/auth/__tests__/**/*.test.ts'],
},
{
displayName: "JWT",
testMatch: ['<rootDir>/packages/jwt/__tests__/**/*.test.ts'],
},
{
displayName: "MESSAGES",
testMatch: ['<rootDir>/packages/messages/__tests__/**/*.test.ts'],
},
{
displayName: "NUMBER INSIGHTS",
testMatch: ['<rootDir>/packages/number-insights/__tests__/**/*.test.ts'],
},
{
displayName: "NUMBERS",
testMatch: ['<rootDir>/packages/numbers/__tests__/**/*.test.ts'],
},
{
displayName: "PRICING",
testMatch: ['<rootDir>/packages/pricing/__tests__/**/*.test.ts'],
},
{
displayName: "SERVER CLIENT",
testMatch: ['<rootDir>/packages/server-client/__tests__/**/*.test.ts'],
},
{
displayName: "SERVER SDK",
testMatch: ['<rootDir>/packages/server-sdk/__tests__/**/*.test.ts'],
},
{
displayName: "SMS",
testMatch: ['<rootDir>/packages/sms/__tests__/**/*.test.ts'],
},
{
displayName: "VERIFY",
testMatch: ['<rootDir>/packages/verify/__tests__/**/*.test.ts'],
},
{
displayName: "VETCH",
testMatch: ['<rootDir>/packages/vetch/__tests__/**/*.test.ts'],
},
{
displayName: "VIDEO",
testMatch: ['<rootDir>/packages/video/__tests__/**/*.test.ts'],
},
{
displayName: "VOICE",
testMatch: ['<rootDir>/packages/voice/__tests__/**/*.test.ts'],
},
],
moduleNameMapper: {
'@vonage/(.+)': '<rootDir>/packages/$1/lib',
coverageDirectory: '<rootDir>/coverage/',
projects: [
{
displayName: 'ACCOUNTS',
testMatch: ['<rootDir>/packages/accounts/__tests__/**/*.test.ts'],
},
{
displayName: 'APPLICATIONS',
testMatch: [
'<rootDir>/packages/applications/__tests__/**/*.test.ts',
],
},
{
displayName: 'AUDIT',
testMatch: ['<rootDir>/packages/audit/__tests__/**/*.test.ts'],
},
{
displayName: 'AUDIT',
testMatch: ['<rootDir>/packages/audit/tests__/**/*.test.ts'],
},
{
displayName: 'AUTH',
testMatch: ['<rootDir>/packages/auth/__tests__/**/*.test.ts'],
},
{
displayName: 'JWT',
testMatch: ['<rootDir>/packages/jwt/__tests__/**/*.test.ts'],
},
{
displayName: 'MESSAGES',
testMatch: ['<rootDir>/packages/messages/__tests__/**/*.test.ts'],
},
{
displayName: 'NUMBER INSIGHTS',
testMatch: [
'<rootDir>/packages/number-insights/__tests__/**/*.test.ts',
],
},
{
displayName: 'NUMBERS',
testMatch: ['<rootDir>/packages/numbers/__tests__/**/*.test.ts'],
},
{
displayName: 'PRICING',
testMatch: ['<rootDir>/packages/pricing/__tests__/**/*.test.ts'],
},
{
displayName: 'SERVER CLIENT',
testMatch: [
'<rootDir>/packages/server-client/__tests__/**/*.test.ts',
],
},
{
displayName: 'SERVER SDK',
testMatch: ['<rootDir>/packages/server-sdk/__tests__/**/*.test.ts'],
},
{
displayName: 'SMS',
testMatch: ['<rootDir>/packages/sms/__tests__/**/*.test.ts'],
},
{
displayName: 'VERIFY',
testMatch: ['<rootDir>/packages/verify/__tests__/**/*.test.ts'],
},
{
displayName: 'VETCH',
testMatch: ['<rootDir>/packages/vetch/__tests__/**/*.test.ts'],
},
{
displayName: 'VIDEO',
testMatch: ['<rootDir>/packages/video/__tests__/**/*.test.ts'],
},
{
displayName: 'VOICE',
testMatch: ['<rootDir>/packages/voice/__tests__/**/*.test.ts'],
},
],
moduleNameMapper: {
'@vonage/(.+)': '<rootDir>/packages/$1/lib',
},
};

export default config;
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 114 additions & 0 deletions packages/audit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Vonage Number 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/npm/v/@vonage/numbers)
[![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/numbers?label=License&style=flat-square)][license]

<img src="https://developer.nexmo.com/images/logos/vbc-logo.svg" height="48px" alt="Vonage" />

This is the Vonage Number 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).

For full API documentation refer to [developer.nexmo.com](https://developer.nexmo.com/).

* [Installation](#installation)
* [Usage](#using-the-vonage-numbers-sdk)
* [Promises](#promises)
* [Testing](#testing)

## 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
Numbers API.

### With NPM

```bash
npm install @vonage/numbers
```

### With Yarn

```bash
yarn add @vonage/numbers
```

## Using the Vonage Numbers SDK

### As part of the Vonage Server SDK

If you are using this SDK as part of the Vonage Server SDK, you can access it
as the `numbers` property off of the client that you instantiate.

```js
const { Vonage, Auth } = require('@vonage/server-sdk');

const credentials = new Auth({
apiKey: API_KEY,
apiSecret: API_SECRET
});
const options = {};
const vonage = new Vonage(credentials, options);

vonage.numbers.getAvailableNumbers()
.then(resp => console.log(resp))
.catch(err => console.error(err));
```

### Standalone

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 Numbers API. All you need to do is
`require('@vonage/numbers')`, and use the returned object to create your own
client.

```js
const { Auth } = require('@vonage/auth');
const { Numbers } = require('@vonage/numbers');

const credentials = new Auth({
apiKey: API_KEY,
apiSecret: API_SECRET
});
const options = {};

const numbersClient = new Numbers(credentials, options);
```

Where `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.

```js
const resp = await vonage.numbers.basicLookup(PHONE_NUMBER)

vonage.numbers.getAvailableNumbers()
.then(resp => console.log(resp))
.catch(err => console.error(err));
```

## Testing

Run:

```bash
npm run test
```

[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
[license]: ../../LICENSE.txt
26 changes: 26 additions & 0 deletions packages/audit/__tests__/__dataSets__/getEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const BASE_URL = 'https://api.nexmo.com/';
const CLIENT_METHOD = 'getEvent';

export default [
{
label: 'get event',
clientMethod: CLIENT_METHOD,
exception: false,
request: {
url: BASE_URL,
intercept: [`/beta/audit/events/asdf`, 'GET'],
reply: [
200,
{
id: 'asdf',
created_at: '2022-11-15T17:30:33',
},
],
},
parameters: ['asdf'],
expected: {
id: 'asdf',
createdAt: '2022-11-15T17:30:33',
},
},
];
Loading

0 comments on commit 12bd547

Please sign in to comment.