From 7945e29053ee27a11bde4bad4f28e56bb40d7c84 Mon Sep 17 00:00:00 2001 From: Kirill Konshin Date: Mon, 23 Nov 2015 16:23:51 -0800 Subject: [PATCH] Doc fixes --- README.md | 27 +++++++-------------------- src/http/Client.js | 4 +++- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 875dc7b9..676ee3da 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Add the following to your HTML: ``` -**Not recommended!** If you are in a hurry, you can use bundled version with all dependencies: +**Not recommended!** You also can use bundle version with all dependencies: ```html @@ -100,9 +100,6 @@ require.config({ require(['ringcentral', 'es6-promise', 'fetch'], function(SDK, Promise) { Promise.polyfill(); - // or - SDK.externals._Promise = Promise; - var sdk = new SDK(...); }); @@ -121,26 +118,16 @@ Make sure that polyfills are loaded before or together with SDK. 2. Require the SDK: ```js - var RingCentral = require('ringcentral'); + var SDK = require('ringcentral'); + var sdk = new SDK(...); ``` ## Set things up for Browserify or Webpack **!!! This is experimental !!!** -1. Install the NPM package: - - ```sh - npm install ringcentral --save - ``` - -2. Require the SDK: - - ```js - var RingCentral = require('ringcentral'); - ``` - -3. Add the following to your `webpack.config.js`, path should be relative to Webpack configuration file: +1. Follow installation steps for NodeJS +2. Add the following to your `webpack.config.js`, path should be relative to Webpack configuration file: ```js { @@ -236,7 +223,7 @@ application can log in so that it can access the features of the API. ## Login -Login is accomplished by calling the `platform.authorize()` method of the Platform singleton with username, extension +Login is accomplished by calling the `platform.login()` method of the Platform singleton with username, extension (optional), and password as parameters. A `Promise` instance is returned, resolved with an AJAX `Response` object. ```js @@ -267,7 +254,7 @@ and such. Login can, of course, fail - a user can enter the incorrect password or mistype their user name. -To handle cases where login fails, you can provide an error handler function in a call to the promise's `catch` method. +To handle cases where login fails, you can provide an error handler function in a call to the Promise's `catch` method. To keep this example simple, a simple JavaScript alert is being used. In a real application, you will want to provide a good UX in your login form UI. diff --git a/src/http/Client.js b/src/http/Client.js index 454e56ed..4f064a38 100644 --- a/src/http/Client.js +++ b/src/http/Client.js @@ -99,7 +99,9 @@ export default class Client extends Observable { // Sanity checks if (!init.url) throw new Error('Url is not defined'); if (!init.method) init.method = 'GET'; - if (init.method && Client._allowedMethods.indexOf(init.method) < 0) throw new Error('Method has wrong value: ' + init.method); + if (init.method && Client._allowedMethods.indexOf(init.method.toUpperCase()) < 0) { + throw new Error('Method has wrong value: ' + init.method); + } // Defaults init.credentials = init.credentials || 'include';