@smartico/public-api 0.0.175 → 0.0.176

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.
@@ -1188,6 +1188,7 @@ var onUpdateContextKey;
1188
1188
  onUpdateContextKey["Pots"] = "Pots";
1189
1189
  onUpdateContextKey["CustomSections"] = "customSections";
1190
1190
  onUpdateContextKey["Bonuses"] = "bonuses";
1191
+ onUpdateContextKey["SAWHistory"] = "sawHistory";
1191
1192
  })(onUpdateContextKey || (onUpdateContextKey = {}));
1192
1193
  /** @group General API */
1193
1194
  class WSAPI {
@@ -1201,8 +1202,15 @@ class WSAPI {
1201
1202
  if (this.api.tracker) {
1202
1203
  const on = this.api.tracker.on;
1203
1204
  on(ClassId.SAW_SPINS_COUNT_PUSH, data => this.updateOnSpin(data));
1204
- on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
1205
- on(ClassId.SAW_DO_SPIN_RESPONSE, data => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
1205
+ on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.reloadMiniGameTemplate());
1206
+ on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => {
1207
+ this.reloadMiniGameTemplate();
1208
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1209
+ });
1210
+ on(ClassId.SAW_DO_SPIN_RESPONSE, () => {
1211
+ this.reloadMiniGameTemplate();
1212
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1213
+ });
1206
1214
  on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissions());
1207
1215
  on(ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE, () => this.updateMissions());
1208
1216
  on(ClassId.RELOAD_ACHIEVEMENTS_EVENT, () => this.updateMissions());
@@ -1214,7 +1222,10 @@ class WSAPI {
1214
1222
  on(ClassId.JP_OPTOUT_RESPONSE, data => this.jackpotClearCache());
1215
1223
  on(ClassId.JP_OPTIN_RESPONSE, data => this.jackpotClearCache());
1216
1224
  on(ClassId.CLAIM_BONUS_RESPONSE, () => this.updateBonuses());
1217
- on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => this.updateOnAddSpin());
1225
+ on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => {
1226
+ this.reloadMiniGameTemplate();
1227
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1228
+ });
1218
1229
  }
1219
1230
  }
1220
1231
  /** Returns information about current user
@@ -1527,8 +1538,7 @@ class WSAPI {
1527
1538
  * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
1528
1539
  * The maximum number of items per request is limited to 20.
1529
1540
  * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
1530
- * 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 getMiniGamesHistory with a new onUpdate callback, the old one will be overwritten by the new one.
1531
- * Updated templates will be passed to onUpdate callback.
1541
+ * The returned list of mini-games history is cached for 30 seconds.
1532
1542
  *
1533
1543
  * **Example**:
1534
1544
  * ```
@@ -1542,13 +1552,9 @@ class WSAPI {
1542
1552
  async getMiniGamesHistory({
1543
1553
  limit,
1544
1554
  offset,
1545
- saw_template_id,
1546
- onUpdate
1555
+ saw_template_id
1547
1556
  }) {
1548
- if (onUpdate) {
1549
- this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1550
- }
1551
- return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.getSawWinningHistoryT(null, limit, offset, saw_template_id), CACHE_DATA_SEC);
1557
+ return OCache.use(onUpdateContextKey.SAWHistory, ECacheContext.WSAPI, () => this.api.getSawWinningHistoryT(null, limit, offset, saw_template_id), CACHE_DATA_SEC);
1552
1558
  }
1553
1559
  /**
1554
1560
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
@@ -1830,15 +1836,9 @@ class WSAPI {
1830
1836
  templates[index].spin_count = data.spin_count;
1831
1837
  this.updateEntity(onUpdateContextKey.Saw, templates);
1832
1838
  }
1833
- async updateOnAddSpin() {
1834
- const payload = await this.api.sawGetTemplatesT(null);
1835
- this.updateEntity(onUpdateContextKey.Saw, payload);
1836
- }
1837
- async updateOnPrizeWin(data) {
1838
- if (data.errCode === SAWSpinErrorCode.SAW_OK) {
1839
- const updatedTemplates = await this.api.sawGetTemplatesT(null);
1840
- this.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
1841
- }
1839
+ async reloadMiniGameTemplate() {
1840
+ const updatedTemplates = await this.api.sawGetTemplatesT(null);
1841
+ this.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
1842
1842
  }
1843
1843
  async updateMissions() {
1844
1844
  const payload = await this.api.missionsGetItemsT(null);