This is just a personal project. Users should use RingCentral Extensible SDK instead.
Concise JavaScript SDK for RingCentral.
yarn add ringcentral-js-concise
<script src="https://unpkg.com/axios@0.18.0/dist/axios.min.js"></script>
<script src="https://unpkg.com/ringcentral-js-concise@0.5.4/dist/ringcentral.js"></script>
ringcentral-js-concise
depends on axios
. With the code above you will have a global variable named RingCentral.default
.
import RingCentral from 'ringcentral-js-concise'
(async () => {
const rc = new RingCentral(process.env.RINGCENTRAL_CLIENT_ID, process.env.RINGCENTRAL_CLIENT_SECRET, process.env.RINGCENTRAL_SERVER_URL)
await rc.authorize({ username: process.env.RINGCENTRAL_USERNAME, extension: process.env.RINGCENTRAL_EXTENSION, password: process.env.RINGCENTRAL_PASSWORD })
const r = await rc.get('/restapi/v1.0/account/~/extension/~')
const extension = r.data
console.log(extension)
})()
const token = rc.token() // get
rc.token(token) // set
Token expires. You can call rc.refresh()
to refresh token. But normally you don't need to do that because this library will refresh for you if access token expired.
Please refer to test cases.
import PubNub from 'ringcentral-js-concise/dist/pubnub'
Check the PubNub sample code
The underlying HTTP library is axios.
The 4th parameter of RingCentral
's constructor allows you to specify a custom axios Instance:
const rc = new RingCentral(clientId, clientSecret, server, axiosInstance)
The 4th parameter is optional, if you omit it, a default axiosInstance
with be used.
mv .sample.env .env
edit .env
yarn test