Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: meetings package #788

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const config: Config.InitialOptions = {
testMatch: ['<rootDir>/packages/messages/__tests__/**/*.test.ts'],
coveragePathIgnorePatterns: ['node_modules', '__tests__'],
},
{
displayName: 'MEETINGS',
testMatch: ['<rootDir>/packages/meetings/__tests__/**/*.test.ts'],
coveragePathIgnorePatterns: ['node_modules', '__tests__'],
},
{
displayName: 'NUMBER INSIGHTS',
testMatch: [
Expand Down
3,841 changes: 1,179 additions & 2,662 deletions package-lock.json

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions packages/meetings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Vonage Meetings 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/meetings)
[![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/meetings?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 Meetings 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-number-sdk)
* [Theme Files](#uploading-theme-images)
* [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
Meetings API.

### With NPM

```bash
npm install @vonage/meetings
```

### With Yarn

```bash
yarn add @vonage/meetings
```

## Using the Vonage Meetings 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 `meetings` 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);

(async () =>{
for await (const room of vonage.meetings.getRooms()) {
console.log(room);
}
})();


```

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

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

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

const meetingsClient = new Meetings(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)

## Uploading theme images

The SDK will handle all the steps for uploading images to your theme. All you need to do is pass in the `themeId`, `logoType` and the path the image file:

```js
const { Auth } = require('@vonage/auth');
const { Meetings, LogoType } = require('@vonage/meetings');

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

const meetingsClient = new Meetings(credentials, options);

(async () => {
await meetingsClient.uploadIcon('my-theme', LogoType.WHITE, '/path/to/image.png'),
})()
```

For more information see [Uploading Icons and Logos](https://developer.vonage.com/en/meetings/code-snippets/theme-management#uploading-icons-and-logos)

## 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.meetings.getRoom(roomId);

vonage.meetings.getRoom(roomId)
.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
141 changes: 141 additions & 0 deletions packages/meetings/__tests__/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import nock from 'nock';
import { Auth } from '@vonage/auth';
import { Meetings } from '../lib/index';
import { readFileSync } from 'fs';
import {
ThemeDomain,
MeetingType,
JoinType,
MicrophoneSate,
RoomLanguage,
} from '../lib/enums';
import { Theme, MeetingRoom } from '../lib/types';

const testKey = readFileSync(`${__dirname}/private.test.key`).toString();

const checkAuth = (value) => value.startsWith('Bearer ') && value.length > 10;

export const BASE_URL = 'https://api-eu.vonage.com';
export const BASE_PATH = '/beta';

export const roomLinks = {
host_url: {
href: 'https://example.vonage.com/rooms/host',
},
guest_url: {
href: 'https://example.vonage.com/rooms/guest',
},
};

export const getClient = (): Meetings =>
new Meetings(
new Auth({
applicationId: 'abcd-1234',
privateKey: testKey,
}),
);

export const getScope = (): nock =>
nock(BASE_URL, {
reqheaders: {
authorization: checkAuth,
},
}).persist();

export const roomOne: MeetingRoom = {
id: '3ff993a8-deb0-4bd2-8fed-e190ee6114c4',
displayName: 'Room 1',
metadata: null,
type: MeetingType.LONG_TERM,
expiresAt: '2024-01-17T15:53:03.377Z',
recordingOptions: {
autoRecord: false,
recordOnlyOwner: false,
},
meetingCode: '1234567890',
createdAt: '2023-01-17T15:54:07.299Z',
isAvailable: true,
expireAfterUse: true,
themeId: null,
initialJoinOptions: {
microphoneState: MicrophoneSate.OFF,
},
joinApprovalLevel: JoinType.EXPLICT_APPROVAL,
uiSettings: {
language: RoomLanguage.DEFAULT,
},
availableFeatures: {
isRecordingAvailable: true,
isChatAvailable: true,
isWhiteboardAvailable: true,
isLocaleSwitcherAvailable: true,
},
hostUrl: roomLinks.host_url.href,
guestUrl: roomLinks.guest_url.href,
};

export const roomTwo: MeetingRoom = {
id: 'b52c4ded-fc4c-4bed-bada-6ad33fa37b76',
displayName: 'Room 2',
metadata: null,
type: MeetingType.INSTANT,
expiresAt: '2024-01-17T15:53:03.377Z',
recordingOptions: {
autoRecord: false,
recordOnlyOwner: false,
},
meetingCode: '1234567890',
createdAt: '2023-01-17T15:54:07.299Z',
isAvailable: true,
expireAfterUse: true,
themeId: null,
initialJoinOptions: {
microphoneState: MicrophoneSate.OFF,
},
joinApprovalLevel: JoinType.AFTER_OWNER_ONLY,
uiSettings: {
language: RoomLanguage.EN,
},
availableFeatures: {
isRecordingAvailable: true,
isChatAvailable: true,
isWhiteboardAvailable: true,
isLocaleSwitcherAvailable: true,
},
hostUrl: roomLinks.host_url.href,
guestUrl: roomLinks.guest_url.href,
};

export const themeOne: Theme = {
themeId: '91882dd4-f673-4b5b-a1e2-a94475091896',
themeName: 'Theme one',
domain: ThemeDomain.VBC,
accountId: 'abcd1234',
applicationId: 'acd8853c-1a20-40d8-9a48-9ff91d3850ab',
mainColor: '#2a2a2a',
shortCompanyUrl: 'vonage',
brandText: 'Node SDK',
brandImageColored: null,
brandImageWhite: null,
brandedFavicon: null,
brandImageWhiteUrl: null,
brandImageColoredUrl: null,
brandedFaviconUrl: null,
};

export const themeTwo: Theme = {
themeId: '1af8e55f-5ad4-4dd2-901c-492ef0a1561d',
themeName: 'Theme Two',
domain: ThemeDomain.VBC,
accountId: 'abcd1234',
applicationId: '73c6ddda-28bb-4c28-88d7-df3e54826368',
mainColor: '#2a2a2a',
shortCompanyUrl: 'vonage',
brandText: 'Node SDK',
brandImageColored: null,
brandImageWhite: null,
brandedFavicon: null,
brandImageWhiteUrl: null,
brandImageColoredUrl: null,
brandedFaviconUrl: null,
};
Loading