SDK HTML5

From Radarus Project Wiki
Jump to: navigation, search

Contents

Overview

The HTML5 SDK provides your application with all functionality of RADARUS. Before you start, you have to register your application on developer portal to obtain application id

Integration

To integrate RADARUS, you have to include JavaScript library into <head> section on your page:

Simple integration:
<script type="text/javascript" src="http://front-test.radarus.net/rhost.js?appId={your_app_id}"></script>

Parameters to rhost.js

  • appId : Your application id
  • defViewModel : Default view model for user Dashboard
    • window : Dashboard will be shown in new browser window
    • iframe : Dashboard will be loaded into automatically added iframe and will cover your app page while open
    • iframe.popup : Dashboard will be loaded into automatically added iframe and will float over your app in popup while open

Example:
<script type="text/javascript" src="http://front-test.radarus.net/rhost.js?appId=99&defViewModel=iframe.popup"></script>

Core API concepts

RHost namespace

Once initialized, all the functions of RADARUS are available from RHost namespace.

ResponseItem

Most of operations are asynchronous, so actual data are delivered in callbacks. All callbacks receive single parameter: instance of ResponseItem object. (The object constructed similar to Open-Social API)

ResponseItem API:

hadError() : (boolean) return false or true depending on error was encountered during operation
getDataEntry() : (mixed) Result data, if hadError() was false, null otherwise. Please note, that some operation may return null as part of normal operation flow. Shortcut for getData().entry
getErrorMessage() : (string) Error message if hadError() is true, null if no error
getErrorCode() : (integer) Error code if hadError() is true, null if no error
getData() : result operation object, with actual data inside entry field. That is use getData().entry to get the data

Basic API

Once integrated, all the functions of RADARUS are available from RHost namespace.

Init

RHost.init()

Synopsis:
Initialize the system. Should be called once before any other functions.

Login

RHost.AppCore.markUserLoginAsExtUser(userExtLogin, userName, callback, options)

Synopsis:
Login external (application) user into RADARUS. If there is no such user, the new user account will be create by RADARUS automatically. If there is any exiting RADARUS user session, it will be logged out automatically.

Parameters:

userExtLogin : (string) User login (unique user identifier in your system)
userName : (string) User name
callback : (function,optional) callback function to be called once operation completed
options : (hashmap,optional) array (hashmap) of operation options
RHost.AppCore.OPT.LOGIN_TOKEN : (string) Secure token to verify login, if server side security turned on for your app (see manual for more info)

callback(response):

response.hadError() : true/false depending on error condition
response.getDataEntry():
userId : (integer) RADARUS system user id assigned to this external user

RHost.AppCore.getCurrentUserId()

Returns:
Return RADARUS userId for currently logged in user or null otherwise. Can be used to check if there is any user logged in RADARUS.

UI Dashboard

User Dashboard is a component that allow users to manage theirs social connections, discover new buddies, send invites, work with inbox, find new applications etc. The dashboard is optional component, since most of RADARUS functionality available via API as well. This is ready-to-use UI component that can be used to reduce time-to-market. Moreover, you may user UI button (yet another ready-to-use UI component) to control dashboard autocratically. Presently, dashboard loaded on demand, that is it will be loaded with first request to show it.

RHost.UIDashboard.show()

Synopsis:
Shows dashboard

RHost.UIDashboard.hide()

Synopsis:
Hides dashboard

RHost.UIDashboard.isVisible()

Returns:
Returns dashboard visibility status (true / false).

Extended API

Groups

RHost.AppCore.markUserExtGroupJoin(extGroupId, callback, options)

RHost.AppCore.markUserExtGroupLeave(extGroupId)

Actions

RHost.AppAction.execAction(actionId, callback, options)

RHost.AppAction.execActionOnOtherUser(actionId, corrUserId, callback, options)

RHost.AppAction.execActionOnOtherExtUser(actionId, corrUserExtLogin, callback, options)

UI Button

RHost.UIButton.show()

RHost.UIButton.hide()

RHost.UIButton.isVisible()

Logout

RHost.AppCore.markUserLogout(callback, options)

Synopsis:
Logout external (application) user from RADARUS. Actually, RADARUS will try to keep track of user session automatically, by issuing independent ping requests to server every few minutes (if there is no other activity) and it will logout user by timeout. But you may provide better expirience if you call this method explicitly once user logouts from your system.

Parameters:

callback : (function,optional) callback function to be called once operation completed
options : (hashmap,optional) array (hashmap) of operation options

Graph API

Buddies

RHost.AppBuddy.UserInfoItem

userId  : User's id in RADARUS
userName  : User's display name
userIcon  : User's avatar icon
userExtLogin : User's external login used (if any)
isFriend  : (true/false) if user is a friend of requesting (currently logged in user)
isOnline  : (true/false) if user is online in the requesting (current) application

