Skip to content

Commit ca20d83

Browse files
committed
update content
1 parent cdcfff8 commit ca20d83

File tree

3 files changed

+215
-81
lines changed

3 files changed

+215
-81
lines changed

source/includes/_errors.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# Errors
22

3-
<aside class="notice">This error section is stored in a separate file in `includes/_errors.md`. Slate allows you to optionally separate out your docs into many files...just save them to the `includes` folder and add them to the top of your `index.md`'s frontmatter. Files are included in the order listed.</aside>
4-
5-
The Kittn API uses the following error codes:
3+
The RingCentral for Developers API uses the following error codes:
64

75

86
Error Code | Meaning
97
---------- | -------
10-
400 | Bad Request -- Your request sucks
8+
400 | Bad Request -- Your request is incorrectly formatted
119
401 | Unauthorized -- Your API key is wrong
12-
403 | Forbidden -- The kitten requested is hidden for administrators only
13-
404 | Not Found -- The specified kitten could not be found
14-
405 | Method Not Allowed -- You tried to access a kitten with an invalid method
15-
406 | Not Acceptable -- You requested a format that isn't json
16-
410 | Gone -- The kitten requested has been removed from our servers
17-
418 | I'm a teapot
18-
429 | Too Many Requests -- You're requesting too many kittens! Slow down!
10+
403 | Forbidden -- The resource requested is hidden for administrators only
11+
404 | Not Found -- The specified resource could not be found
12+
405 | Method Not Allowed -- You tried to access a resource with an invalid method
13+
410 | Gone -- The resource requested has been removed from our servers
14+
429 | Too Many Requests -- You're making too many requests! Slown down!
1915
500 | Internal Server Error -- We had a problem with our server. Try again later.
20-
503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later.
16+
503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later.

source/index.md

Lines changed: 206 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,52 @@ Send `POST` request: Specify `accountId` and `extensionId` in the request URL or
245245

246246
## Send Pager Message
247247

248+
~~~ http
249+
POST /restapi/v1.0/account/~/extension/~/company-pager HTTP/1.1
250+
Content-Type: application/json
251+
Content-Length: ACTUAL_CONTENT_LENGTH_HERE
252+
253+
{
254+
"to": [{"extensionNumber": "102"},
255+
{"extensionNumber": "103"}],
256+
257+
"from": {"extensionNumber": "101"},
258+
"text": "Hello!"
259+
}
260+
261+
HTTP/1.1 200 OK
262+
Content-Type: application/json
263+
264+
{
265+
"uri": ".../account/1346632010/extension/1346632010/message-store/320272670010",
266+
"id": 320272670010,
267+
"to": [
268+
{"extensionNumber": "101"},
269+
{"extensionNumber": "102"},
270+
{"extensionNumber": "103"}
271+
],
272+
"from": {"extensionNumber": "101"},
273+
"type": "Pager",
274+
"creationTime": "2012-10-18T13:18:24.000Z",
275+
"readStatus": "Unread",
276+
"priority": "Normal",
277+
"attachments": [ {
278+
"id": 1,
279+
"uri": "http:.../restapi/v1.0/account/1346632010/extension/1346632010/message-store/320272670010/content/1",
280+
"contentType": "text/plain"
281+
}],
282+
"direction": "Outbound",
283+
"availability": "Alive",
284+
"subject": "Hello!",
285+
"messageStatus": "Sent",
286+
"conversationId": 320272670010,
287+
"lastModifiedTime": "2012-10-18T13:18:24.000Z",
288+
"pgToDepartment": false
289+
}
290+
~~~
291+
292+
Pager messages are RingCentral specific types of text messages which can be sent between extensions of one account. Unlike SMS, pager messages can be sent to multiple recipients, so the API allows several extension numbers in the **to** field. Another difference from SMS is that the pager message that is sent to the department extension is automatically forwarded to all department members. This allows setting up dedicated mailing lists within the organization. The endpoint **company-pager** is designed to handle pager messages.
293+
248294
# Getting Started
249295

250296
## Installing the SDK
@@ -282,7 +328,43 @@ var platform = rcsdk.getPlatform();
282328

283329
Now that you have your platform singleton and SDK has been configured with the correct server URL and API key, your application can log in so that it can access the features of the API.
284330

