Skip to content

Latest commit

 

History

History
147 lines (96 loc) · 3.91 KB

README.md

File metadata and controls

147 lines (96 loc) · 3.91 KB

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

yarn 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

Regenerate code using latest swagger spec

Please refer to the RingCentral Code Generator project.

Test

yarn reset && yarn compile && yarn test

Test one test case

t=auto-recover yarn test

Publish

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

yarn lerna publish from-package

By default lerna check git tag to determine which packages to publish. from-package will make lerna check npmjs.com instead.

As I just tried, it works without from-package option.

NPM 2FA

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

Add dependency

yarn workspace @rc-ex/debug add ramda

Todo

  • Extension to refresh token
  • Extension to do pagination