RHost.AppBuddy.reqThisUserBuddiesItemList(callback, options)

Friends

RHost.AppBuddy.execSendFriendReq(corrUserId, callback, options)

RHost.AppBuddy.execSendFriendReqToExtUser(corrUserExtLogin, callback, options)

RHost.AppBuddy.reqThisUserFriendsItemList(callback, options)

Users

RHost.AppCore.UserInfoItem

userId  : User's id in RADARUS
userName  : User's display name
userIcon  : User's avatar icon
userExtLogin : User's external login used (if any)
isFriend  : (true/false) if user is a friend of requesting (currently logged in user)
isOnline  : (true/false) if user is online in the requesting (current) application

RHost.AppCore.reqAnyUserInfo(userId, callback, options)

RHost.AppCore.reqAnyExtUserInfo(userExtLogin, callback, options)

Pride API

Pride API provides a functionality that allows your application users share what they have achieved in your application.

Progress

RHost.AppProgress.execPostProgress(progressId, progressValue, callback, options)

RHost.AppProgress.UserInfoItem

appId  : Application id in RADARUS
progressId  : Progress id registered for your application
progressCode : Progress timespan code (ALL_TIME, THIS_MONTH, THIS_WEEK, etc)
userId  : User's id in RADARUS
userExtLogin : User's external login used (if any)
userName  : User's display name
userIcon  : User's avatar icon
value  : Progress value
points  : Synonym for value
updateTs  : timestamp for last update (in ms since 1/1/1970, may be used to make Date() object)
rank  : User's position in progress list

RHost.AppProgress.PROGRESS_CODE_*

RHost.AppProgress.PROGRESS_CODE_ALL_TIME  : All time
RHost.AppProgress.PROGRESS_CODE_THIS_MONTH : For this month
RHost.AppProgress.PROGRESS_CODE_THIS_WEEK  : For this week

RHost.AppProgress.reqAllUsersItemList(progressId, progressCode, callback, options)

RHost.AppProgress.reqThisUserBuddiesItemList(progressId, progressCode, callback, options)

RHost.AppProgress.reqAnyUserItem(progressId, progressCode, userId, callback, options)

RHost.AppProgress.reqThisUserItem(progressId, progressCode, callback, options)

RHost.AppProgress.AppInfoItem

Synopsis:
Application vocabulary entry for progress defined for the application via developer portal.

appId  : Application id in RADARUS
progressId  : Progress registered for your application
progressName : Progress name
progressIcon : Progress icon url
progressData : Application specific data (opaque for RADARUS) associated with the item via developer portal. Can be used to build data-driven custom tunable logic.
appData  : Synonym for progressData

RHost.AppProgress.reqAppItemList(callback)

Synopsis:
Application vocabulary extraction : returns all progresses defined for the application on developer portal.

callback(response):

response.hadError() : true/false depending on error condition
response.getDataEntry():
Array of RHost.AppProgress.AppInfoItem defined for the application

Badges

RHost.AppBadge.execUnlock(badgeId, callback, options)

Synopsis:
Unlock application badge for current user.

Parameters:

badgeId  : (integer) badge id to unlock
callback  : (function,optional) callback function to be called once operation completed
options  : (hashmap,optional) array (hashmap) of operation options

callback(response):

response.hadError() : true/false depending on error condition

RHost.AppBadge.UserInfoItem

appId  : Application id in RADARUS
badgeId  : Badge id (registered for your application on developer portal)
badgeName : Badge name
badgeIcon : Badge icon url
userId  : User's id in RADARUS
unlockTs  : timestamp for last update (in ms since 1/1/1970, may be used to make Date() object)

RHost.AppBadge.reqAnyUserItemList(userId, callback, options)

RHost.AppBadge.reqThisUserItemList(callback, options)

RHost.AppBadge.AppInfoItem

Synopsis:
Application vocabulary entry for badges defined for the application via developer portal.

appId  : Application id in RADARUS
badgeId  : Badge id (registered for your application on developer portal)
badgeName : Badge name
badgeIcon : Badge icon url
badgeData : Application specific data (opaque for RADARUS) associated with the item via developer portal. Can be used to build data-driven custom tunable logic.
appData  : Synonym for badgeData

RHost.AppBadge.reqAppItemList(callback)

Synopsis:
Application vocabulary extraction : returns all badges defined for the application on developer portal.

Parameters:

callback  : (function,optional) callback function to be called once operation completed

callback(response):

response.hadError() : true/false depending on error condition
response.getDataEntry():
Array of RHost.AppBadge.AppInfoItem defined for the application
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox