Skip to content

ringcentral/ringcentral-extensible

Repository files navigation

RingCentral Extensible SDK

Build Status

RingCentral Extensible is a SDK with a tiny core and lots of extensions. It is an endeavour to get rid of bloated SDK. You install extensions on demand.

Getting help and support

If you are having difficulty using this SDK, or working with the RingCentral API, please visit our developer community forums for help and to get quick answers to your questions. If you wish to contact the RingCentral Developer Support team directly, please submit a help ticket from our developer website.

Installation

pnpm add @rc-ex/core

Then you should be able to import the SDK like this:

import RingCentral from "@rc-ex/core";

Usage

You can also find lots of useful code snippets from test cases.

This SDK supports extensions. You can enable features by installing extensions.

If you want to add features to this SDK, create an extension.

Logging

The logging implementation copies AWS SDK logging.

To enable logging:

RingCentral.config.logger = console;

Or you could use a third-party logger:

import winston from "winston";

const logger = winston.createLogger({
  transports: [
    new winston.transports.Console({
      format: winston.format.simple(),
    }),
  ],
});
RingCentral.config.logger = logger;

Sample log entries:

[3/16/2022, 9:58:47 AM HTTP GET 200 OK] https://platform.devtest.ringcentral.com /restapi/v1.0/account/~/extension/~/call-log
[3/16/2022, 5:47:53 PM HTTP POST 401 Unauthorized] https://platform.ringcentral.com /restapi/oauth/token

A demo application printing logs to console.

Binary content downloading

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();

Rule of thumb

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, construct the uri as sample code shows.

For maintainers

Code style

pnpm check
pnpm fix

Regenerate code using latest swagger spec

Please refer to the RingCentral Code Generator project.

Test

pnpm build
pnpm test

Test one test case

t=auto-recover pnpm test

Publish

Update version number in packages/core/src/Rest.ts

pnpm build
pnpm publish-changed

Recursive pnpm publish checks npmjs.com and only publishes workspace packages whose current versions are not already in the registry.

NPM 2FA

I don't know how to make it work with publishing and I have to disable it via npmjs.com GUI: I disabled "Require two-factor authentication for write actions".

Add dependency

pnpm --filter @rc-ex/debug add ramda

Todo

  • Extension to refresh token
  • Extension to do pagination

Packages

 
 
 

Contributors