var leaderboardId = "test",record = {},privateId = getUserIdFromLocalStorage();var leaderboard = new window.LViS.Leaderboard({lvis: window.LViS,id: leaderboardId});var success = function (response) {record = response;};var failure = function (error) {console.log("error:" + error.error);};if (privateId) {leaderboard.getRecord(privateId, success, failure);} else {leaderboard.setRecord(object, success, failure);}
Create a new instance as follows:
var leaderboard = new window.LViS.Leaderboard({lvis: <LViS object>,id: <id>,eventId: <eventId>,timeout: <timeout>});
where:
lvis
is the initialised LViS API object.
id
is an up to 36 chars length string unique identifier. It can be whatever you need, depending on application logic.
eventId
(optional) is a 36 chars length string unique identifier. It should be event UUID if you need to collect information in the context of a single event. Or this param can be skipped if you need to collect information for the whole project context.
timeout
(optional) is request timeout in milliseconds.
There are some parameters that can be changed on the LViS-service side and they will be automatically configured in the API using service assets:
read_endpoint
(string) - web-service endpoint for read operations.
write_endpoint
(string) - web-service endpoint for write operations.
use_base64
(bool) - send and receive base64-encoded data.
LViS API object must be initialised before creating leaderboard instance.