@smartico/public-api 0.0.162 → 0.0.164

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.
@@ -1,5 +1,6 @@
1
1
  export declare enum SAWAcknowledgeType {
2
2
  Silent = 1,
3
3
  QuickMessage = 2,
4
- FullMessage = 3
4
+ FullMessage = 3,
5
+ ExplicityAcknowledge = 4
5
6
  }
@@ -90,15 +90,17 @@ export declare class WSAPI {
90
90
  *
91
91
  * **Visitor mode: not supported**
92
92
  */
93
- getBonuses(): Promise<TBonus[]>;
93
+ getBonuses({ onUpdate }?: {
94
+ onUpdate?: (data: TBonus[]) => void;
95
+ }): Promise<TBonus[]>;
94
96
  /**
95
- * Claim the bonus by bonus_id. Returns the err_code in case of success or error.
96
- * Note that this method can be used only on integrations where originally failed bonus can be claimed again.
97
- * For example, user won a bonus in the mini-game, but Operator rejected this bonus.
98
- * This bonus will be available for the user to claim again.
99
- *
100
- * **Visitor mode: not supported**
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 updateMissionsOnOptIn;
399
- private updateTournamentsOnRegistration;
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
@@ -294,6 +294,7 @@ exports.SAWAcknowledgeType = void 0;
294
294
  SAWAcknowledgeType[SAWAcknowledgeType["Silent"] = 1] = "Silent";
295
295
  SAWAcknowledgeType[SAWAcknowledgeType["QuickMessage"] = 2] = "QuickMessage";
296
296
  SAWAcknowledgeType[SAWAcknowledgeType["FullMessage"] = 3] = "FullMessage";
297
+ SAWAcknowledgeType[SAWAcknowledgeType["ExplicityAcknowledge"] = 4] = "ExplicityAcknowledge";
297
298
  })(exports.SAWAcknowledgeType || (exports.SAWAcknowledgeType = {}));
298
299
 
299
300
  exports.SAWAskForUsername = void 0;
@@ -1217,10 +1218,16 @@ var WSAPI = /*#__PURE__*/function () {
1217
1218
  });
1218
1219
  });
1219
1220
  on(exports.ClassId.MISSION_OPTIN_RESPONSE, function () {
1220
- return _this.updateMissionsOnOptIn();
1221
+ return _this.updateMissions();
1222
+ });
1223
+ on(exports.ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE, function () {
1224
+ return _this.updateMissions();
1225
+ });
1226
+ on(exports.ClassId.RELOAD_ACHIEVEMENTS_EVENT, function () {
1227
+ return _this.updateMissions();
1221
1228
  });
1222
1229
  on(exports.ClassId.TOURNAMENT_REGISTER_RESPONSE, function () {
1223
- return _this.updateTournamentsOnRegistration();
1230
+ return _this.updateTournaments();
1224
1231
  });
