5.0.3 • Published 11 months ago

@ringcentral/subscriptions v5.0.3

Weekly downloads
101
License
MIT
Repository
github
Last release
11 months ago

RingCentral Subscriptions SDK

This project is a proxy project to the WebSocket Extension of the RingCentral Extensible project.

For new users, you are recommended to use this project directly.

Please do read this article: Create WebSocket subscriptions using RingCentral JavaScript SDKs.

App permissions required

Your RingCentral app needs to have the "WebSocket Subscriptions" permission. If you don't know how to enabled it, please contact dev support.

Installation

yarn add @ringcentral/sdk @ringcentral/subscriptions

Usage sample

import {SDK} from '@ringcentral/sdk';
import {Subscriptions} from '@ringcentral/subscriptions';

// init
const sdk = new SDK({
  server: process.env.RINGCENTRAL_SERVER_URL,
  clientId: process.env.RINGCENTRAL_CLIENT_ID,
  clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
});
const platform = sdk.platform();
const subscriptions = new Subscriptions({
  sdk: sdk,
});

const main = async () => {
  // login
  await platform.login({
    username: process.env.RINGCENTRAL_USERNAME,
    extension: process.env.RINGCENTRAL_EXTENSION,
    password: process.env.RINGCENTRAL_PASSWORD,
  });

  // subscribe
  const subscription = subscriptions.createSubscription();
  subscription.on(subscription.events.notification, evt => {
    console.log(JSON.stringify(evt, null, 2));
  });
  await subscription
    .setEventFilters(['/restapi/v1.0/account/~/extension/~/message-store'])
    .register();

  // trigger events
  const r = await platform.get('/restapi/v1.0/account/~/extension/~');
  const ext = await r.json();
  platform.post('/restapi/v1.0/account/~/extension/~/company-pager', {
    from: {extensionId: ext.id},
    to: [{extensionId: ext.id}],
    text: 'Hello world!',
  });
};

main();

Traditional way

Let's say you just want to use plain HTML and JavaScript without any fancy technology such as webpack/parcel/TypeScript...etc.

Please refer to the RingCentral SPA Demo.

Simply put:

<script type="text/javascript" src="https://unpkg.com/@ringcentral/sdk@latest/dist/ringcentral.js"></script>
<script type="text/javascript" src="https://unpkg.com/@ringcentral/subscriptions@0.0.1-master.4079103221.135.0/dist/ringcentral-subscriptions.js"></script>

...


const rc = new RingCentral.SDK({
  server,
  clientId,
});

...

const subscriptions = new RingCentral.Subscriptions({
  sdk: rc
});
const subscription = subscriptions.createSubscription();

...

@ringcentral/subscriptions@0.0.1-master.4079103221.135.0 was the latest nightly build when I was writing this documentation. Please choose a proper version yourself.

5.0.3

11 months ago

5.0.2

12 months ago

0.0.1-fixci.0

1 year ago

5.0.1

2 years ago

5.0.0

2 years ago

4.7.4

2 years ago

4.7.3

3 years ago

4.7.2

3 years ago

4.7.1

3 years ago

4.6.2

3 years ago

4.7.0

3 years ago

4.6.1

4 years ago

4.6.0

4 years ago

4.5.1

4 years ago

4.5.0

4 years ago

4.4.3

4 years ago

4.4.2

4 years ago

4.4.1

4 years ago

4.4.0

5 years ago

4.3.3

5 years ago

4.3.2

5 years ago

4.3.1

5 years ago

4.3.0

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago

4.0.0

6 years ago

4.0.0-alpha.7

6 years ago

4.0.0-alpha.6

6 years ago

3.1.2-alpha.31

6 years ago

3.1.2-alpha.30

6 years ago

4.0.0-alpha.5

6 years ago

4.0.0-alpha.4

6 years ago

4.0.0-alpha.3

6 years ago

4.0.0-alpha.2

6 years ago

4.0.0-alpha.1

7 years ago

4.0.0-alpha.0

7 years ago