Skip to content

Commit

Permalink
Merge branch 'release/3.0.0-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-konshin committed Jun 29, 2016
2 parents 5f5197c + 3d1fc0b commit 612a182
Show file tree
Hide file tree
Showing 52 changed files with 1,926 additions and 11,465 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ node_js:
- '0.11'
- '0.12'
- '4'
- '5'
- '6'
- stable
env:
- CXX=g++-4.8
Expand All @@ -20,3 +22,7 @@ deploy:
on:
tags: true
repo: ringcentral/ringcentral-js
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Change Log

This document contains only major functionality changes in certain versions. Minor fixes/updates are omitted.

## 3.0

- SDK no longer runs refresh queue across multiple tabs
- SDK is no longer shipped with the bundle, you need to add polyfills and PUBNUB manually
- Migration Guides merged into one Change Log
- `SDK.core.Observable` has been replaced by NodeJS's `EventEmitter` and is accessible via `SDK.core.EventEmitter`
- `Platform.login` does not support `remember` parameter anymore, if you wish to supply custom token TTLs,
use `accessTokenTtl` and `refreshTokenTtl`
- `Subscription` will not throw an error when it can't renew because it's expired when timeout hits (computer woke up
after sleep, for example), it will automatically `subscribe` again with the same `eventFilter`s

## 2.0

