zengfenfei / ringcentral-js-integration-commons

RingCentral Integration Common Javascript Core Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ringcentral-js-integration-commons

Build Status Coverage Status Codacy Badge NPM Version

Introduction

RingCentral integration common library aims to provide reusable modules to allow developers to integrate RingCentral unified communication service into third party processes or tools more easily.

This project is built based on RingCentral Client and Redux. The basic idea is to wrap RingCentral REST API into highly reusable modules based on common application scenarios and provide an unified application state.

Get Started

To use this library, please follow below steps

Install from NPM

npm install ringcentral-integration

Create your own Phone object by adding modules

import { combineReducers, createStore } from 'redux';

class Phone extends RcModule {
  constructor() {
    super();
    this.addModule('${module}');
    this._reducer = combineReducers({
      ${moduleName}: this.${module}.reducer,
    });
  }
}
const phone = new Phone();
const store = createStore(phone.reducer);
phone.setStore(store);

Now you are armed with a set of RingCentral services.

Notice: If you have no idea what this section is talking about, which is the case most of the time, please reference next section for more info.

High Level Concept

Module

Module is the basic component, which usually wraps one ore more API calls to provide common used features. A good example to understand module is to compare Call Log related features in RingCentral JS Client and RingCentral Integration Common Library. In RingCentral JS Client, you can get call log with following code

client.account().extension().callLog().list({
	...param
})

Notice that you can provide any query param specified in API documentation, which allows you to fetch call log in the way you like.

But in RingCentral Integration Common Library, the parameters are limited based on common application use cases. As shown in the code below, you can only fetch call log by specifying from and to date.

_fetch({ dateFrom, dateTo }) {
	fetchList(params => (
		this._client.account().extension().callLog().list({
			...params,
			dateFrom,
			dateTo,
		})
	));
}

Obviously, It kind of limits the flexibility. But it also allows you to fetch call log without much knowledge about API. This library actually consists of a collection of modules. But module could not work by itself, it needs to be added into a Phone object before using(see section below).

Phone

Phone is an aggregator of modules which provides a full functional object in application level. As different application requires different features, the Phone object needs to be constructed in application level by adding required modules. A typical way to create Phone object is something like below

class Phone extends RcModule {
  constructor() {
    super();
    this.addModule('${module}');
    this._reducer = combineReducers({
      ${moduleName}: this.${module}.reducer,
    });
  }
}
const phone = new Phone();

Store

As Phone object is built up with Redux, after Phone object is created, you need to use following code to create Redux store

const store = createStore(phone.reducer);
phone.setStore(store);

Play with Development Server

A development server is delivered with source so that developers can use it to get familiar with the project or do further development. To get development server running

Clone the repo

git clone https://github.com/ringcentral/ringcentral-js-integration-commons.git

Create a file named config.js in following format in folder dev-server to specify app related info

export default {
  appKey: ${app key},
  appSecret: ${app secret},
  server: ${server url},
};

Run following command to start development server

npm run dev-server

The development server is listening on port 8190 by default. Open up your browser and access localhost:8190 to see how it works.

Dependency Injection

Please refer to Dependency Injection for more details.

Modules


  • AccountExtension
  • AccountInfo
  • AccountPhoneNumber
  • Alert
  • Auth
  • AddressBook
  • BlockedNumber
  • Brand
  • Call
  • CallingSettings
  • ComposeText
  • ConnectivityMonitor
  • Conversation
  • ContactSearch
  • Contacts
  • DialingPlan
  • DetailedPresence
  • Environment
  • ExtensionInfo
  • ExtensionPhoneNumber
  • ExtensionDevice
  • GlobalStorage
  • Locale
  • MessageSender
  • MessageStore
  • Messages
  • NumberValidate
  • Presence
  • RateLimiter
  • RecentCalls
  • RecentMessages
  • RegionSettings
  • Ringout
  • RolesAndPermissions
  • Softphone
  • Storage
  • Subscription
  • TabManager
  • Webphone
  • more...

Contribution


Please fork the project and read the following:

About

RingCentral Integration Common Javascript Core Library

License:MIT License


Languages

Language:JavaScript 99.7%Language:HTML 0.2%Language:Shell 0.1%Language:PowerShell 0.0%