@smartico/public-api 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OCache.d.ts +3 -1
- package/dist/SmarticoAPI.d.ts +3 -1
- package/dist/WSAPI/WSAPI.d.ts +24 -6
- package/dist/WSAPI/WSAPITypes.d.ts +3 -0
- package/dist/index.js +242 -84
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +99 -15
- package/dist/index.modern.mjs.map +1 -1
- package/docs/classes/WSAPI.md +33 -6
- package/docs/interfaces/TMiniGameTemplate.md +12 -0
- package/package.json +1 -1
- package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -2
- package/src/OCache.ts +12 -5
- package/src/SmarticoAPI.ts +14 -4
- package/src/WSAPI/WSAPI.ts +93 -13
- package/src/WSAPI/WSAPITypes.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -283,8 +283,8 @@ var SAWTemplatesTransform = function SAWTemplatesTransform(items) {
|
|
|
283
283
|
over_limit_message: r.saw_template_ui_definition.over_limit_message,
|
|
284
284
|
no_attempts_message: r.saw_template_ui_definition.no_attempts_message,
|
|
285
285
|
jackpot_symbol: r.saw_template_ui_definition.jackpot_symbol,
|
|
286
|
-
saw_game_type: SAWGameTypeNamed
|
|
287
|
-
saw_buyin_type: SAWBuyInTypeNamed
|
|
286
|
+
saw_game_type: SAWGameTypeNamed(r.saw_game_type_id),
|
|
287
|
+
saw_buyin_type: SAWBuyInTypeNamed(r.saw_buyin_type_id),
|
|
288
288
|
buyin_cost_points: r.buyin_cost_points,
|
|
289
289
|
jackpot_add_on_attempt: r.jackpot_add_on_attempt,
|
|
290
290
|
jackpot_current: r.jackpot_current,
|
|
@@ -379,14 +379,18 @@ var ECacheContext;
|
|
|
379
379
|
(function (ECacheContext) {
|
|
380
380
|
ECacheContext[ECacheContext["Translations"] = 0] = "Translations";
|
|
381
381
|
ECacheContext[ECacheContext["LabelInfo"] = 1] = "LabelInfo";
|
|
382
|
+
ECacheContext[ECacheContext["WSAPI"] = 2] = "WSAPI";
|
|
382
383
|
})(ECacheContext || (ECacheContext = {}));
|
|
383
384
|
var OCache = /*#__PURE__*/function () {
|
|
384
385
|
function OCache() {}
|
|
385
|
-
OCache.
|
|
386
|
-
var key = cacheContext.toString() + '_' + JSON.stringify(oKey);
|
|
386
|
+
OCache.init = function init(cacheContext) {
|
|
387
387
|
if (this.cache[cacheContext] === undefined) {
|
|
388
388
|
this.cache[cacheContext] = new NodeCache();
|
|
389
389
|
}
|
|
390
|
+
};
|
|
391
|
+
OCache.get = function get(oKey, cacheContext) {
|
|
392
|
+
var key = cacheContext.toString() + '_' + JSON.stringify(oKey);
|
|
393
|
+
this.init(cacheContext);
|
|
390
394
|
return this.cache[cacheContext].get(key);
|
|
391
395
|
};
|
|
392
396
|
OCache.set = function set(oKey, o, cacheContext, ttlSeconds) {
|
|
@@ -394,6 +398,7 @@ var OCache = /*#__PURE__*/function () {
|
|
|
394
398
|
ttlSeconds = 60;
|
|
395
399
|
}
|
|
396
400
|
var key = cacheContext.toString() + '_' + JSON.stringify(oKey);
|
|
401
|
+
this.init(cacheContext);
|
|
397
402
|
this.cache[cacheContext].set(key, o, ttlSeconds);
|
|
398
403
|
};
|
|
399
404
|
OCache.use = function use(oKey, cacheContext, f, ttlSeconds) {
|
|
@@ -811,12 +816,38 @@ var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels)
|
|
|
811
816
|
});
|
|
812
817
|
};
|
|
813
818
|
|
|
819
|
+
/** @hidden */
|
|
820
|
+
var CACHE_DATA_SEC = 30;
|
|
821
|
+
/** @hidden */
|
|
822
|
+
var onUpdateContextKey;
|
|
823
|
+
(function (onUpdateContextKey) {
|
|
824
|
+
onUpdateContextKey["Saw"] = "saw";
|
|
825
|
+
onUpdateContextKey["Missions"] = "missions";
|
|
826
|
+
onUpdateContextKey["TournamentList"] = "tournamentList";
|
|
827
|
+
})(onUpdateContextKey || (onUpdateContextKey = {}));
|
|
814
828
|
/** @group General API */
|
|
815
829
|
var WSAPI = /*#__PURE__*/function () {
|
|
816
830
|
/** @private */
|
|
817
831
|
function WSAPI(api) {
|
|
832
|
+
var _this = this;
|
|
818
833
|
this.api = void 0;
|
|
834
|
+
this.onUpdateCallback = new Map();
|
|
819
835
|
this.api = api;
|
|
836
|
+
var on = this.api.tracker.on;
|
|
837
|
+
on(exports.ClassId.SAW_SPINS_COUNT_PUSH, function (data) {
|
|
838
|
+
return _this.updateOnSpin(data);
|
|
839
|
+
});
|
|
840
|
+
on(exports.ClassId.SAW_DO_SPIN_RESPONSE, function (data) {
|
|
841
|
+
return on(exports.ClassId.SAW_AKNOWLEDGE_RESPONSE, function () {
|
|
842
|
+
return _this.updateOnPrizeWin(data);
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
on(exports.ClassId.MISSION_OPTIN_RESPONSE, function () {
|
|
846
|
+
return _this.updateMissionsOnOptIn();
|
|
847
|
+
});
|
|
848
|
+
on(exports.ClassId.TOURNAMENT_REGISTER_RESPONSE, function () {
|
|
849
|
+
return _this.updateTournamentsOnRegistration();
|
|
850
|
+
});
|
|
820
851
|
}
|
|
821
852
|
/** Returns information about current user */
|
|
822
853
|
var _proto = WSAPI.prototype;
|
|
@@ -832,56 +863,77 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
832
863
|
/** Returns all the levels available the current user */;
|
|
833
864
|
_proto.getLevels = function getLevels() {
|
|
834
865
|
try {
|
|
835
|
-
var
|
|
836
|
-
return Promise.resolve(
|
|
866
|
+
var _this2 = this;
|
|
867
|
+
return Promise.resolve(_this2.api.levelsGetT(null));
|
|
837
868
|
} catch (e) {
|
|
838
869
|
return Promise.reject(e);
|
|
839
870
|
}
|
|
840
|
-
}
|
|
841
|
-
|
|
871
|
+
}
|
|
872
|
+
/** Returns all the missions available the current user.
|
|
873
|
+
* The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
874
|
+
* The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
|
|
875
|
+
;
|
|
876
|
+
_proto.getMissions = function getMissions(_ref) {
|
|
877
|
+
var onUpdate = _ref.onUpdate;
|
|
842
878
|
try {
|
|
843
|
-
var
|
|
844
|
-
|
|
879
|
+
var _this3 = this;
|
|
880
|
+
if (onUpdate) {
|
|
881
|
+
_this3.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
|
|
882
|
+
}
|
|
883
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Missions, ECacheContext.WSAPI, function () {
|
|
884
|
+
return _this3.api.missionsGetItemsT(null);
|
|
885
|
+
}, CACHE_DATA_SEC));
|
|
845
886
|
} catch (e) {
|
|
846
887
|
return Promise.reject(e);
|
|
847
888
|
}
|
|
848
889
|
} /** Returns all the badges available the current user */;
|
|
849
890
|
_proto.getBadges = function getBadges() {
|
|
850
891
|
try {
|
|
851
|
-
var
|
|
852
|
-
return Promise.resolve(
|
|
892
|
+
var _this4 = this;
|
|
893
|
+
return Promise.resolve(_this4.api.badgetsGetItemsT(null));
|
|
853
894
|
} catch (e) {
|
|
854
895
|
return Promise.reject(e);
|
|
855
896
|
}
|
|
856
897
|
} /** Returns all the store items available the current user */;
|
|
857
898
|
_proto.getStoreItems = function getStoreItems() {
|
|
858
899
|
try {
|
|
859
|
-
var
|
|
860
|
-
return Promise.resolve(
|
|
900
|
+
var _this5 = this;
|
|
901
|
+
return Promise.resolve(_this5.api.storeGetItemsT(null));
|
|
861
902
|
} catch (e) {
|
|
862
903
|
return Promise.reject(e);
|
|
863
904
|
}
|
|
864
905
|
} /** Returns store categories */;
|
|
865
906
|
_proto.getStoreCategories = function getStoreCategories() {
|
|
866
907
|
try {
|
|
867
|
-
var
|
|
868
|
-
return Promise.resolve(
|
|
908
|
+
var _this6 = this;
|
|
909
|
+
return Promise.resolve(_this6.api.storeGetItemsT(null));
|
|
869
910
|
} catch (e) {
|
|
870
911
|
return Promise.reject(e);
|
|
871
912
|
}
|
|
872
|
-
}
|
|
873
|
-
|
|
913
|
+
}
|
|
914
|
+
/** Returns the list of mini-games available for user
|
|
915
|
+
* The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
916
|
+
* The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one . Updated templates will be passed to onUpdate callback. */
|
|
917
|
+
;
|
|
918
|
+
_proto.getMiniGames = function getMiniGames(_ref2) {
|
|
919
|
+
var onUpdate = _ref2.onUpdate;
|
|
874
920
|
try {
|
|
875
|
-
var
|
|
876
|
-
|
|
921
|
+
var _this7 = this;
|
|
922
|
+
if (onUpdate) {
|
|
923
|
+
_this7.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
924
|
+
}
|
|
925
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
926
|
+
return _this7.api.sawGetTemplatesT(null);
|
|
927
|
+
}, CACHE_DATA_SEC));
|
|
877
928
|
} catch (e) {
|
|
878
929
|
return Promise.reject(e);
|
|
879
930
|
}
|
|
880
931
|
} /** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */;
|
|
881
932
|
_proto.playMiniGame = function playMiniGame(template_id) {
|
|
882
933
|
try {
|
|
883
|
-
var
|
|
884
|
-
return Promise.resolve(
|
|
934
|
+
var _this8 = this;
|
|
935
|
+
return Promise.resolve(_this8.api.sawSpinRequest(null, template_id)).then(function (r) {
|
|
936
|
+
_this8.api.doAcknowledgeRequest(null, r.request_id);
|
|
885
937
|
var o = {
|
|
886
938
|
err_code: r.errCode,
|
|
887
939
|
err_message: r.errMsg,
|
|
@@ -892,19 +944,111 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
892
944
|
} catch (e) {
|
|
893
945
|
return Promise.reject(e);
|
|
894
946
|
}
|
|
895
|
-
}
|
|
896
|
-
|
|
947
|
+
}
|
|
948
|
+
/** Returns all the active instances of tournaments
|
|
949
|
+
* The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
950
|
+
* The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
|
|
951
|
+
;
|
|
952
|
+
_proto.getTournamentsList = function getTournamentsList(_ref3) {
|
|
953
|
+
var onUpdate = _ref3.onUpdate;
|
|
897
954
|
try {
|
|
898
|
-
var
|
|
899
|
-
|
|
955
|
+
var _this9 = this;
|
|
956
|
+
if (onUpdate) {
|
|
957
|
+
_this9.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
|
|
958
|
+
}
|
|
959
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, function () {
|
|
960
|
+
return _this9.api.tournamentsGetLobbyT(null);
|
|
961
|
+
}, CACHE_DATA_SEC));
|
|
900
962
|
} catch (e) {
|
|
901
963
|
return Promise.reject(e);
|
|
902
964
|
}
|
|
903
965
|
} /** Returns details information of specific tournament instance, the response will includ tournamnet info and the leaderboard of players */;
|
|
904
966
|
_proto.getTournamentInstanceInfo = function getTournamentInstanceInfo(tournamentInstanceId) {
|
|
905
967
|
try {
|
|
906
|
-
var
|
|
907
|
-
return Promise.resolve(
|
|
968
|
+
var _this10 = this;
|
|
969
|
+
return Promise.resolve(_this10.api.tournamentsGetInfoT(null, tournamentInstanceId));
|
|
970
|
+
} catch (e) {
|
|
971
|
+
return Promise.reject(e);
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
_proto.updateOnSpin = function updateOnSpin(data) {
|
|
975
|
+
try {
|
|
976
|
+
var _this11 = this;
|
|
977
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
978
|
+
return _this11.api.sawGetTemplatesT(null);
|
|
979
|
+
}, CACHE_DATA_SEC)).then(function (templates) {
|
|
980
|
+
var index = templates.findIndex(function (t) {
|
|
981
|
+
return t.id === data.saw_template_id;
|
|
982
|
+
});
|
|
983
|
+
templates[index].spin_count = data.spin_count;
|
|
984
|
+
_this11.updateEntity(onUpdateContextKey.Saw, templates);
|
|
985
|
+
});
|
|
986
|
+
} catch (e) {
|
|
987
|
+
return Promise.reject(e);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
_proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
|
|
991
|
+
try {
|
|
992
|
+
var _this12 = this;
|
|
993
|
+
var _temp2 = function () {
|
|
994
|
+
if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
|
|
995
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
996
|
+
return _this12.api.sawGetTemplatesT(null);
|
|
997
|
+
}, CACHE_DATA_SEC)).then(function (templates) {
|
|
998
|
+
var _template$prizes$find;
|
|
999
|
+
var template = templates.find(function (t) {
|
|
1000
|
+
return t.prizes.find(function (p) {
|
|
1001
|
+
return p.id === data.saw_prize_id;
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
var prizeType = (_template$prizes$find = template.prizes.find(function (p) {
|
|
1005
|
+
return p.id === data.saw_prize_id;
|
|
1006
|
+
})) == null ? void 0 : _template$prizes$find.prize_type;
|
|
1007
|
+
var _temp = function () {
|
|
1008
|
+
if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === exports.MiniGamePrizeTypeName.JACKPOT || prizeType === exports.MiniGamePrizeTypeName.SPIN) {
|
|
1009
|
+
return Promise.resolve(_this12.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
|
|
1010
|
+
_this12.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
}();
|
|
1014
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}();
|
|
1018
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
1019
|
+
} catch (e) {
|
|
1020
|
+
return Promise.reject(e);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
_proto.updateMissionsOnOptIn = function updateMissionsOnOptIn() {
|
|
1024
|
+
try {
|
|
1025
|
+
var _this13 = this;
|
|
1026
|
+
return Promise.resolve(_this13.api.missionsGetItemsT(null)).then(function (payload) {
|
|
1027
|
+
_this13.updateEntity(onUpdateContextKey.Missions, payload);
|
|
1028
|
+
});
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
return Promise.reject(e);
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
_proto.updateTournamentsOnRegistration = function updateTournamentsOnRegistration() {
|
|
1034
|
+
try {
|
|
1035
|
+
var _this14 = this;
|
|
1036
|
+
return Promise.resolve(_this14.api.tournamentsGetLobbyT(null)).then(function (payload) {
|
|
1037
|
+
_this14.updateEntity(onUpdateContextKey.TournamentList, payload);
|
|
1038
|
+
});
|
|
1039
|
+
} catch (e) {
|
|
1040
|
+
return Promise.reject(e);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
_proto.updateEntity = function updateEntity(contextKey, payload) {
|
|
1044
|
+
try {
|
|
1045
|
+
var _this15 = this;
|
|
1046
|
+
OCache.set(contextKey, payload, ECacheContext.WSAPI);
|
|
1047
|
+
var onUpdate = _this15.onUpdateCallback.get(contextKey);
|
|
1048
|
+
if (onUpdate) {
|
|
1049
|
+
onUpdate(payload);
|
|
1050
|
+
}
|
|
1051
|
+
return Promise.resolve();
|
|
908
1052
|
} catch (e) {
|
|
909
1053
|
return Promise.reject(e);
|
|
910
1054
|
}
|
|
@@ -1220,24 +1364,38 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1220
1364
|
return Promise.reject(e);
|
|
1221
1365
|
}
|
|
1222
1366
|
};
|
|
1223
|
-
_proto.
|
|
1367
|
+
_proto.doAcknowledgeRequest = function doAcknowledgeRequest(user_ext_id, request_id) {
|
|
1224
1368
|
try {
|
|
1225
1369
|
var _this9 = this;
|
|
1226
|
-
var message = _this9.buildMessage(user_ext_id, exports.ClassId.
|
|
1370
|
+
var message = _this9.buildMessage(user_ext_id, exports.ClassId.SAW_AKNOWLEDGE_REQUEST, {
|
|
1371
|
+
request_id: request_id
|
|
1372
|
+
});
|
|
1373
|
+
return Promise.resolve(_this9.send(message, exports.ClassId.SAW_AKNOWLEDGE_RESPONSE));
|
|
1374
|
+
} catch (e) {
|
|
1375
|
+
return Promise.reject(e);
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
_proto.sawSpinRequest = function sawSpinRequest(user_ext_id, saw_template_id, round_id) {
|
|
1379
|
+
try {
|
|
1380
|
+
var _this10 = this;
|
|
1381
|
+
var request_id = IntUtils.uuid();
|
|
1382
|
+
var message = _this10.buildMessage(user_ext_id, exports.ClassId.SAW_DO_SPIN_REQUEST, {
|
|
1227
1383
|
saw_template_id: saw_template_id,
|
|
1228
|
-
request_id:
|
|
1384
|
+
request_id: request_id
|
|
1229
1385
|
});
|
|
1230
|
-
return Promise.resolve(
|
|
1386
|
+
return Promise.resolve(_this10.send(message, exports.ClassId.SAW_DO_SPIN_RESPONSE)).then(function (spinAttemptResponse) {
|
|
1231
1387
|
var _SAWSpinErrorCode$SAW;
|
|
1232
1388
|
// to simulate fail
|
|
1233
1389
|
// response.errCode = SAWSpinErrorCode.SAW_NO_SPINS;
|
|
1234
1390
|
var status = (_SAWSpinErrorCode$SAW = {}, _SAWSpinErrorCode$SAW[exports.SAWSpinErrorCode.SAW_OK] = 'OK', _SAWSpinErrorCode$SAW[exports.SAWSpinErrorCode.SAW_NO_SPINS] = 'NO SPINS AVAILABLE', _SAWSpinErrorCode$SAW[exports.SAWSpinErrorCode.SAW_PRIZE_POOL_EMPTY] = 'PRIZE POOL IS EMPTY', _SAWSpinErrorCode$SAW[exports.SAWSpinErrorCode.SAW_NOT_ENOUGH_POINTS] = 'NOT ENOUGH POINTS', _SAWSpinErrorCode$SAW[exports.SAWSpinErrorCode.SAW_FAILED_MAX_SPINS_REACHED] = 'MAX SPIN ATTEMPTS REACHED', _SAWSpinErrorCode$SAW)[spinAttemptResponse.errCode] || 'OTHER';
|
|
1235
|
-
return Promise.resolve(
|
|
1391
|
+
return Promise.resolve(_this10.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
1236
1392
|
saw_template_id: saw_template_id,
|
|
1237
1393
|
status: status,
|
|
1238
1394
|
round_id: round_id
|
|
1239
1395
|
})).then(function () {
|
|
1240
|
-
return spinAttemptResponse
|
|
1396
|
+
return _extends({}, spinAttemptResponse, {
|
|
1397
|
+
request_id: request_id
|
|
1398
|
+
});
|
|
1241
1399
|
});
|
|
1242
1400
|
});
|
|
1243
1401
|
} catch (e) {
|
|
@@ -1252,30 +1410,30 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1252
1410
|
offset = 0;
|
|
1253
1411
|
}
|
|
1254
1412
|
try {
|
|
1255
|
-
var
|
|
1256
|
-
var message =
|
|
1413
|
+
var _this11 = this;
|
|
1414
|
+
var message = _this11.buildMessage(user_ext_id, exports.ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
|
1257
1415
|
limit: limit,
|
|
1258
1416
|
offset: offset
|
|
1259
1417
|
});
|
|
1260
|
-
return Promise.resolve(
|
|
1418
|
+
return Promise.resolve(_this11.send(message, exports.ClassId.GET_INBOX_MESSAGES_RESPONSE));
|
|
1261
1419
|
} catch (e) {
|
|
1262
1420
|
return Promise.reject(e);
|
|
1263
1421
|
}
|
|
1264
1422
|
};
|
|
1265
1423
|
_proto.storeGetItems = function storeGetItems(user_ext_id) {
|
|
1266
1424
|
try {
|
|
1267
|
-
var
|
|
1268
|
-
var message =
|
|
1269
|
-
return Promise.resolve(
|
|
1425
|
+
var _this12 = this;
|
|
1426
|
+
var message = _this12.buildMessage(user_ext_id, exports.ClassId.GET_SHOP_ITEMS_REQUEST);
|
|
1427
|
+
return Promise.resolve(_this12.send(message, exports.ClassId.GET_SHOP_ITEMS_RESPONSE));
|
|
1270
1428
|
} catch (e) {
|
|
1271
1429
|
return Promise.reject(e);
|
|
1272
1430
|
}
|
|
1273
1431
|
};
|
|
1274
1432
|
_proto.storeGetItemsT = function storeGetItemsT(user_ext_id) {
|
|
1275
1433
|
try {
|
|
1276
|
-
var
|
|
1277
|
-
return Promise.resolve(
|
|
1278
|
-
return StoreItemTransform(
|
|
1434
|
+
var _this13 = this;
|
|
1435
|
+
return Promise.resolve(_this13.storeGetItems(user_ext_id)).then(function (_this13$storeGetItems) {
|
|
1436
|
+
return StoreItemTransform(_this13$storeGetItems.items);
|
|
1279
1437
|
});
|
|
1280
1438
|
} catch (e) {
|
|
1281
1439
|
return Promise.reject(e);
|
|
@@ -1283,18 +1441,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1283
1441
|
};
|
|
1284
1442
|
_proto.storeGetCategories = function storeGetCategories(user_ext_id) {
|
|
1285
1443
|
try {
|
|
1286
|
-
var
|
|
1287
|
-
var message =
|
|
1288
|
-
return Promise.resolve(
|
|
1444
|
+
var _this14 = this;
|
|
1445
|
+
var message = _this14.buildMessage(user_ext_id, exports.ClassId.GET_SHOP_CATEGORIES_REQUEST);
|
|
1446
|
+
return Promise.resolve(_this14.send(message, exports.ClassId.GET_SHOP_CATEGORIES_RESPONSE));
|
|
1289
1447
|
} catch (e) {
|
|
1290
1448
|
return Promise.reject(e);
|
|
1291
1449
|
}
|
|
1292
1450
|
};
|
|
1293
1451
|
_proto.storeGetCategoriesT = function storeGetCategoriesT(user_ext_id) {
|
|
1294
1452
|
try {
|
|
1295
|
-
var
|
|
1296
|
-
return Promise.resolve(
|
|
1297
|
-
return StoreCategoryTransform(
|
|
1453
|
+
var _this15 = this;
|
|
1454
|
+
return Promise.resolve(_this15.storeGetCategories(user_ext_id)).then(function (_this15$storeGetCateg) {
|
|
1455
|
+
return StoreCategoryTransform(_this15$storeGetCateg.categories);
|
|
1298
1456
|
});
|
|
1299
1457
|
} catch (e) {
|
|
1300
1458
|
return Promise.reject(e);
|
|
@@ -1302,9 +1460,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1302
1460
|
};
|
|
1303
1461
|
_proto.missionsGetItems = function missionsGetItems(user_ext_id) {
|
|
1304
1462
|
try {
|
|
1305
|
-
var
|
|
1306
|
-
var message =
|
|
1307
|
-
return Promise.resolve(
|
|
1463
|
+
var _this16 = this;
|
|
1464
|
+
var message = _this16.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
1465
|
+
return Promise.resolve(_this16.send(message, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
|
|
1308
1466
|
if (response.achievements) {
|
|
1309
1467
|
response.achievements = response.achievements.filter(function (a) {
|
|
1310
1468
|
return a.ach_type_id === exports.AchievementType.Mission;
|
|
@@ -1318,9 +1476,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1318
1476
|
};
|
|
1319
1477
|
_proto.missionsGetItemsT = function missionsGetItemsT(user_ext_id) {
|
|
1320
1478
|
try {
|
|
1321
|
-
var
|
|
1322
|
-
return Promise.resolve(
|
|
1323
|
-
return UserAchievementTransform(
|
|
1479
|
+
var _this17 = this;
|
|
1480
|
+
return Promise.resolve(_this17.missionsGetItems(user_ext_id)).then(function (_this17$missionsGetIt) {
|
|
1481
|
+
return UserAchievementTransform(_this17$missionsGetIt.achievements);
|
|
1324
1482
|
});
|
|
1325
1483
|
} catch (e) {
|
|
1326
1484
|
return Promise.reject(e);
|
|
@@ -1328,9 +1486,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1328
1486
|
};
|
|
1329
1487
|
_proto.badgetsGetItems = function badgetsGetItems(user_ext_id) {
|
|
1330
1488
|
try {
|
|
1331
|
-
var
|
|
1332
|
-
var message =
|
|
1333
|
-
return Promise.resolve(
|
|
1489
|
+
var _this18 = this;
|
|
1490
|
+
var message = _this18.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
1491
|
+
return Promise.resolve(_this18.send(message, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
|
|
1334
1492
|
if (response.achievements) {
|
|
1335
1493
|
response.achievements = response.achievements.filter(function (a) {
|
|
1336
1494
|
return a.ach_type_id === exports.AchievementType.Badge;
|
|
@@ -1344,9 +1502,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1344
1502
|
};
|
|
1345
1503
|
_proto.badgetsGetItemsT = function badgetsGetItemsT(user_ext_id) {
|
|
1346
1504
|
try {
|
|
1347
|
-
var
|
|
1348
|
-
return Promise.resolve(
|
|
1349
|
-
return UserAchievementTransform(
|
|
1505
|
+
var _this19 = this;
|
|
1506
|
+
return Promise.resolve(_this19.badgetsGetItems(user_ext_id)).then(function (_this19$badgetsGetIte) {
|
|
1507
|
+
return UserAchievementTransform(_this19$badgetsGetIte.achievements);
|
|
1350
1508
|
});
|
|
1351
1509
|
} catch (e) {
|
|
1352
1510
|
return Promise.reject(e);
|
|
@@ -1354,18 +1512,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1354
1512
|
};
|
|
1355
1513
|
_proto.tournamentsGetLobby = function tournamentsGetLobby(user_ext_id) {
|
|
1356
1514
|
try {
|
|
1357
|
-
var
|
|
1358
|
-
var message =
|
|
1359
|
-
return Promise.resolve(
|
|
1515
|
+
var _this20 = this;
|
|
1516
|
+
var message = _this20.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
|
|
1517
|
+
return Promise.resolve(_this20.send(message, exports.ClassId.GET_TOURNAMENT_LOBBY_RESPONSE));
|
|
1360
1518
|
} catch (e) {
|
|
1361
1519
|
return Promise.reject(e);
|
|
1362
1520
|
}
|
|
1363
1521
|
};
|
|
1364
1522
|
_proto.tournamentsGetLobbyT = function tournamentsGetLobbyT(user_ext_id) {
|
|
1365
1523
|
try {
|
|
1366
|
-
var
|
|
1367
|
-
return Promise.resolve(
|
|
1368
|
-
return TournamentItemsTransform(
|
|
1524
|
+
var _this21 = this;
|
|
1525
|
+
return Promise.resolve(_this21.tournamentsGetLobby(user_ext_id)).then(function (_this21$tournamentsGe) {
|
|
1526
|
+
return TournamentItemsTransform(_this21$tournamentsGe.tournaments);
|
|
1369
1527
|
});
|
|
1370
1528
|
} catch (e) {
|
|
1371
1529
|
return Promise.reject(e);
|
|
@@ -1373,18 +1531,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1373
1531
|
};
|
|
1374
1532
|
_proto.tournamentsGetInfo = function tournamentsGetInfo(user_ext_id, tournamentInstanceId) {
|
|
1375
1533
|
try {
|
|
1376
|
-
var
|
|
1377
|
-
var message =
|
|
1534
|
+
var _this22 = this;
|
|
1535
|
+
var message = _this22.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_INFO_REQUEST, {
|
|
1378
1536
|
tournamentInstanceId: tournamentInstanceId
|
|
1379
1537
|
});
|
|
1380
|
-
return Promise.resolve(
|
|
1538
|
+
return Promise.resolve(_this22.send(message, exports.ClassId.GET_TOURNAMENT_INFO_RESPONSE)).then(function (response) {
|
|
1381
1539
|
var _response$userPositio, _response$tournamentI;
|
|
1382
1540
|
if ((_response$userPositio = response.userPosition) != null && _response$userPositio.avatar_id) {
|
|
1383
|
-
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id,
|
|
1541
|
+
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, _this22.avatarDomain);
|
|
1384
1542
|
}
|
|
1385
1543
|
if ((_response$tournamentI = response.tournamentInfo.players) != null && _response$tournamentI.length) {
|
|
1386
1544
|
response.tournamentInfo.players.forEach(function (p) {
|
|
1387
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id,
|
|
1545
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this22.avatarDomain);
|
|
1388
1546
|
});
|
|
1389
1547
|
}
|
|
1390
1548
|
return response;
|
|
@@ -1395,8 +1553,8 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1395
1553
|
};
|
|
1396
1554
|
_proto.tournamentsGetInfoT = function tournamentsGetInfoT(user_ext_id, tournamentInstanceId) {
|
|
1397
1555
|
try {
|
|
1398
|
-
var
|
|
1399
|
-
return Promise.resolve(
|
|
1556
|
+
var _this23 = this;
|
|
1557
|
+
return Promise.resolve(_this23.tournamentsGetInfo(user_ext_id, tournamentInstanceId)).then(tournamentInfoItemTransform);
|
|
1400
1558
|
} catch (e) {
|
|
1401
1559
|
return Promise.reject(e);
|
|
1402
1560
|
}
|
|
@@ -1406,13 +1564,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1406
1564
|
prevPeriod = false;
|
|
1407
1565
|
}
|
|
1408
1566
|
try {
|
|
1409
|
-
var
|
|
1410
|
-
var message =
|
|
1567
|
+
var _this24 = this;
|
|
1568
|
+
var message = _this24.buildMessage(user_ext_id, exports.ClassId.GET_LEADERS_BOARD_REQUEST, {
|
|
1411
1569
|
period_type_id: period_type_id,
|
|
1412
1570
|
snapshot_offset: prevPeriod ? 1 : 0,
|
|
1413
1571
|
include_users: true
|
|
1414
1572
|
});
|
|
1415
|
-
return Promise.resolve(
|
|
1573
|
+
return Promise.resolve(_this24.send(message, exports.ClassId.GET_LEADERS_BOARD_RESPONSE)).then(function (response) {
|
|
1416
1574
|
var _response$map$boardKe, _response$map$boardKe2, _response$map$boardKe3, _response$map$boardKe4;
|
|
1417
1575
|
var boardKey = Object.keys(response.map).find(function (k) {
|
|
1418
1576
|
return period_type_id === undefined || k === (period_type_id == null ? void 0 : period_type_id.toString());
|
|
@@ -1421,11 +1579,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1421
1579
|
return undefined;
|
|
1422
1580
|
}
|
|
1423
1581
|
if ((_response$map$boardKe = response.map[boardKey]) != null && (_response$map$boardKe2 = _response$map$boardKe.userPosition) != null && _response$map$boardKe2.avatar_id) {
|
|
1424
|
-
response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(response.map[boardKey].userPosition.avatar_id,
|
|
1582
|
+
response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(response.map[boardKey].userPosition.avatar_id, _this24.avatarDomain);
|
|
1425
1583
|
}
|
|
1426
1584
|
if ((_response$map$boardKe3 = response.map[boardKey]) != null && (_response$map$boardKe4 = _response$map$boardKe3.positions) != null && _response$map$boardKe4.length) {
|
|
1427
1585
|
response.map[boardKey].positions.forEach(function (p) {
|
|
1428
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id,
|
|
1586
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this24.avatarDomain);
|
|
1429
1587
|
});
|
|
1430
1588
|
}
|
|
1431
1589
|
return response.map[boardKey];
|
|
@@ -1436,17 +1594,17 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1436
1594
|
};
|
|
1437
1595
|
_proto.levelsGet = function levelsGet(user_ext_id) {
|
|
1438
1596
|
try {
|
|
1439
|
-
var
|
|
1440
|
-
var message =
|
|
1441
|
-
return Promise.resolve(
|
|
1597
|
+
var _this25 = this;
|
|
1598
|
+
var message = _this25.buildMessage(user_ext_id, exports.ClassId.GET_LEVEL_MAP_REQUEST);
|
|
1599
|
+
return Promise.resolve(_this25.send(message, exports.ClassId.GET_LEVEL_MAP_RESPONSE));
|
|
1442
1600
|
} catch (e) {
|
|
1443
1601
|
return Promise.reject(e);
|
|
1444
1602
|
}
|
|
1445
1603
|
};
|
|
1446
1604
|
_proto.levelsGetT = function levelsGetT(user_ext_id) {
|
|
1447
1605
|
try {
|
|
1448
|
-
var
|
|
1449
|
-
return Promise.resolve(
|
|
1606
|
+
var _this26 = this;
|
|
1607
|
+
return Promise.resolve(_this26.levelsGet(user_ext_id)).then(GetLevelMapResponseTransform);
|
|
1450
1608
|
} catch (e) {
|
|
1451
1609
|
return Promise.reject(e);
|
|
1452
1610
|
}
|