285-
## Login
331+
## Login via 3-legged OAuth
332+
333+
~~~ javascript
334+
// Get user authorization URL
335+
var myRedirectUri = 'https://example.com/oauth';
336+
var authorizeUrl = t.rcDemo.Core.rcSdk.getPlatform().getAuthURL({
337+
redirectUri: myRedirectUri
338+
});
339+
// Open window for authorizeUrl
340+
341+
// In redirect URL, retrieve `code` from query string and exhange for access token.
342+
// Get query string
343+
var myRedirectUri = 'https://example.com/oauth';
344+
var qs = rcsdk.getPlatform().parseAuthRedirectUrl(window.location.href);
345+
qs.redirectUri = myRedirectUri;
346+
347+
if ('code' in qs) {
348+
var res = rcsdk.getPlatform().authorize(qs)
349+
.then(function(response) {
350+
// process response and close window (if popup)
351+
window.open('', '_self', '');
352+
window.close();
353+
}).catch(function(e) {
354+
console.log("Error: Authorization")
355+
});
356+
} else {
357+
console.log("Error: No Code")
358+
}
359+
~~~
360+
361+
3-legged OAuth is the standard login approach for user applications via the web where the user will be presented with a standard RingCentral login. This approach also supports RingCentral customers that have deployed single sign-on (SSO) via 3-rd party identity providers (IdPs). To implement 3-legged OAuth, implement the following steps:
362+
363+
1. Configure a redirect URI for your service in the RingCentral Developer portal which will be used to send the authorization code upon success login and authorization.
364+
2. Then use the redirect URI with the SDK to retrieve an OAuth authorization URL that can be used to open a browser window.
365+
3. Finally, in the web page at your redirect URI, extract the authoriation code from the URL string's `code` query parameter and exchange the authorization code for an access token.
366+
367+
## Login via 2-legged OAuth
286368

