Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RingCentral from 'ringcentral-js-concise'
- import PubNub from 'ringcentral-js-concise/src/pubnub.es5'
- import delay from 'timeout-as-promise'
- const rc = new RingCentral(
- process.env.RINGCENTRAL_CLIENT_ID,
- process.env.RINGCENTRAL_CLIENT_SECRET,
- process.env.RINGCENTRAL_SERVER_URL
- )
- ;(async () => {
- try {
- await rc.authorize({
- username: process.env.RINGCENTRAL_USERNAME,
- extension: process.env.RINGCENTRAL_EXTENSION,
- password: process.env.RINGCENTRAL_PASSWORD
- })
- console.log(rc.token())
- const pubnub = new PubNub(rc, ['/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true'], async message => {
- console.log(JSON.stringify(message.body.activeCalls, null, 2))
- })
- await pubnub.subscribe()
- console.log(pubnub.subscription())
- await delay(36000000)
- } catch (e) {
- console.log(e.response.data)
- } finally {
- await rc.revoke()
- }
- })()
Add Comment
Please, Sign In to add comment