1225
1232
  on(exports.ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, function () {
1226
1233
  return _this.updateInboxMessages();
@@ -1237,8 +1244,8 @@ var WSAPI = /*#__PURE__*/function () {
1237
1244
  on(exports.ClassId.JP_OPTOUT_RESPONSE, function (data) {
1238
1245
  return _this.jackpotClearCache();
1239
1246
  });
1240
- on(exports.ClassId.JP_OPTIN_RESPONSE, function (data) {
1241
- return _this.jackpotClearCache();
1247
+ on(exports.ClassId.CLAIM_BONUS_RESPONSE, function () {
1248
+ return _this.updateBonuses();
1242
1249
  });
1243
1250
  }
1244
1251
  }
@@ -1389,9 +1396,14 @@ var WSAPI = /*#__PURE__*/function () {
1389
1396
  * **Visitor mode: not supported**
1390
1397
  */
1391
1398
  ;
1392
- _proto.getBonuses = function getBonuses() {
1399
+ _proto.getBonuses = function getBonuses(_temp2) {
1400
+ var _ref2 = _temp2 === void 0 ? {} : _temp2,
1401
+ onUpdate = _ref2.onUpdate;
1393
1402
  try {
1394
1403
  var _this7 = this;
1404
+ if (onUpdate) {
1405
+ _this7.onUpdateCallback.set(onUpdateContextKey.Bonuses, onUpdate);
1406
+ }
1395
1407
  return Promise.resolve(OCache.use(onUpdateContextKey.Bonuses, exports.ECacheContext.WSAPI, function () {
1396
1408
  return _this7.api.bonusesGetItemsT(null);
1397
1409
  }, CACHE_DATA_SEC));
@@ -1400,13 +1412,13 @@ var WSAPI = /*#__PURE__*/function () {
1400
1412
  }
1401
1413
  }
1402
1414
  /**
1403
- * Claim the bonus by bonus_id. Returns the err_code in case of success or error.
1404
- * Note that this method can be used only on integrations where originally failed bonus can be claimed again.
1405
- * For example, user won a bonus in the mini-game, but Operator rejected this bonus.
1406
- * This bonus will be available for the user to claim again.
1407
- *
1408
- * **Visitor mode: not supported**
1409
- */
1415
+ * Claim the bonus by bonus_id. Returns the err_code in case of success or error.
1416
+ * Note that this method can be used only on integrations where originally failed bonus can be claimed again.
1417
+ * For example, user won a bonus in the mini-game, but Operator rejected this bonus.
1418
+ * This bonus will be available for the user to claim again.
1419
+ *
1420
+ * **Visitor mode: not supported**
1421
+ */
1410
1422
  ;
1411
1423
  _proto.claimBonus = function claimBonus(bonus_id) {
1412
1424
  try {
@@ -1546,11 +1558,11 @@ var WSAPI = /*#__PURE__*/function () {
1546
1558
  * **Visitor mode: not supported**
1547
1559
  */
1548
1560
  ;
1549
- _proto.getStorePurchasedItems = function getStorePurchasedItems(_temp2) {
1550
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
1551
- limit = _ref2.limit,
1552
- offset = _ref2.offset,
1553
- onUpdate = _ref2.onUpdate;
1561
+ _proto.getStorePurchasedItems = function getStorePurchasedItems(_temp3) {
1562
+ var _ref3 = _temp3 === void 0 ? {} : _temp3,
1563
+ limit = _ref3.limit,
1564
+ offset = _ref3.offset,
1565
+ onUpdate = _ref3.onUpdate;
1554
1566
  try {
1555
1567
  var _this13 = this;
1556
1568
  if (onUpdate) {
@@ -1642,9 +1654,9 @@ var WSAPI = /*#__PURE__*/function () {
1642
1654
  *
1643
1655
  */
1644
1656
  ;
1645
- _proto.getMiniGames = function getMiniGames(_temp3) {
1646
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
1647
- onUpdate = _ref3.onUpdate;
1657
+ _proto.getMiniGames = function getMiniGames(_temp4) {
1658
+ var _ref4 = _temp4 === void 0 ? {} : _temp4,
1659
+ onUpdate = _ref4.onUpdate;
1648
1660
  try {
1649
1661
  var _this16 = this;
1650
1662
  if (onUpdate) {
@@ -1738,9 +1750,9 @@ var WSAPI = /*#__PURE__*/function () {
1738
1750
  * ```
1739
1751
  * */
1740
1752
  ;
1741
- _proto.getTournamentsList = function getTournamentsList(_temp4) {
1742
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
1743
- onUpdate = _ref4.onUpdate;
1753
+ _proto.getTournamentsList = function getTournamentsList(_temp5) {
1754
+ var _ref5 = _temp5 === void 0 ? {} : _temp5,
1755
+ onUpdate = _ref5.onUpdate;
1744
1756
  try {
1745
1757
  var _this20 = this;
1746
1758
  if (onUpdate) {
@@ -1849,12 +1861,12 @@ var WSAPI = /*#__PURE__*/function () {
1849
1861
  * @param params
1850
1862
  */
1851
1863
  ;
1852
- _proto.getInboxMessages = function getInboxMessages(_temp5) {
1853
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
1854
- from = _ref5.from,
1855
- to = _ref5.to,
1856
- onlyFavorite = _ref5.onlyFavorite,
1857
- onUpdate = _ref5.onUpdate;
1864
+ _proto.getInboxMessages = function getInboxMessages(_temp6) {
1865
+ var _ref6 = _temp6 === void 0 ? {} : _temp6,
1866
+ from = _ref6.from,
1867
+ to = _ref6.to,
1868
+ onlyFavorite = _ref6.onlyFavorite,
1869
+ onUpdate = _ref6.onUpdate;
1858
1870
  try {
1859
1871
  var _this24 = this;
1860
1872
  if (onUpdate) {
@@ -2021,26 +2033,8 @@ var WSAPI = /*#__PURE__*/function () {
2021
2033
  var _this34 = this;
2022
2034
  var _temp7 = function () {
2023
2035
  if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
2024
- return Promise.resolve(OCache.use(onUpdateContextKey.Saw, exports.ECacheContext.WSAPI, function () {
2025
- return _this34.api.sawGetTemplatesT(null);
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 () {});
2036
+ return Promise.resolve(_this34.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
2037
+ _this34.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
2044
2038
  });
2045
2039
  }
2046
2040
  }();
@@ -2049,7 +2043,7 @@ var WSAPI = /*#__PURE__*/function () {
2049
2043
  return Promise.reject(e);
2050
2044
  }
2051
2045
  };
2052
- _proto.updateMissionsOnOptIn = function updateMissionsOnOptIn() {
2046
+ _proto.updateMissions = function updateMissions() {
2053
2047
  try {
2054
2048
  var _this35 = this;
2055
2049
  return Promise.resolve(_this35.api.missionsGetItemsT(null)).then(function (payload) {
@@ -2059,31 +2053,41 @@ var WSAPI = /*#__PURE__*/function () {
2059
2053
  return Promise.reject(e);
2060
2054
  }
2061
2055
  };
2062
- _proto.updateTournamentsOnRegistration = function updateTournamentsOnRegistration() {
2056
+ _proto.updateBonuses = function updateBonuses() {
2063
2057
  try {
2064
2058
  var _this36 = this;
2065
- return Promise.resolve(_this36.api.tournamentsGetLobbyT(null)).then(function (payload) {
2066
- _this36.updateEntity(onUpdateContextKey.TournamentList, payload);
2059
+ return Promise.resolve(_this36.api.bonusesGetItemsT(null)).then(function (payload) {
2060
+ _this36.updateEntity(onUpdateContextKey.Bonuses, payload);
2067
2061
  });
2068
2062
  } catch (e) {
2069
2063
  return Promise.reject(e);
2070
2064
  }
2071
2065
  };
2072
- _proto.updateInboxMessages = function updateInboxMessages() {
2066
+ _proto.updateTournaments = function updateTournaments() {
2073
2067
  try {
2074
2068
  var _this37 = this;
2075
- return Promise.resolve(_this37.api.getInboxMessagesT(null)).then(function (payload) {
2076
- _this37.updateEntity(onUpdateContextKey.InboxMessages, payload);
2069
+ return Promise.resolve(_this37.api.tournamentsGetLobbyT(null)).then(function (payload) {
2070
+ _this37.updateEntity(onUpdateContextKey.TournamentList, payload);
2077
2071
  });
2078
2072
  } catch (e) {
2079
2073
  return Promise.reject(e);
2080
2074
  }
2081
2075
  };
2082
- _proto.updateEntity = function updateEntity(contextKey, payload) {
2076
+ _proto.updateInboxMessages = function updateInboxMessages() {
2083
2077
  try {
2084
2078
  var _this38 = this;
2079
+ return Promise.resolve(_this38.api.getInboxMessagesT(null)).then(function (payload) {
2080
+ _this38.updateEntity(onUpdateContextKey.InboxMessages, payload);
2081
+ });
2082
+ } catch (e) {
2083
+ return Promise.reject(e);
2084
+ }
2085
+ };
2086
+ _proto.updateEntity = function updateEntity(contextKey, payload) {
2087
+ try {
2088
+ var _this39 = this;
2085
2089
  OCache.set(contextKey, payload, exports.ECacheContext.WSAPI);
2086
- var onUpdate = _this38.onUpdateCallback.get(contextKey);
2090
+ var onUpdate = _this39.onUpdateCallback.get(contextKey);
2087
2091
  if (onUpdate) {
2088
2092
  onUpdate(payload);
2089
2093
  }
@@ -2123,17 +2127,17 @@ var WSAPI = /*#__PURE__*/function () {
2123
2127
  ;
2124
2128
  _proto.jackpotGet = function jackpotGet(filter) {
2125
2129
  try {
2126
- var _this39 = this;
2130
+ var _this40 = this;
2127
2131
  var signature = (filter == null ? void 0 : filter.jp_template_id) + ":" + (filter == null ? void 0 : filter.related_game_id);
2128
- if (signature !== _this39.jackpotGetSignature) {
2129
- _this39.jackpotGetSignature = signature;
2130
- _this39.jackpotClearCache();
2132
+ if (signature !== _this40.jackpotGetSignature) {
2133
+ _this40.jackpotGetSignature = signature;
2134
+ _this40.jackpotClearCache();
2131
2135
  }
2132
2136
  var jackpots = [];
2133
2137
  var pots = [];
2134
2138
  return Promise.resolve(OCache.use(onUpdateContextKey.Jackpots, exports.ECacheContext.WSAPI, function () {
2135
2139
  try {
2136
- return Promise.resolve(_this39.api.jackpotGet(null, filter)).then(function (_jackpots) {
2140
+ return Promise.resolve(_this40.api.jackpotGet(null, filter)).then(function (_jackpots) {
2137
2141
  var _pots = _jackpots.items.map(function (jp) {
2138
2142
  return jp.pot;
2139
2143
  });
@@ -2162,10 +2166,10 @@ var WSAPI = /*#__PURE__*/function () {
2162
2166
  var jp_template_ids = jackpots.map(function (jp) {
2163
2167
  return jp.jp_template_id;
2164
2168
  });
2165
- return Promise.resolve(_this39.api.potGet(null, {
2169
+ return Promise.resolve(_this40.api.potGet(null, {
2166
2170
  jp_template_ids: jp_template_ids
2167
- })).then(function (_this39$api$potGet) {
2168
- return _this39$api$potGet.items;
2171
+ })).then(function (_this40$api$potGet) {
2172
+ return _this40$api$potGet.items;
2169
2173
  });
2170
2174
  } catch (e) {
2171
2175
  return Promise.reject(e);
@@ -2198,11 +2202,11 @@ var WSAPI = /*#__PURE__*/function () {
2198
2202
  ;
2199
2203
  _proto.jackpotOptIn = function jackpotOptIn(filter) {
2200
2204
  try {
2201
- var _this40 = this;
2205
+ var _this41 = this;
2202
2206
  if (!filter.jp_template_id) {
2203
2207
  throw new Error('jp_template_id is required in jackpotOptIn');
2204
2208
  }
2205
- return Promise.resolve(_this40.api.jackpotOptIn(null, filter));
2209
+ return Promise.resolve(_this41.api.jackpotOptIn(null, filter));
2206
2210
  } catch (e) {
2207
2211
  return Promise.reject(e);
2208
2212
  }
@@ -2224,11 +2228,11 @@ var WSAPI = /*#__PURE__*/function () {
2224
2228
  ;
2225
2229
  _proto.jackpotOptOut = function jackpotOptOut(filter) {
2226
2230
  try {
2227
- var _this41 = this;
2231
+ var _this42 = this;
2228
2232
  if (!filter.jp_template_id) {
2229
2233
  throw new Error('jp_template_id is required in jackpotOptOut');
2230
2234
  }
2231
- return Promise.resolve(_this41.api.jackpotOptOut(null, filter));
2235
+ return Promise.resolve(_this42.api.jackpotOptOut(null, filter));
2232
2236
  } catch (e) {
2233
2237
  return Promise.reject(e);
2234
2238
  }