Guest User

Untitled

a guest
Dec 6th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import RingCentral from 'ringcentral-js-concise'
  2. import PubNub from 'ringcentral-js-concise/src/pubnub.es5'
  3. import delay from 'timeout-as-promise'
  4.  
  5. const rc = new RingCentral(
  6. process.env.RINGCENTRAL_CLIENT_ID,
  7. process.env.RINGCENTRAL_CLIENT_SECRET,
  8. process.env.RINGCENTRAL_SERVER_URL
  9. )
  10.  
  11. ;(async () => {
  12. try {
  13. await rc.authorize({
  14. username: process.env.RINGCENTRAL_USERNAME,
  15. extension: process.env.RINGCENTRAL_EXTENSION,
  16. password: process.env.RINGCENTRAL_PASSWORD
  17. })
  18. console.log(rc.token())
  19. const pubnub = new PubNub(rc, ['/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true'], async message => {
  20. console.log(JSON.stringify(message.body.activeCalls, null, 2))
  21. })
  22. await pubnub.subscribe()
  23. console.log(pubnub.subscription())
  24. await delay(36000000)
  25. } catch (e) {
  26. console.log(e.response.data)
  27. } finally {
  28. await rc.revoke()
  29. }
  30. })()
Add Comment
Please, Sign In to add comment