- Helpers were moved to separate repository: [RingCentral JS Helpers](https://github.com/ringcentral/ringcentral-js-helpers).
- Root JS name has changed from `RCSDK` to `RingCentral.SDK`
- New naming convention: `getSomething()` methods are now simply `something()`
- `Auth` class inside `Platform`
- `AjaxObserver` functionality been moved to `Client`
- New `ApiResponse` interface that wraps native Requests/Responses:
- `apiResponse.json()` instead of `ajax.json`
- `apiResponse.multipart()` instead of `ajax.responses`
- `apiResponse.request()` and `ajax.response()` to access to DOM Request and DOM Response accordingly
- `apiResponse.request().headers` and `ajax.response().headers` should be used to access headers
- `Subscription` interface changes

## 1.2

- AJAX object is now represented by 2 separate objects:
- `Request`
- `Response`
- AJAX error has 2 properties: `e.request` and `e.response` and backward-compatible `e.ajax` which is equal to
`e.response`.
- AJAX Response now has `responses` property and `json` property along with backward-compatible `data` property

## 0.14

The key differences between versions:
- Promises/A+
- Native ECMAScript6 where available (Chrome, FireFox, Safari)
- RSVP polyfill for older browsers
- RCSDK is now a constructor
- Instance has a context, so it is possible to have multiple simultaneous connections to API
- All other objects are obtained through RCSDK instance's getters instead of static methods of classes

### Initialization

Before:

```js
var platform = RCSDK.core.Platform.getInstance();
```

After:

```js
var rcsdk = new RCSDK(), // save this object, everything else is provided by it
platform = rcsdk.getPlatform();
```

### Promises and API Calls

Before:

```js
platform.apiCall({
url: '...',
success: function(data){ ... }
error: function(e){ ... }
});
```

After:

```js
platform.apiCall({url: '...'}).then(function(ajax){
// do something with ajax.data
}).catch(function(e){ ... });
```

This also applies to any other place that formerly accepted `success` and `error` callbacks.

- platform.isAuthorized|refresh|authorize|logout
- subscription.register|subscribe|renew|remove

### AjaxObserver

Before:

```js
RCSDK.core.Ajax.observer.on(...)
```

After:

```js
rcsdk.getAjaxObserver().on(...);
```

### Call Monitoring Object is deprecated

Call Monitoring object is now replaced with a number of Helper objects, which gives developers more control over
application logic while processing logic is still maintained by SDK.

Take a look on **Call Management Using JavaScript** section of **Usage Manual**, and big **AngularJS Demo** for
implementation examples.
83 changes: 49 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Pick the option that works best for you:
bower install ringcentral --save
```

- Use CDN **Attention! Versions listed here may be outdated**:
- https://cdn.rawgit.com/ringcentral/ringcentral-js/master/build/ringcentral.js
- https://cdnjs.cloudflare.com/ajax/libs/fetch/0.11.0/fetch.js
- https://cdnjs.cloudflare.com/ajax/libs/es6-promise/3.2.1/es6-promise.js
- https://cdnjs.cloudflare.com/ajax/libs/pubnub/3.7.7/pubnub.js

- Donwload everything manually *(not recommended)*:
- [ZIP file with source code](https://github.com/ringcentral/ringcentral-js/archive/master.zip)
- [Fetch](https://github.com/github/fetch), direct download: [fetch.js](https://raw.githubusercontent.com/github/fetch/master/fetch.js)
Expand All @@ -69,43 +75,24 @@ Add the following to your HTML:
</script>
```

**Not recommended!** You also can use bundle version with all dependencies:

```html
<script type="text/javascript" src="path-to-scripts/ringcentral/build/ringcentral-bundle.js"></script><!-- or ringcentral-bundle.min.js -->
<script type="text/javascript">
var sdk = new RingCentral.SDK(...);
</script>
```

Keep in mind that this is for quick start only and for production you should add each dependency separately to have
full control over the process.

### If you use RequireJS in your project

```js
// Add this to your RequireJS configuration file
require.config({
paths: {
'es6-promise': 'path-to-scripts/es6-promise-polyfill/promise',
'fetch': 'path-to-scripts/fetch/fetch',
'pubnub': 'path-to-scripts/pubnub/web/pubnub'
'ringcentral': 'path-to-scripts/ringcentral/build/ringcentral', // or ringcentral.min
}
});
// Then you can use the SDK like any other AMD component
require(['ringcentral', 'es6-promise', 'fetch'], function(SDK, Promise) {
Promise.polyfill();
require(['ringcentral'], function(SDK) {
var sdk = new SDK(...);
});
```

Make sure that polyfills are loaded before or together with SDK.
Make sure that polyfills are added to the page before or together with SDK.

## Set things up in NodeJS

Expand All @@ -130,15 +117,37 @@ Make sure that polyfills are loaded before or together with SDK.
2. Add the following to your `webpack.config.js`, path should be relative to Webpack configuration file:

```js
{
module.exports = {
resolve: {
alias: {
'node-fetch': path.resolve('./bower_components/fetch/fetch.js'),
'es6-promise': path.resolve('./bower_components/es6-promise/promise.js'),
'pubnub': path.resolve('./bower_components/pubnub/web/pubnub.js')
'node-fetch': 'whatwg-fetch',
'pubnub': require.resolve('pubnub/modern/pubnub')
}
}
}
};
```

For old NPM versions which install packages in a nested way:

```sh
$ npm instal resolve-from --save
```

Add the following to your `webpack.config.js`, path should be relative to Webpack configuration file:

```js
var resolve = require('resolve-from');
module.exports = {
resolve: {
alias: {
'node-fetch': resolve(require.resolve('ringcentral'), 'whatwg-fetch') ||
resolve(process.cwd(), 'whatwg-fetch'),
'pubnub': resolve(require.resolve('ringcentral'), 'pubnub/modern/pubnub') ||
resolve(process.cwd(), 'pubnub/modern/pubnub')
}
}
};
```

To reduce the size of your Webpack bundle it's better to use browser version of dependencies (instead of the ones that
Expand Down Expand Up @@ -180,13 +189,8 @@ But taking into account the nature of polyfills, it's better to keep them global

**In SDK version 2.0 Helpers were moved to separate repository: [ringcentral-js-helpers](https://github.com/ringcentral/ringcentral-js-helpers).**

A lot of code improvements were implemented in order to make SDK compatible with WhatWG Fetch, DOM Requests & DOM Responses.

Full list of migration instructions:

- [0.13 to 0.14](docs/migration-0.13-0.14.md)
- [1.1 to 1.2](docs/migration-1.1-1.2.md)
- [1.x to 2.0](docs/migration-1.x-2.0.md)
A lot of code improvements were implemented in order to make SDK compatible with WhatWG Fetch, DOM Requests &
DOM Responses: see [full list of migration instructions](CHANGELOG.md).

***

Expand All @@ -212,6 +216,9 @@ var rcsdk = new RingCentral.SDK({
This instance will be used later on to perform calls to API.
If you need to use 2 or more RingCentral accounts simultaneously, you need to create an instance of SDK for each account
and provide some unique `cachePrefix` to SDK constructor (otherwise instances will share authentication).
## Get the Platform singleton
```js
Expand Down Expand Up @@ -264,7 +271,13 @@ To check in your Application if the user is authenticated, you can call the `log
singleton:

```js
rcsdk.platform().loggedIn().then(function(status){ ... });
rcsdk.platform().loggedIn().then(function(status){ if (status) { ... } else { ... } });
```
Or you can call `ensureLogedIn` method which works the same way as `loggedIn` but rejects promise on failure:
```js
rcsdk.platform().ensureLogedIn().then(function(){ ... }).catch(function(){ ... });
```
The SDK takes care of the token lifecycle. It will refresh tokens for you automatically. It will also automatically
Expand Down Expand Up @@ -317,6 +330,8 @@ In the NodeJS it might be useful to replace simple built-in storage with somethi
RingCentral.SDK.core.Externals.localStorage = Anything;
```
SDK works with `localStorage` as with a simple object.
# API calls
To perform an authenticated API call, you should use the one of the methods of the platform singleton:
Expand Down
16 changes: 4 additions & 12 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
"!src/**/*"
],
"dependencies": {
"es6-promise": "~2.2.0",
"fetch": "#master",
"pubnub": "~3.7.13"
},
"devDependencies": {
"chai": "~3.2.0",
"sinon-chai": "~2.8.0",
"mocha": "~2.2.5",
"sinonjs": "~1.14.1",
"requirejs": "~2.1.20"
"es6-promise": "^3.2.1",
"fetch": "^0.11.0",
"pubnub": "^3.14.4"
},
"moduleType": [
"amd",
Expand All @@ -48,6 +41,5 @@
"repository": {
"type": "git",
"url": "git://github.com/ringcentral/ringcentral-js.git"
},
"version": "2.0.6"
}
}
Loading

0 comments on commit 612a182

Please sign in to comment.