287369
~~~ javascript
288370
platform.authorize({
@@ -294,13 +376,15 @@ platform.authorize({
294376
}).catch(function(e) {
295377
alert(e.message || 'Server cannot authorize user');
296378
});
297-
~~~
379+
~~~
380+
381+
Client-server applications can use the 2-legged OAuth approach which doesn't provide a user login page.
298382

299383
To log in to RingCentral, get the Platform object and call its authorize method, providing valid username, extension, and password values. Enter your phone number in E.164 format for username. The `+` may be omitted.
300384

301385
A Promise is returned, and you can use its then method to specify your continuation function, and its catch method to specify an error handling function.
302386

303-
## Handling Authn Exceptions
387+
## Handling Authorization Exceptions
304388

305389
~~~ javascript
306390
platform.on(platform.events.accessViolation, function(e){
@@ -314,7 +398,7 @@ To handle possible access or authentication exceptions that may occur while the
314398
A recommended way to handle access or authentication exceptions is to direct the user to the login page or UI. The login page may attempt to automatically re-authenticate the user using stored authentication data (see below).
315399
</aside>
316400

317-
## Determining Authn Status
401+
## Determining Authorization Status
318402

319403
~~~ javascript
320404
// To check authentication status:
@@ -351,6 +435,111 @@ platform.logout().then(...)
351435

352436
Your application can log out the user by calling the `platform.logout()` method.
353437

438+
# Making Calls (RingOut)
439+
440+
Outbound calls using RingCentral can be made using the RingOut functionality.
441+
442+
## Two-Legged Calls
443+
444+
When making a call, the RingCentral system establishes two calls, one for each of the two parties being connected, and then connects them. This results in events for two calls (2-legged calls) when initiated a single click-to-call?
445+
446+
## Making an Outbound Call
447+
448+
~~~ javascript
449+
// Phone numbers should be in E.164 format.
450+
platform
451+
.apiCall(rcsdk.getRingoutHelper().saveRequest({
452+
from: {phoneNumber: '+16501111111'},
453+
to: {phoneNumber: '+18882222222'},
454+
callerId: {phoneNumber: '+18882222222'}, // optional,
455+
playPrompt: false // optional
456+
}))
457+
.then(function(ajax) {
458+
// here application can start polling
459+
// also save ajax.data as, for example, prevRingoutData
460+
})
461+
.catch(handleError);
462+
~~~
463+
464+
The application should stop polling the RingOut when its status changes to error or success because after that there will be no status updates.
465+
466+
## Polling Outbound Call Status
467+
468+
~~~ javascript
469+
// Poll for the status of an ongoing outbound call
470+
function update(next, delay) {
471+
472+
if (!rcsdk.getRingoutHelper().isInProgress(ringout)) return;
473+
474+
platform
475+
.apiCall(rcsdk.getRingoutHelper().loadRequest(prevRingoutData))
476+
.then(function(ajax) {
477+
// also save ajax.data as, for example, prevRingoutData
478+
console.log(ajax.data); // updated status of ringout
479+
timeout = next(delay); // you can increase delay here
480+
})
481+
.catch(handleError);
482+
483+
}
484+
485+
var timeout = rcsdk.getUtils().poll(update, 3000); // stay in RPS limits
486+
487+
// To stop polling:
488+
489+
rcsdk.getUtils().stopPolling(timeout);
490+
~~~
491+
492+
Use polling to get the status of an ongoing outbound call.
493+
494+
## Outbound Call Control
495+
496+
The RingCentral Connect Platform does not currently support control of outbound calls. However, you can cancel ringout call while callee party status is `InProgress`. To do that make a `DELETE` request to ringout URI.
497+
498+
## Outbound Call Statuses
499+
500+
* A 2-legged RingOut call is represented in events as an outbound call between `from` and `to` numbers provided in RingOut API request.
501+
* There is the known issue: notification with `CallConnected` status comes after first leg is connected. So actually a call can be missed by callee but it won't be reflected in event flow; but it will be reflected in call log.
502+
* Phone numbers in notification (`from` and `to`) may be either E.164 phone numbers (with or without `+`) or short extension numbers (e.g. '101') for calls between extensions
503+
* For some RC phone system configurations when multiple devices are ringing for inbound call, you may get transitional notifications with `NoCall` status which will be immediately followed by `Ringing` or `CallConnected` (for the same `sessionId`).
504+
505+
## Polling & Events Notification
506+
507+
All RingOut calls will appear in event notifications and active calls endpoint. The difference between what RingOut polling provides is more granular status updates (application can track status of both parties). Normally it should be represented by two independent views/flows in application. In general there is no point to match ringout calls with any of active calls, those process may happen concurrently.
508+
509+
If the application needs to track outbound calls and save them somewhere, it is better to initiate the ringout and NOT poll it, but expect a notification and work only with notifications/active calls.
510+
511+
# Making Calls (URI Scheme)
512+
513+
In addition to making calls via the RingOut API, if the user has the RingCentral for Desktop softphone installed, it is possible to use a URI scheme to initiate a dial out from the application.
514+
515+
RingCentral supports both a custom `rcmobile` URI scheme will resolve the issue of competing applications using the same URI scheme and a standard `tel` URI scheme which is more common but subject to competing uses.
516+
517+
## RingCentral URI Scheme
518+
519+
~~~
520+
// HTML URI Scheme
521+
<a href="rcmobile://call?number=16501112222">1-650-111-2222</a>
522+
~~~
523+
524+
~~~ javascript
525+
// Use the following for Google Chrome only
526+
var w = (window.parent)?window.parent:window;
527+
w.location.assign('rcmobile://call?number=16501112222');
528+
// For more info, see http://stackoverflow.com/questions/2330545/
529+
~~~
530+
531+
The RingCentral `rcmobile` URI Scheme is specific to RingCentral and thus has a higher probability of workign as intended.
532+
533+
## Standard URI Scheme
534+
535+
~~~
536+
// HTML URI Scheme
537+
<a href="tel:1-650-111-2222">1-650-111-2222</a>
538+
<a href="tel:16501112222">1-650-111-2222</a>
539+
~~~
540+
541+
The standard `tel` URI Scheme is also supported but since multiple applications use this URI scheme, there may be competing applications resulting in a less desirable expeirence.
542+
354543
# Call Management
355544

356545
If you are integrating with a CRM or ERP system, use of the JavaScript SDK is highly recommended. Following is an example of a call management integration that includes monitoring of incoming calls and performing of RingOuts.
@@ -644,75 +833,23 @@ platform.apiCall(Call.loadRequest(null, {
644833

645834
By default, the load request returns calls that were made during the last week. To alter the time frame, provide custom query.dateTo and query.dateFrom properties.
646835

647-
# Making Calls (RingOut)
648-
649-
Outbound calls using RingCentral can be made using the RingOut functionality.
650-
651-
## Two-Legged Calls
652-
653-
When making a call, the RingCentral system establishes two calls, one for each of the two parties being connected, and then connects them. This results in events for two calls (2-legged calls) when initiated a single click-to-call?
654-
655-
## Making an Outbound Call
656-
657-
~~~ javascript
658-
// Phone numbers should be in E.164 format.
659-
platform
660-
.apiCall(rcsdk.getRingoutHelper().saveRequest({
661-
from: {phoneNumber: '+16501111111'},
662-
to: {phoneNumber: '+18882222222'},
663-
callerId: {phoneNumber: '+18882222222'}, // optional,
664-
playPrompt: false // optional
665-
}))
666-
.then(function(ajax) {
667-
// here application can start polling
668-
// also save ajax.data as, for example, prevRingoutData
669-
})
670-
.catch(handleError);
671-
~~~
672-
673-
The application should stop polling the RingOut when its status changes to error or success because after that there will be no status updates.
836+
# Call Recordings
674837

675-
## Polling Outbound Call Status
838+
Call log records with recordings will have a `recording` object property which includes information on the recording including the `contentUri` string property which can be used to retrieve the recording.
676839

677840
~~~ javascript
678-
// Poll for the status of an ongoing outbound call
679-
function update(next, delay) {
680-
681-
if (!rcsdk.getRingoutHelper().isInProgress(ringout)) return;
682-
683-
platform
684-
.apiCall(rcsdk.getRingoutHelper().loadRequest(prevRingoutData))
685-
.then(function(ajax) {
686-
// also save ajax.data as, for example, prevRingoutData
687-
console.log(ajax.data); // updated status of ringout
688-
timeout = next(delay); // you can increase delay here
689-
})
690-
.catch(handleError);
691-
841+
var callLogRecord = {
842+
[...]
843+
"recording": {
844+
"uri": "https.../restapi/v1.0/account/401190149008/recording/401547458008",
845+
"id": "401547458008",
846+
"type": "OnDemand",
847+
"contentUri": "https.../restapi/v1.0/account/401190149008/recording/401547458008/content"
848+
}
692849
}
693850

694-
var timeout = rcsdk.getUtils().poll(update, 3000); // stay in RPS limits
851+
var recordingUrl = callLogRecord['recording']['contentUri'];
852+
var recordingUrlWithToken = rcsdk.getPlatform().apiUrl(uri, {addToken: true});
853+
~~~
695854

696-
// To stop polling:
697855

698-
rcsdk.getUtils().stopPolling(timeout);
699-
~~~
700-
701-
Use polling to get the status of an ongoing outbound call.
702-
703-
## Outbound Call Control
704-
705-
The RingCentral Connect Platform does not currently support control of outbound calls. However, you can cancel ringout call while callee party status is `InProgress`. To do that make a `DELETE` request to ringout URI.
706-
707-
## Outbound Call Statuses
708-
709-
* A 2-legged RingOut call is represented in events as an outbound call between `from` and `to` numbers provided in RingOut API request.
710-
* There is the known issue: notification with `CallConnected` status comes after first leg is connected. So actually a call can be missed by callee but it won't be reflected in event flow; but it will be reflected in call log.
711-
* Phone numbers in notification (`from` and `to`) may be either E.164 phone numbers (with or without `+`) or short extension numbers (e.g. '101') for calls between extensions
712-
* For some RC phone system configurations when multiple devices are ringing for inbound call, you may get transitional notifications with `NoCall` status which will be immediately followed by `Ringing` or `CallConnected` (for the same `sessionId`).
713-
714-
## Polling & Events Notification
715-
716-
All RingOut calls will appear in event notifications and active calls endpoint. The difference between what RingOut polling provides is more granular status updates (application can track status of both parties). Normally it should be represented by two independent views/flows in application. In general there is no point to match ringout calls with any of active calls, those process may happen concurrently.
717-
718-
If the application needs to track outbound calls and save them somewhere, it is better to initiate the ringout and NOT poll it, but expect a notification and work only with notifications/active calls.

start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bundle exec middleman server

0 commit comments

Comments
 (0)