Moved to ringcentral/ringcentral-extensible
This SDK supports both RingCentral REST API and RingCentral Events & Notifications.
It provides unifed programming interface to transport protocol HTTPS and WebSocket:
- For RingCentral REST API, you can access it via either HTTPS or WebSocket.
- For RingCentral Events & Notifications, you can set it up with either WebSocket or WebHook.
yarn add ringcentral-typescript
or
npm install ringcentral-typescript --save
Then you should be able to import the SDK like this:
import RestCentral from 'ringcentral-typescript';
or
const RestCentral = require('ringcentral-typescript').default;
You can also find lots of useful code snippets from the test cases.
By default, HTTPS is the transport protocol. If you'd like to use WebSocket as transport protocol, you need to sepcify wsgOptions
when creating a RingCentral
instance:
const restOptions = { ... };
const wsgOptions = {
server: 'wss://ws-api.devtest.ringcentral.com/ws', // for sandbox
// server: 'wss://ws-api.ringcentral.com/ws', // for production
};
const rc = new RingCentral(restOptions, wsgOptions);
The you can set the default tranport protocol to wss
:
rc.defaults.tranport = 'wss';
The transport protocol can also be specified when making an API call:
const extInfo = await rc
.restapi()
.account()
.extension()
.get({transport: 'wss'});
To use HTTPS as transport protocol, just specify tranport
as 'https'
.
Some sample code for binary content downloading may not work.
Because RingCentral is gradually migrating binary content to CDN such as media.ringcentral.com
.
For example, to download the attachment of a fax:
// `message` is the fax message object
const r = await rc.get(message.attachments[0].uri, undefined, { responseType: 'arraybuffer' })
const content = r.data
The following does NOT work:
// `message` is the fax message object
const content = await rc.restapi().account().extension().messageStore(message.id).content(message.attachments[0].id).get()
But not all binary content has been migrated to CDN. If the resource to download provides you with a CDN uri, use that CDN uri. If there is no CDN uri provided, contruct the uri as the sample code shows.
Get the latest swagger spec here and run:
yarn generate
yarn test
- no more
{}
type - convert code generator to TS
- compare it with C# sdk and see what are missing
- Make it a RingCentral official project
- PubNub
- optional, since we will mainly use WSG instead.
- Support events:
- token refreshed
- extra features as plugins or extensions
- rate limit handling
- debug mode
- extrensions/<extension 1>/
- every extension should have a readme file
- WSG
- Test WSG queryParams with array as value
- Test WSG binary uploading / downloading
- update test case so that everyone tests both REST and WSG
- WSG should have its own folder and readme file