@smartico/public-api 0.0.69 → 0.0.71
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/README.md +15 -0
- 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 +245 -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,79 @@ 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(_temp) {
|
|
877
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
878
|
+
onUpdate = _ref.onUpdate;
|
|
842
879
|
try {
|
|
843
|
-
var
|
|
844
|
-
|
|
880
|
+
var _this3 = this;
|
|
881
|
+
if (onUpdate) {
|
|
882
|
+
_this3.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
|
|
883
|
+
}
|
|
884
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Missions, ECacheContext.WSAPI, function () {
|
|
885
|
+
return _this3.api.missionsGetItemsT(null);
|
|
886
|
+
}, CACHE_DATA_SEC));
|
|
845
887
|
} catch (e) {
|
|
846
888
|
return Promise.reject(e);
|
|
847
889
|
}
|
|
848
890
|
} /** Returns all the badges available the current user */;
|
|
849
891
|
_proto.getBadges = function getBadges() {
|
|
850
892
|
try {
|
|
851
|
-
var
|
|
852
|
-
return Promise.resolve(
|
|
893
|
+
var _this4 = this;
|
|
894
|
+
return Promise.resolve(_this4.api.badgetsGetItemsT(null));
|
|
853
895
|
} catch (e) {
|
|
854
896
|
return Promise.reject(e);
|
|
855
897
|
}
|
|
856
898
|
} /** Returns all the store items available the current user */;
|
|
857
899
|
_proto.getStoreItems = function getStoreItems() {
|
|
858
900
|
try {
|
|
859
|
-
var
|
|
860
|
-
return Promise.resolve(
|
|
901
|
+
var _this5 = this;
|
|
902
|
+
return Promise.resolve(_this5.api.storeGetItemsT(null));
|
|
861
903
|
} catch (e) {
|
|
862
904
|
return Promise.reject(e);
|
|
863
905
|
}
|
|
864
906
|
} /** Returns store categories */;
|
|
865
907
|
_proto.getStoreCategories = function getStoreCategories() {
|
|
866
908
|
try {
|
|
867
|
-
var
|
|
868
|
-
return Promise.resolve(
|
|
909
|
+
var _this6 = this;
|
|
910
|
+
return Promise.resolve(_this6.api.storeGetItemsT(null));
|
|
869
911
|
} catch (e) {
|
|
870
912
|
return Promise.reject(e);
|
|
871
913
|
}
|
|
872
|
-
}
|
|
873
|
-
|
|
914
|
+
}
|
|
915
|
+
/** Returns the list of mini-games available for user
|
|
916
|
+
* 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.
|
|
917
|
+
* 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. */
|
|
918
|
+
;
|
|
919
|
+
_proto.getMiniGames = function getMiniGames(_temp2) {
|
|
920
|
+
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
921
|
+
onUpdate = _ref2.onUpdate;
|
|
874
922
|
try {
|
|
875
|
-
var
|
|
876
|
-
|
|
923
|
+
var _this7 = this;
|
|
924
|
+
if (onUpdate) {
|
|
925
|
+
_this7.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
926
|
+
}
|
|
927
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
928
|
+
return _this7.api.sawGetTemplatesT(null);
|
|
929
|
+
}, CACHE_DATA_SEC));
|
|
877
930
|
} catch (e) {
|
|
878
931
|
return Promise.reject(e);
|
|
879
932
|
}
|
|
880
933
|
} /** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */;
|
|
881
934
|
_proto.playMiniGame = function playMiniGame(template_id) {
|
|
882
935
|
try {
|
|
883
|
-
var
|
|
884
|
-
return Promise.resolve(
|
|
936
|
+
var _this8 = this;
|
|
937
|
+
return Promise.resolve(_this8.api.sawSpinRequest(null, template_id)).then(function (r) {
|
|
938
|
+
_this8.api.doAcknowledgeRequest(null, r.request_id);
|
|
885
939
|
var o = {
|
|
886
940
|
err_code: r.errCode,
|
|
887
941
|
err_message: r.errMsg,
|
|
@@ -892,19 +946,112 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
892
946
|
} catch (e) {
|
|
893
947
|
return Promise.reject(e);
|
|
894
948
|
}
|
|
895
|
-
}
|
|
896
|
-
|
|
949
|
+
}
|
|
950
|
+
/** Returns all the active instances of tournaments
|
|
951
|
+
* 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.
|
|
952
|
+
* The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
|
|
953
|
+
;
|
|
954
|
+
_proto.getTournamentsList = function getTournamentsList(_temp3) {
|
|
955
|
+
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
956
|
+
onUpdate = _ref3.onUpdate;
|
|
897
957
|
try {
|
|
898
|
-
var
|
|
899
|
-
|
|
958
|
+
var _this9 = this;
|
|
959
|
+
if (onUpdate) {
|
|
960
|
+
_this9.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
|
|
961
|
+
}
|
|
962
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, function () {
|
|
963
|
+
return _this9.api.tournamentsGetLobbyT(null);
|
|
964
|
+
}, CACHE_DATA_SEC));
|
|
900
965
|
} catch (e) {
|
|
901
966
|
return Promise.reject(e);
|
|
902
967
|
}
|
|
903
968
|
} /** Returns details information of specific tournament instance, the response will includ tournamnet info and the leaderboard of players */;
|
|
904
969
|
_proto.getTournamentInstanceInfo = function getTournamentInstanceInfo(tournamentInstanceId) {
|
|
905
970
|
try {
|
|
906
|
-
var
|
|
907
|
-
return Promise.resolve(
|
|
971
|
+
var _this10 = this;
|
|
972
|
+
return Promise.resolve(_this10.api.tournamentsGetInfoT(null, tournamentInstanceId));
|
|
973
|
+
} catch (e) {
|
|
974
|
+
return Promise.reject(e);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
_proto.updateOnSpin = function updateOnSpin(data) {
|
|
978
|
+
try {
|
|
979
|
+
var _this11 = this;
|
|
980
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
981
|
+
return _this11.api.sawGetTemplatesT(null);
|
|
982
|
+
}, CACHE_DATA_SEC)).then(function (templates) {
|
|
983
|
+
var index = templates.findIndex(function (t) {
|
|
984
|
+
return t.id === data.saw_template_id;
|
|
985
|
+
});
|
|
986
|
+
templates[index].spin_count = data.spin_count;
|
|
987
|
+
_this11.updateEntity(onUpdateContextKey.Saw, templates);
|
|
988
|
+
});
|
|
989
|
+
} catch (e) {
|
|
990
|
+
return Promise.reject(e);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
_proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
|
|
994
|
+
try {
|
|
995
|
+
var _this12 = this;
|
|
996
|
+
var _temp5 = function () {
|
|
997
|
+
if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
|
|
998
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
|
|
999
|
+
return _this12.api.sawGetTemplatesT(null);
|
|
1000
|
+
}, CACHE_DATA_SEC)).then(function (templates) {
|
|
1001
|
+
var _template$prizes$find;
|
|
1002
|
+
var template = templates.find(function (t) {
|
|
1003
|
+
return t.prizes.find(function (p) {
|
|
1004
|
+
return p.id === data.saw_prize_id;
|
|
1005
|
+
});
|
|
1006
|
+
});
|
|
1007
|
+
var prizeType = (_template$prizes$find = template.prizes.find(function (p) {
|
|
1008
|
+
return p.id === data.saw_prize_id;
|
|
1009
|
+
})) == null ? void 0 : _template$prizes$find.prize_type;
|
|
1010
|
+
var _temp4 = function () {
|
|
1011
|
+
if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === exports.MiniGamePrizeTypeName.JACKPOT || prizeType === exports.MiniGamePrizeTypeName.SPIN) {
|
|
1012
|
+
return Promise.resolve(_this12.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
|
|
1013
|
+
_this12.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
}();
|
|
1017
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
}();
|
|
1021
|
+
return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(function () {}) : void 0);
|
|
1022
|
+
} catch (e) {
|
|
1023
|
+
return Promise.reject(e);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
_proto.updateMissionsOnOptIn = function updateMissionsOnOptIn() {
|
|
1027
|
+
try {
|
|
1028
|
+
var _this13 = this;
|
|
1029
|
+
return Promise.resolve(_this13.api.missionsGetItemsT(null)).then(function (payload) {
|
|
1030
|
+
_this13.updateEntity(onUpdateContextKey.Missions, payload);
|
|
1031
|
+
});
|
|
1032
|
+
} catch (e) {
|
|
1033
|
+
return Promise.reject(e);
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
_proto.updateTournamentsOnRegistration = function updateTournamentsOnRegistration() {
|
|
1037
|
+
try {
|
|
1038
|
+
var _this14 = this;
|
|
1039
|
+
return Promise.resolve(_this14.api.tournamentsGetLobbyT(null)).then(function (payload) {
|
|
1040
|
+
_this14.updateEntity(onUpdateContextKey.TournamentList, payload);
|
|
1041
|
+
});
|
|
1042
|
+
} catch (e) {
|
|
1043
|
+
return Promise.reject(e);
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
_proto.updateEntity = function updateEntity(contextKey, payload) {
|
|
1047
|
+
try {
|
|
1048
|
+
var _this15 = this;
|
|
1049
|
+
OCache.set(contextKey, payload, ECacheContext.WSAPI);
|
|
1050
|
+
var onUpdate = _this15.onUpdateCallback.get(contextKey);
|
|
1051
|
+
if (onUpdate) {
|
|
1052
|
+
onUpdate(payload);
|
|
1053
|
+
}
|
|
1054
|
+
return Promise.resolve();
|
|
908
1055
|
} catch (e) {
|
|
909
1056
|
return Promise.reject(e);
|
|
910
1057
|
}
|
|
@@ -1220,24 +1367,38 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1220
1367
|
return Promise.reject(e);
|
|
1221
1368
|
}
|
|
1222
1369
|
};
|
|
1223
|
-
_proto.
|
|
1370
|
+
_proto.doAcknowledgeRequest = function doAcknowledgeRequest(user_ext_id, request_id) {
|
|
1224
1371
|
try {
|
|
1225
1372
|
var _this9 = this;
|
|
1226
|
-
var message = _this9.buildMessage(user_ext_id, exports.ClassId.
|
|
1373
|
+
var message = _this9.buildMessage(user_ext_id, exports.ClassId.SAW_AKNOWLEDGE_REQUEST, {
|
|
1374
|
+
request_id: request_id
|
|
1375
|
+
});
|
|
1376
|
+
return Promise.resolve(_this9.send(message, exports.ClassId.SAW_AKNOWLEDGE_RESPONSE));
|
|
1377
|
+
} catch (e) {
|
|
1378
|
+
return Promise.reject(e);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
_proto.sawSpinRequest = function sawSpinRequest(user_ext_id, saw_template_id, round_id) {
|
|
1382
|
+
try {
|
|
1383
|
+
var _this10 = this;
|
|
1384
|
+
var request_id = IntUtils.uuid();
|
|
1385
|
+
var message = _this10.buildMessage(user_ext_id, exports.ClassId.SAW_DO_SPIN_REQUEST, {
|
|
1227
1386
|
saw_template_id: saw_template_id,
|
|
1228
|
-
request_id:
|
|
1387
|
+
request_id: request_id
|
|
1229
1388
|
});
|
|
1230
|
-
return Promise.resolve(
|
|
1389
|
+
return Promise.resolve(_this10.send(message, exports.ClassId.SAW_DO_SPIN_RESPONSE)).then(function (spinAttemptResponse) {
|
|
1231
1390
|
var _SAWSpinErrorCode$SAW;
|
|
1232
1391
|
// to simulate fail
|
|
1233
1392
|
// response.errCode = SAWSpinErrorCode.SAW_NO_SPINS;
|
|
1234
1393
|
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(
|
|
1394
|
+
return Promise.resolve(_this10.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
1236
1395
|
saw_template_id: saw_template_id,
|
|
1237
1396
|
status: status,
|
|
1238
1397
|
round_id: round_id
|
|
1239
1398
|
})).then(function () {
|
|
1240
|
-
return spinAttemptResponse
|
|
1399
|
+
return _extends({}, spinAttemptResponse, {
|
|
1400
|
+
request_id: request_id
|
|
1401
|
+
});
|
|
1241
1402
|
});
|
|
1242
1403
|
});
|
|
1243
1404
|
} catch (e) {
|
|
@@ -1252,30 +1413,30 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1252
1413
|
offset = 0;
|
|
1253
1414
|
}
|
|
1254
1415
|
try {
|
|
1255
|
-
var
|
|
1256
|
-
var message =
|
|
1416
|
+
var _this11 = this;
|
|
1417
|
+
var message = _this11.buildMessage(user_ext_id, exports.ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
|
1257
1418
|
limit: limit,
|
|
1258
1419
|
offset: offset
|
|
1259
1420
|
});
|
|
1260
|
-
return Promise.resolve(
|
|
1421
|
+
return Promise.resolve(_this11.send(message, exports.ClassId.GET_INBOX_MESSAGES_RESPONSE));
|
|
1261
1422
|
} catch (e) {
|
|
1262
1423
|
return Promise.reject(e);
|
|
1263
1424
|
}
|
|
1264
1425
|
};
|
|
1265
1426
|
_proto.storeGetItems = function storeGetItems(user_ext_id) {
|
|
1266
1427
|
try {
|
|
1267
|
-
var
|
|
1268
|
-
var message =
|
|
1269
|
-
return Promise.resolve(
|
|
1428
|
+
var _this12 = this;
|
|
1429
|
+
var message = _this12.buildMessage(user_ext_id, exports.ClassId.GET_SHOP_ITEMS_REQUEST);
|
|
1430
|
+
return Promise.resolve(_this12.send(message, exports.ClassId.GET_SHOP_ITEMS_RESPONSE));
|
|
1270
1431
|
} catch (e) {
|
|
1271
1432
|
return Promise.reject(e);
|
|
1272
1433
|
}
|
|
1273
1434
|
};
|
|
1274
1435
|
_proto.storeGetItemsT = function storeGetItemsT(user_ext_id) {
|
|
1275
1436
|
try {
|
|
1276
|
-
var
|
|
1277
|
-
return Promise.resolve(
|
|
1278
|
-
return StoreItemTransform(
|
|
1437
|
+
var _this13 = this;
|
|
1438
|
+
return Promise.resolve(_this13.storeGetItems(user_ext_id)).then(function (_this13$storeGetItems) {
|
|
1439
|
+
return StoreItemTransform(_this13$storeGetItems.items);
|
|
1279
1440
|
});
|
|
1280
1441
|
} catch (e) {
|
|
1281
1442
|
return Promise.reject(e);
|
|
@@ -1283,18 +1444,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1283
1444
|
};
|
|
1284
1445
|
_proto.storeGetCategories = function storeGetCategories(user_ext_id) {
|
|
1285
1446
|
try {
|
|
1286
|
-
var
|
|
1287
|
-
var message =
|
|
1288
|
-
return Promise.resolve(
|
|
1447
|
+
var _this14 = this;
|
|
1448
|
+
var message = _this14.buildMessage(user_ext_id, exports.ClassId.GET_SHOP_CATEGORIES_REQUEST);
|
|
1449
|
+
return Promise.resolve(_this14.send(message, exports.ClassId.GET_SHOP_CATEGORIES_RESPONSE));
|
|
1289
1450
|
} catch (e) {
|
|
1290
1451
|
return Promise.reject(e);
|
|
1291
1452
|
}
|
|
1292
1453
|
};
|
|
1293
1454
|
_proto.storeGetCategoriesT = function storeGetCategoriesT(user_ext_id) {
|
|
1294
1455
|
try {
|
|
1295
|
-
var
|
|
1296
|
-
return Promise.resolve(
|
|
1297
|
-
return StoreCategoryTransform(
|
|
1456
|
+
var _this15 = this;
|
|
1457
|
+
return Promise.resolve(_this15.storeGetCategories(user_ext_id)).then(function (_this15$storeGetCateg) {
|
|
1458
|
+
return StoreCategoryTransform(_this15$storeGetCateg.categories);
|
|
1298
1459
|
});
|
|
1299
1460
|
} catch (e) {
|
|
1300
1461
|
return Promise.reject(e);
|
|
@@ -1302,9 +1463,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1302
1463
|
};
|
|
1303
1464
|
_proto.missionsGetItems = function missionsGetItems(user_ext_id) {
|
|
1304
1465
|
try {
|
|
1305
|
-
var
|
|
1306
|
-
var message =
|
|
1307
|
-
return Promise.resolve(
|
|
1466
|
+
var _this16 = this;
|
|
1467
|
+
var message = _this16.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
1468
|
+
return Promise.resolve(_this16.send(message, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
|
|
1308
1469
|
if (response.achievements) {
|
|
1309
1470
|
response.achievements = response.achievements.filter(function (a) {
|
|
1310
1471
|
return a.ach_type_id === exports.AchievementType.Mission;
|
|
@@ -1318,9 +1479,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1318
1479
|
};
|
|
1319
1480
|
_proto.missionsGetItemsT = function missionsGetItemsT(user_ext_id) {
|
|
1320
1481
|
try {
|
|
1321
|
-
var
|
|
1322
|
-
return Promise.resolve(
|
|
1323
|
-
return UserAchievementTransform(
|
|
1482
|
+
var _this17 = this;
|
|
1483
|
+
return Promise.resolve(_this17.missionsGetItems(user_ext_id)).then(function (_this17$missionsGetIt) {
|
|
1484
|
+
return UserAchievementTransform(_this17$missionsGetIt.achievements);
|
|
1324
1485
|
});
|
|
1325
1486
|
} catch (e) {
|
|
1326
1487
|
return Promise.reject(e);
|
|
@@ -1328,9 +1489,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1328
1489
|
};
|
|
1329
1490
|
_proto.badgetsGetItems = function badgetsGetItems(user_ext_id) {
|
|
1330
1491
|
try {
|
|
1331
|
-
var
|
|
1332
|
-
var message =
|
|
1333
|
-
return Promise.resolve(
|
|
1492
|
+
var _this18 = this;
|
|
1493
|
+
var message = _this18.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
1494
|
+
return Promise.resolve(_this18.send(message, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
|
|
1334
1495
|
if (response.achievements) {
|
|
1335
1496
|
response.achievements = response.achievements.filter(function (a) {
|
|
1336
1497
|
return a.ach_type_id === exports.AchievementType.Badge;
|
|
@@ -1344,9 +1505,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1344
1505
|
};
|
|
1345
1506
|
_proto.badgetsGetItemsT = function badgetsGetItemsT(user_ext_id) {
|
|
1346
1507
|
try {
|
|
1347
|
-
var
|
|
1348
|
-
return Promise.resolve(
|
|
1349
|
-
return UserAchievementTransform(
|
|
1508
|
+
var _this19 = this;
|
|
1509
|
+
return Promise.resolve(_this19.badgetsGetItems(user_ext_id)).then(function (_this19$badgetsGetIte) {
|
|
1510
|
+
return UserAchievementTransform(_this19$badgetsGetIte.achievements);
|
|
1350
1511
|
});
|
|
1351
1512
|
} catch (e) {
|
|
1352
1513
|
return Promise.reject(e);
|
|
@@ -1354,18 +1515,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1354
1515
|
};
|
|
1355
1516
|
_proto.tournamentsGetLobby = function tournamentsGetLobby(user_ext_id) {
|
|
1356
1517
|
try {
|
|
1357
|
-
var
|
|
1358
|
-
var message =
|
|
1359
|
-
return Promise.resolve(
|
|
1518
|
+
var _this20 = this;
|
|
1519
|
+
var message = _this20.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
|
|
1520
|
+
return Promise.resolve(_this20.send(message, exports.ClassId.GET_TOURNAMENT_LOBBY_RESPONSE));
|
|
1360
1521
|
} catch (e) {
|
|
1361
1522
|
return Promise.reject(e);
|
|
1362
1523
|
}
|
|
1363
1524
|
};
|
|
1364
1525
|
_proto.tournamentsGetLobbyT = function tournamentsGetLobbyT(user_ext_id) {
|
|
1365
1526
|
try {
|
|
1366
|
-
var
|
|
1367
|
-
return Promise.resolve(
|
|
1368
|
-
return TournamentItemsTransform(
|
|
1527
|
+
var _this21 = this;
|
|
1528
|
+
return Promise.resolve(_this21.tournamentsGetLobby(user_ext_id)).then(function (_this21$tournamentsGe) {
|
|
1529
|
+
return TournamentItemsTransform(_this21$tournamentsGe.tournaments);
|
|
1369
1530
|
});
|
|
1370
1531
|
} catch (e) {
|
|
1371
1532
|
return Promise.reject(e);
|
|
@@ -1373,18 +1534,18 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1373
1534
|
};
|
|
1374
1535
|
_proto.tournamentsGetInfo = function tournamentsGetInfo(user_ext_id, tournamentInstanceId) {
|
|
1375
1536
|
try {
|
|
1376
|
-
var
|
|
1377
|
-
var message =
|
|
1537
|
+
var _this22 = this;
|
|
1538
|
+
var message = _this22.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_INFO_REQUEST, {
|
|
1378
1539
|
tournamentInstanceId: tournamentInstanceId
|
|
1379
1540
|
});
|
|
1380
|
-
return Promise.resolve(
|
|
1541
|
+
return Promise.resolve(_this22.send(message, exports.ClassId.GET_TOURNAMENT_INFO_RESPONSE)).then(function (response) {
|
|
1381
1542
|
var _response$userPositio, _response$tournamentI;
|
|
1382
1543
|
if ((_response$userPositio = response.userPosition) != null && _response$userPositio.avatar_id) {
|
|
1383
|
-
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id,
|
|
1544
|
+
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, _this22.avatarDomain);
|
|
1384
1545
|
}
|
|
1385
1546
|
if ((_response$tournamentI = response.tournamentInfo.players) != null && _response$tournamentI.length) {
|
|
1386
1547
|
response.tournamentInfo.players.forEach(function (p) {
|
|
1387
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id,
|
|
1548
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this22.avatarDomain);
|
|
1388
1549
|
});
|
|
1389
1550
|
}
|
|
1390
1551
|
return response;
|
|
@@ -1395,8 +1556,8 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1395
1556
|
};
|
|
1396
1557
|
_proto.tournamentsGetInfoT = function tournamentsGetInfoT(user_ext_id, tournamentInstanceId) {
|
|
1397
1558
|
try {
|
|
1398
|
-
var
|
|
1399
|
-
return Promise.resolve(
|
|
1559
|
+
var _this23 = this;
|
|
1560
|
+
return Promise.resolve(_this23.tournamentsGetInfo(user_ext_id, tournamentInstanceId)).then(tournamentInfoItemTransform);
|
|
1400
1561
|
} catch (e) {
|
|
1401
1562
|
return Promise.reject(e);
|
|
1402
1563
|
}
|
|
@@ -1406,13 +1567,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1406
1567
|
prevPeriod = false;
|
|
1407
1568
|
}
|
|
1408
1569
|
try {
|
|
1409
|
-
var
|
|
1410
|
-
var message =
|
|
1570
|
+
var _this24 = this;
|
|
1571
|
+
var message = _this24.buildMessage(user_ext_id, exports.ClassId.GET_LEADERS_BOARD_REQUEST, {
|
|
1411
1572
|
period_type_id: period_type_id,
|
|
1412
1573
|
snapshot_offset: prevPeriod ? 1 : 0,
|
|
1413
1574
|
include_users: true
|
|
1414
1575
|
});
|
|
1415
|
-
return Promise.resolve(
|
|
1576
|
+
return Promise.resolve(_this24.send(message, exports.ClassId.GET_LEADERS_BOARD_RESPONSE)).then(function (response) {
|
|
1416
1577
|
var _response$map$boardKe, _response$map$boardKe2, _response$map$boardKe3, _response$map$boardKe4;
|
|
1417
1578
|
var boardKey = Object.keys(response.map).find(function (k) {
|
|
1418
1579
|
return period_type_id === undefined || k === (period_type_id == null ? void 0 : period_type_id.toString());
|
|
@@ -1421,11 +1582,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1421
1582
|
return undefined;
|
|
1422
1583
|
}
|
|
1423
1584
|
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,
|
|
1585
|
+
response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(response.map[boardKey].userPosition.avatar_id, _this24.avatarDomain);
|
|
1425
1586
|
}
|
|
1426
1587
|
if ((_response$map$boardKe3 = response.map[boardKey]) != null && (_response$map$boardKe4 = _response$map$boardKe3.positions) != null && _response$map$boardKe4.length) {
|
|
1427
1588
|
response.map[boardKey].positions.forEach(function (p) {
|
|
1428
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id,
|
|
1589
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this24.avatarDomain);
|
|
1429
1590
|
});
|
|
1430
1591
|
}
|
|
1431
1592
|
return response.map[boardKey];
|
|
@@ -1436,17 +1597,17 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
1436
1597
|
};
|
|
1437
1598
|
_proto.levelsGet = function levelsGet(user_ext_id) {
|
|
1438
1599
|
try {
|
|
1439
|
-
var
|
|
1440
|
-
var message =
|
|
1441
|
-
return Promise.resolve(
|
|
1600
|
+
var _this25 = this;
|
|
1601
|
+
var message = _this25.buildMessage(user_ext_id, exports.ClassId.GET_LEVEL_MAP_REQUEST);
|
|
1602
|
+
return Promise.resolve(_this25.send(message, exports.ClassId.GET_LEVEL_MAP_RESPONSE));
|
|
1442
1603
|
} catch (e) {
|
|
1443
1604
|
return Promise.reject(e);
|
|
1444
1605
|
}
|
|
1445
1606
|
};
|
|
1446
1607
|
_proto.levelsGetT = function levelsGetT(user_ext_id) {
|
|
1447
1608
|
try {
|
|
1448
|
-
var
|
|
1449
|
-
return Promise.resolve(
|
|
1609
|
+
var _this26 = this;
|
|
1610
|
+
return Promise.resolve(_this26.levelsGet(user_ext_id)).then(GetLevelMapResponseTransform);
|
|
1450
1611
|
} catch (e) {
|
|
1451
1612
|
return Promise.reject(e);
|
|
1452
1613
|
}
|