项目作者: ringcentral

项目描述 :
RingCentral Extensible SDK
高级语言: TypeScript
项目地址: git://github.com/ringcentral/ringcentral-extensible.git
创建时间: 2020-05-01T20:32:20Z
项目社区:https://github.com/ringcentral/ringcentral-extensible

开源协议:

下载


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

  1. yarn add @rc-ex/core

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

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

Usage

Sample code for all endpoints

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

Extensions

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:

  1. RingCentral.config.logger = console;

Or you could use a third-party logger:

  1. import winston from "winston";
  2. const logger = winston.createLogger({
  3. transports: [
  4. new winston.transports.Console({
  5. format: winston.format.simple(),
  6. }),
  7. ],
  8. });
  9. RingCentral.config.logger = logger;

Sample log entries:

  1. [3/16/2022, 9:58:47 AM HTTP GET 200 OK] https://platform.devtest.ringcentral.com /restapi/v1.0/account/~/extension/~/call-log
  2. [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:

  1. // `message` is the fax message object
  2. const r = await rc.get(message.attachments[0].uri, undefined, {
  3. responseType: "arraybuffer",
  4. });
  5. const content = r.data;

The following does NOT work:

  1. // `message` is the fax message object
  2. const content = await rc
  3. .restapi()
  4. .account()
  5. .extension()
  6. .messageStore(message.id)
  7. .content(message.attachments[0].id)
  8. .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

  1. yarn reset && yarn compile && yarn test

Test one test case

  1. t=auto-recover yarn test

Publish

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

  1. yarn compile
  2. 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

  1. yarn workspace @rc-ex/debug add ramda

Todo

  • Extension to refresh token
  • Extension to do pagination