@smartico/public-api 0.0.161 → 0.0.163
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/WSAPI/WSAPI.d.ts +13 -10
- package/dist/index.js +74 -71
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +27 -22
- package/dist/index.modern.mjs.map +1 -1
- package/docs/classes/WSAPI.md +4 -1
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +1 -1
- package/src/WSAPI/WSAPI.ts +20 -29
package/dist/WSAPI/WSAPI.d.ts
CHANGED
|
@@ -90,15 +90,17 @@ export declare class WSAPI {
|
|
|
90
90
|
*
|
|
91
91
|
* **Visitor mode: not supported**
|
|
92
92
|
*/
|
|
93
|
-
getBonuses(
|
|
93
|
+
getBonuses({ onUpdate }?: {
|
|
94
|
+
onUpdate?: (data: TBonus[]) => void;
|
|
95
|
+
}): Promise<TBonus[]>;
|
|
94
96
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
* Claim the bonus by bonus_id. Returns the err_code in case of success or error.
|
|
98
|
+
* Note that this method can be used only on integrations where originally failed bonus can be claimed again.
|
|
99
|
+
* For example, user won a bonus in the mini-game, but Operator rejected this bonus.
|
|
100
|
+
* This bonus will be available for the user to claim again.
|
|
101
|
+
*
|
|
102
|
+
* **Visitor mode: not supported**
|
|
103
|
+
*/
|
|
102
104
|
claimBonus(bonus_id: number): Promise<TClaimBonusResult>;
|
|
103
105
|
/**
|
|
104
106
|
* Returns the extra counters for the current user level.
|
|
@@ -395,8 +397,9 @@ export declare class WSAPI {
|
|
|
395
397
|
private updateOnSpin;
|
|
396
398
|
private updateOnAddSpin;
|
|
397
399
|
private updateOnPrizeWin;
|
|
398
|
-
private
|
|
399
|
-
private
|
|
400
|
+
private updateMissions;
|
|
401
|
+
private updateBonuses;
|
|
402
|
+
private updateTournaments;
|
|
400
403
|
private updateInboxMessages;
|
|
401
404
|
private updateEntity;
|
|
402
405
|
private jackpotClearCache;
|
package/dist/index.js
CHANGED
|
@@ -1217,10 +1217,16 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1217
1217
|
});
|
|
1218
1218
|
});
|
|
1219
1219
|
on(exports.ClassId.MISSION_OPTIN_RESPONSE, function () {
|
|
1220
|
-
return _this.
|
|
1220
|
+
return _this.updateMissions();
|
|
1221
|
+
});
|
|
1222
|
+
on(exports.ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE, function () {
|
|
1223
|
+
return _this.updateMissions();
|
|
1224
|
+
});
|
|
1225
|
+
on(exports.ClassId.RELOAD_ACHIEVEMENTS_EVENT, function () {
|
|
1226
|
+
return _this.updateMissions();
|
|
1221
1227
|
});
|
|
1222
1228
|
on(exports.ClassId.TOURNAMENT_REGISTER_RESPONSE, function () {
|
|
1223
|
-
return _this.
|
|
1229
|
+
return _this.updateTournaments();
|
|
1224
1230
|
});
|
|
1225
1231
|
on(exports.ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, function () {
|
|
1226
1232
|
return _this.updateInboxMessages();
|
|
@@ -1237,8 +1243,8 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1237
1243
|
on(exports.ClassId.JP_OPTOUT_RESPONSE, function (data) {
|
|
1238
1244
|
return _this.jackpotClearCache();
|
|
1239
1245
|
});
|
|
1240
|
-
on(exports.ClassId.
|
|
1241
|
-
return _this.
|
|
1246
|
+
on(exports.ClassId.CLAIM_BONUS_RESPONSE, function () {
|
|
1247
|
+
return _this.updateBonuses();
|
|
1242
1248
|
});
|
|
1243
1249
|
}
|
|
1244
1250
|
}
|
|
@@ -1389,9 +1395,14 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1389
1395
|
* **Visitor mode: not supported**
|
|
1390
1396
|
*/
|
|
1391
1397
|
;
|
|
1392
|
-
_proto.getBonuses = function getBonuses() {
|
|
1398
|
+
_proto.getBonuses = function getBonuses(_temp2) {
|
|
1399
|
+
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
1400
|
+
onUpdate = _ref2.onUpdate;
|
|
1393
1401
|
try {
|
|
1394
1402
|
var _this7 = this;
|
|
1403
|
+
if (onUpdate) {
|
|
1404
|
+
_this7.onUpdateCallback.set(onUpdateContextKey.Bonuses, onUpdate);
|
|
1405
|
+
}
|
|
1395
1406
|
return Promise.resolve(OCache.use(onUpdateContextKey.Bonuses, exports.ECacheContext.WSAPI, function () {
|
|
1396
1407
|
return _this7.api.bonusesGetItemsT(null);
|
|
1397
1408
|
}, CACHE_DATA_SEC));
|
|
@@ -1400,13 +1411,13 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1400
1411
|
}
|
|
1401
1412
|
}
|
|
1402
1413
|
/**
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1414
|
+
* Claim the bonus by bonus_id. Returns the err_code in case of success or error.
|
|
1415
|
+
* Note that this method can be used only on integrations where originally failed bonus can be claimed again.
|
|
1416
|
+
* For example, user won a bonus in the mini-game, but Operator rejected this bonus.
|
|
1417
|
+
* This bonus will be available for the user to claim again.
|
|
1418
|
+
*
|
|
1419
|
+
* **Visitor mode: not supported**
|
|
1420
|
+
*/
|
|
1410
1421
|
;
|
|
1411
1422
|
_proto.claimBonus = function claimBonus(bonus_id) {
|
|
1412
1423
|
try {
|
|
@@ -1546,11 +1557,11 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1546
1557
|
* **Visitor mode: not supported**
|
|
1547
1558
|
*/
|
|
1548
1559
|
;
|
|
1549
|
-
_proto.getStorePurchasedItems = function getStorePurchasedItems(
|
|
1550
|
-
var
|
|
1551
|
-
limit =
|
|
1552
|
-
offset =
|
|
1553
|
-
onUpdate =
|
|
1560
|
+
_proto.getStorePurchasedItems = function getStorePurchasedItems(_temp3) {
|
|
1561
|
+
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
1562
|
+
limit = _ref3.limit,
|
|
1563
|
+
offset = _ref3.offset,
|
|
1564
|
+
onUpdate = _ref3.onUpdate;
|
|
1554
1565
|
try {
|
|
1555
1566
|
var _this13 = this;
|
|
1556
1567
|
if (onUpdate) {
|
|
@@ -1642,9 +1653,9 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1642
1653
|
*
|
|
1643
1654
|
*/
|
|
1644
1655
|
;
|
|
1645
|
-
_proto.getMiniGames = function getMiniGames(
|
|
1646
|
-
var
|
|
1647
|
-
onUpdate =
|
|
1656
|
+
_proto.getMiniGames = function getMiniGames(_temp4) {
|
|
1657
|
+
var _ref4 = _temp4 === void 0 ? {} : _temp4,
|
|
1658
|
+
onUpdate = _ref4.onUpdate;
|
|
1648
1659
|
try {
|
|
1649
1660
|
var _this16 = this;
|
|
1650
1661
|
if (onUpdate) {
|
|
@@ -1738,9 +1749,9 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1738
1749
|
* ```
|
|
1739
1750
|
* */
|
|
1740
1751
|
;
|
|
1741
|
-
_proto.getTournamentsList = function getTournamentsList(
|
|
1742
|
-
var
|
|
1743
|
-
onUpdate =
|
|
1752
|
+
_proto.getTournamentsList = function getTournamentsList(_temp5) {
|
|
1753
|
+
var _ref5 = _temp5 === void 0 ? {} : _temp5,
|
|
1754
|
+
onUpdate = _ref5.onUpdate;
|
|
1744
1755
|
try {
|
|
1745
1756
|
var _this20 = this;
|
|
1746
1757
|
if (onUpdate) {
|
|
@@ -1849,12 +1860,12 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
1849
1860
|
* @param params
|
|
1850
1861
|
*/
|
|
1851
1862
|
;
|
|
1852
|
-
_proto.getInboxMessages = function getInboxMessages(
|
|
1853
|
-
var
|
|
1854
|
-
from =
|
|
1855
|
-
to =
|
|
1856
|
-
onlyFavorite =
|
|
1857
|
-
onUpdate =
|
|
1863
|
+
_proto.getInboxMessages = function getInboxMessages(_temp6) {
|
|
1864
|
+
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
1865
|
+
from = _ref6.from,
|
|
1866
|
+
to = _ref6.to,
|
|
1867
|
+
onlyFavorite = _ref6.onlyFavorite,
|
|
1868
|
+
onUpdate = _ref6.onUpdate;
|
|
1858
1869
|
try {
|
|
1859
1870
|
var _this24 = this;
|
|
1860
1871
|
if (onUpdate) {
|
|
@@ -2021,26 +2032,8 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2021
2032
|
var _this34 = this;
|
|
2022
2033
|
var _temp7 = function () {
|
|
2023
2034
|
if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
|
|
2024
|
-
return Promise.resolve(
|
|
2025
|
-
|
|
2026
|
-
}, CACHE_DATA_SEC)).then(function (templates) {
|
|
2027
|
-
var _template$prizes$find;
|
|
2028
|
-
var template = templates.find(function (t) {
|
|
2029
|
-
return t.prizes.find(function (p) {
|
|
2030
|
-
return p.id === data.saw_prize_id;
|
|
2031
|
-
});
|
|
2032
|
-
});
|
|
2033
|
-
var prizeType = (_template$prizes$find = template.prizes.find(function (p) {
|
|
2034
|
-
return p.id === data.saw_prize_id;
|
|
2035
|
-
})) == null ? void 0 : _template$prizes$find.prize_type;
|
|
2036
|
-
var _temp6 = function () {
|
|
2037
|
-
if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === exports.MiniGamePrizeTypeName.JACKPOT || prizeType === exports.MiniGamePrizeTypeName.SPIN) {
|
|
2038
|
-
return Promise.resolve(_this34.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
|
|
2039
|
-
_this34.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
}();
|
|
2043
|
-
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
2035
|
+
return Promise.resolve(_this34.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
|
|
2036
|
+
_this34.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
2044
2037
|
});
|
|
2045
2038
|
}
|
|
2046
2039
|
}();
|
|
@@ -2049,7 +2042,7 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2049
2042
|
return Promise.reject(e);
|
|
2050
2043
|
}
|
|
2051
2044
|
};
|
|
2052
|
-
_proto.
|
|
2045
|
+
_proto.updateMissions = function updateMissions() {
|
|
2053
2046
|
try {
|
|
2054
2047
|
var _this35 = this;
|
|
2055
2048
|
return Promise.resolve(_this35.api.missionsGetItemsT(null)).then(function (payload) {
|
|
@@ -2059,31 +2052,41 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2059
2052
|
return Promise.reject(e);
|
|
2060
2053
|
}
|
|
2061
2054
|
};
|
|
2062
|
-
_proto.
|
|
2055
|
+
_proto.updateBonuses = function updateBonuses() {
|
|
2063
2056
|
try {
|
|
2064
2057
|
var _this36 = this;
|
|
2065
|
-
return Promise.resolve(_this36.api.
|
|
2066
|
-
_this36.updateEntity(onUpdateContextKey.
|
|
2058
|
+
return Promise.resolve(_this36.api.bonusesGetItemsT(null)).then(function (payload) {
|
|
2059
|
+
_this36.updateEntity(onUpdateContextKey.Bonuses, payload);
|
|
2067
2060
|
});
|
|
2068
2061
|
} catch (e) {
|
|
2069
2062
|
return Promise.reject(e);
|
|
2070
2063
|
}
|
|
2071
2064
|
};
|
|
2072
|
-
_proto.
|
|
2065
|
+
_proto.updateTournaments = function updateTournaments() {
|
|
2073
2066
|
try {
|
|
2074
2067
|
var _this37 = this;
|
|
2075
|
-
return Promise.resolve(_this37.api.
|
|
2076
|
-
_this37.updateEntity(onUpdateContextKey.
|
|
2068
|
+
return Promise.resolve(_this37.api.tournamentsGetLobbyT(null)).then(function (payload) {
|
|
2069
|
+
_this37.updateEntity(onUpdateContextKey.TournamentList, payload);
|
|
2077
2070
|
});
|
|
2078
2071
|
} catch (e) {
|
|
2079
2072
|
return Promise.reject(e);
|
|
2080
2073
|
}
|
|
2081
2074
|
};
|
|
2082
|
-
_proto.
|
|
2075
|
+
_proto.updateInboxMessages = function updateInboxMessages() {
|
|
2083
2076
|
try {
|
|
2084
2077
|
var _this38 = this;
|
|
2078
|
+
return Promise.resolve(_this38.api.getInboxMessagesT(null)).then(function (payload) {
|
|
2079
|
+
_this38.updateEntity(onUpdateContextKey.InboxMessages, payload);
|
|
2080
|
+
});
|
|
2081
|
+
} catch (e) {
|
|
2082
|
+
return Promise.reject(e);
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
_proto.updateEntity = function updateEntity(contextKey, payload) {
|
|
2086
|
+
try {
|
|
2087
|
+
var _this39 = this;
|
|
2085
2088
|
OCache.set(contextKey, payload, exports.ECacheContext.WSAPI);
|
|
2086
|
-
var onUpdate =
|
|
2089
|
+
var onUpdate = _this39.onUpdateCallback.get(contextKey);
|
|
2087
2090
|
if (onUpdate) {
|
|
2088
2091
|
onUpdate(payload);
|
|
2089
2092
|
}
|
|
@@ -2123,17 +2126,17 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2123
2126
|
;
|
|
2124
2127
|
_proto.jackpotGet = function jackpotGet(filter) {
|
|
2125
2128
|
try {
|
|
2126
|
-
var
|
|
2129
|
+
var _this40 = this;
|
|
2127
2130
|
var signature = (filter == null ? void 0 : filter.jp_template_id) + ":" + (filter == null ? void 0 : filter.related_game_id);
|
|
2128
|
-
if (signature !==
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
+
if (signature !== _this40.jackpotGetSignature) {
|
|
2132
|
+
_this40.jackpotGetSignature = signature;
|
|
2133
|
+
_this40.jackpotClearCache();
|
|
2131
2134
|
}
|
|
2132
2135
|
var jackpots = [];
|
|
2133
2136
|
var pots = [];
|
|
2134
2137
|
return Promise.resolve(OCache.use(onUpdateContextKey.Jackpots, exports.ECacheContext.WSAPI, function () {
|
|
2135
2138
|
try {
|
|
2136
|
-
return Promise.resolve(
|
|
2139
|
+
return Promise.resolve(_this40.api.jackpotGet(null, filter)).then(function (_jackpots) {
|
|
2137
2140
|
var _pots = _jackpots.items.map(function (jp) {
|
|
2138
2141
|
return jp.pot;
|
|
2139
2142
|
});
|
|
@@ -2162,10 +2165,10 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2162
2165
|
var jp_template_ids = jackpots.map(function (jp) {
|
|
2163
2166
|
return jp.jp_template_id;
|
|
2164
2167
|
});
|
|
2165
|
-
return Promise.resolve(
|
|
2168
|
+
return Promise.resolve(_this40.api.potGet(null, {
|
|
2166
2169
|
jp_template_ids: jp_template_ids
|
|
2167
|
-
})).then(function (
|
|
2168
|
-
return
|
|
2170
|
+
})).then(function (_this40$api$potGet) {
|
|
2171
|
+
return _this40$api$potGet.items;
|
|
2169
2172
|
});
|
|
2170
2173
|
} catch (e) {
|
|
2171
2174
|
return Promise.reject(e);
|
|
@@ -2198,11 +2201,11 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2198
2201
|
;
|
|
2199
2202
|
_proto.jackpotOptIn = function jackpotOptIn(filter) {
|
|
2200
2203
|
try {
|
|
2201
|
-
var
|
|
2204
|
+
var _this41 = this;
|
|
2202
2205
|
if (!filter.jp_template_id) {
|
|
2203
2206
|
throw new Error('jp_template_id is required in jackpotOptIn');
|
|
2204
2207
|
}
|
|
2205
|
-
return Promise.resolve(
|
|
2208
|
+
return Promise.resolve(_this41.api.jackpotOptIn(null, filter));
|
|
2206
2209
|
} catch (e) {
|
|
2207
2210
|
return Promise.reject(e);
|
|
2208
2211
|
}
|
|
@@ -2224,11 +2227,11 @@ var WSAPI = /*#__PURE__*/function () {
|
|
|
2224
2227
|
;
|
|
2225
2228
|
_proto.jackpotOptOut = function jackpotOptOut(filter) {
|
|
2226
2229
|
try {
|
|
2227
|
-
var
|
|
2230
|
+
var _this42 = this;
|
|
2228
2231
|
if (!filter.jp_template_id) {
|
|
2229
2232
|
throw new Error('jp_template_id is required in jackpotOptOut');
|
|
2230
2233
|
}
|
|
2231
|
-
return Promise.resolve(
|
|
2234
|
+
return Promise.resolve(_this42.api.jackpotOptOut(null, filter));
|
|
2232
2235
|
} catch (e) {
|
|
2233
2236
|
return Promise.reject(e);
|
|
2234
2237
|
}
|
|
@@ -2496,7 +2499,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
2496
2499
|
}
|
|
2497
2500
|
});
|
|
2498
2501
|
}, function (e) {
|
|
2499
|
-
_this.logger.
|
|
2502
|
+
_this.logger.warn("Failed to make request to smartico channel, L2. " + e.message, {
|
|
2500
2503
|
url: _this.publicUrl,
|
|
2501
2504
|
request: message,
|
|
2502
2505
|
error: e.message
|