API reference
This section provides a comprehensive reference of the available API methods in the JavaScript SDK beyond those covered in the other sections.
Data retrieval functions
The SDK provides methods to retrieve various types of data without using the widgets directly. These functions allow for complete customization of the user interface.
| Function | Description | Event Triggered | Response Data |
|---|---|---|---|
Mambo.getUserNotifications() | Retrieves notifications for the current user | mambo.data.user_notifications | User Notifications |
Mambo.getUserWallets() | Retrieves point wallets for the current user | mambo.data.user_wallets | User Points |
Mambo.getUserCoupons() | Retrieves coupons for the current user | mambo.data.user_coupons | User Coupons |
Mambo.getUserRewards() | Retrieves rewards for the current user | mambo.data.user_rewards | User Rewards |
Mambo.getUserAchievements() | Retrieves achievements for the current user | mambo.data.user_achievements | User Rewards |
Mambo.getUserLevels() | Retrieves levels for the current user | mambo.data.user_levels | User Rewards |
Mambo.getUserGifts() | Retrieves gifts for the current user | mambo.data.user_gifts | User Rewards |
Mambo.getUserMissions() | Retrieves missions for the current user | mambo.data.user_missions | User Rewards |
Mambo.getUserKPIs(year) | Retrieves KPIs for the current user | mambo.data.user_kpis | User KPIs |
Mambo.getUserActivities(page, count) | Retrieves activities for the current user | mambo.data.activities | User Activities |
Mambo.getBehaviours() | Retrieves available behaviours | mambo.data.behaviours | Behaviours |
Mambo.getAchievements() | Retrieves available achievements | mambo.data.achievements | Rewards |
Mambo.getLevels() | Retrieves available levels | mambo.data.levels | Rewards |
Mambo.getMissions() | Retrieves available missions | mambo.data.missions | Rewards |
Mambo.getLeaderboards(fn, tagUuid) | Retrieves available leaderboards | mambo.data.leaderboards | Leaderboards |
Usage example
Here's how to use these API methods to retrieve data:
The events that return data objects will return either a Backbone Collection or Model. To work with these as standard JSON objects, call the toJSON() function on the data object.
Building custom interfaces
Using these API methods, you can build completely custom interfaces for your gamification elements. This approach gives you full control over the presentation while still leveraging the SDK's communication with the Mambo platform.
A typical implementation pattern:
- Define event listeners for the data you need
- Call the appropriate API methods to fetch the data
- Process the returned data in your event listeners
- Render the data using your own UI components or templates
This allows you to maintain consistent branding and user experience while still taking advantage of the gamification platform's capabilities.