@smartico/public-api 0.0.175 → 0.0.177

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.
@@ -2,4 +2,10 @@ import { ProtocolResponse } from '../Base/ProtocolResponse';
2
2
  export interface GetAchievementsUserInfoResponse extends ProtocolResponse {
3
3
  level_counter_1?: number;
4
4
  level_counter_2?: number;
5
+ points_balance: number;
6
+ points_ever: number;
7
+ current_level: number;
8
+ points_board_period_type_1: number;
9
+ points_board_period_type_2: number;
10
+ points_board_period_type_3: number;
5
11
  }
@@ -254,8 +254,7 @@ export declare class WSAPI {
254
254
  * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
255
255
  * The maximum number of items per request is limited to 20.
256
256
  * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
257
- * 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.
258
- * Updated templates will be passed to onUpdate callback.
257
+ * The returned list of mini-games history is cached for 30 seconds.
259
258
  *
260
259
  * **Example**:
261
260
  * ```
@@ -266,11 +265,10 @@ export declare class WSAPI {
266
265
  *
267
266
  * **Visitor mode: not supported**
268
267
  */
269
- getMiniGamesHistory({ limit, offset, saw_template_id, onUpdate }: {
268
+ getMiniGamesHistory({ limit, offset, saw_template_id }: {
270
269
  limit?: number;
271
270
  offset?: number;
272
271
  saw_template_id?: number;
273
- onUpdate?: (data: TMiniGameTemplate[]) => void;
274
272
  }): Promise<TSawHistory[]>;
275
273
  /**
276
274
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
@@ -448,8 +446,7 @@ export declare class WSAPI {
448
446
  */
449
447
  getTranslations(lang_code: string): Promise<TGetTranslations>;
450
448
  private updateOnSpin;
451
- private updateOnAddSpin;
452
- private updateOnPrizeWin;
449
+ private reloadMiniGameTemplate;
453
450
  private updateMissions;
454
451
  private updateBonuses;
455
452
  private updateTournaments;
package/dist/index.js CHANGED
@@ -1216,6 +1216,7 @@ var onUpdateContextKey;
1216
1216
  onUpdateContextKey["Pots"] = "Pots";
1217
1217
  onUpdateContextKey["CustomSections"] = "customSections";
1218
1218
  onUpdateContextKey["Bonuses"] = "bonuses";
1219
+ onUpdateContextKey["SAWHistory"] = "sawHistory";
1219
1220
  })(onUpdateContextKey || (onUpdateContextKey = {}));
1220
1221
  /** @group General API */
1221
1222
  var WSAPI = /*#__PURE__*/function () {
@@ -1233,12 +1234,15 @@ var WSAPI = /*#__PURE__*/function () {
1233
1234
  return _this.updateOnSpin(data);
1234
1235
  });
1235
1236
  on(exports.ClassId.SAW_SHOW_SPIN_PUSH, function () {
1236
- return _this.updateOnAddSpin();
1237
+ return _this.reloadMiniGameTemplate();
1237
1238
  });
1238
- on(exports.ClassId.SAW_DO_SPIN_RESPONSE, function (data) {
1239
- return on(exports.ClassId.SAW_AKNOWLEDGE_RESPONSE, function () {
1240
- return _this.updateOnPrizeWin(data);
1241
- });
1239
+ on(exports.ClassId.SAW_AKNOWLEDGE_RESPONSE, function () {
1240
+ _this.reloadMiniGameTemplate();
1241
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1242
+ });
1243
+ on(exports.ClassId.SAW_DO_SPIN_RESPONSE, function () {
1244
+ _this.reloadMiniGameTemplate();
1245
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1242
1246
  });
1243
1247
  on(exports.ClassId.MISSION_OPTIN_RESPONSE, function () {
1244
1248
  return _this.updateMissions();
@@ -1274,7 +1278,8 @@ var WSAPI = /*#__PURE__*/function () {
1274
1278
  return _this.updateBonuses();
1275
1279
  });
1276
1280
  on(exports.ClassId.SAW_DO_SPIN_BATCH_RESPONSE, function () {
1277
- return _this.updateOnAddSpin();
1281
+ _this.reloadMiniGameTemplate();
1282
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1278
1283
  });
1279
1284
  }
1280
1285
  }
@@ -1705,8 +1710,7 @@ var WSAPI = /*#__PURE__*/function () {
1705
1710
  * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
1706
1711
  * The maximum number of items per request is limited to 20.
1707
1712
  * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
1708
- * 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.
1709
- * Updated templates will be passed to onUpdate callback.
1713
+ * The returned list of mini-games history is cached for 30 seconds.
1710
1714
  *
1711
1715
  * **Example**:
1712
1716
  * ```
@@ -1721,14 +1725,10 @@ var WSAPI = /*#__PURE__*/function () {
1721
1725
  _proto.getMiniGamesHistory = function getMiniGamesHistory(_ref5) {
1722
1726
  var limit = _ref5.limit,
1723
1727
  offset = _ref5.offset,
1724
- saw_template_id = _ref5.saw_template_id,
1725
- onUpdate = _ref5.onUpdate;
1728
+ saw_template_id = _ref5.saw_template_id;
1726
1729
  try {
1727
1730
  var _this17 = this;
1728
- if (onUpdate) {
1729
- _this17.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1730
- }
1731
- return Promise.resolve(OCache.use(onUpdateContextKey.Saw, exports.ECacheContext.WSAPI, function () {
1731
+ return Promise.resolve(OCache.use(onUpdateContextKey.SAWHistory, exports.ECacheContext.WSAPI, function () {
1732
1732
  return _this17.api.getSawWinningHistoryT(null, limit, offset, saw_template_id);
1733
1733
  }, CACHE_DATA_SEC));
1734
1734
  } catch (e) {
@@ -2140,36 +2140,21 @@ var WSAPI = /*#__PURE__*/function () {
2140
2140
  return Promise.reject(e);
2141
2141
  }
2142
2142
  };
2143
- _proto.updateOnAddSpin = function updateOnAddSpin() {
2143
+ _proto.reloadMiniGameTemplate = function reloadMiniGameTemplate() {
2144
2144
  try {
2145
2145
  var _this35 = this;
2146
- return Promise.resolve(_this35.api.sawGetTemplatesT(null)).then(function (payload) {
2147
- _this35.updateEntity(onUpdateContextKey.Saw, payload);
2146
+ return Promise.resolve(_this35.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
2147
+ _this35.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
2148
2148
  });
2149
2149
  } catch (e) {
2150
2150
  return Promise.reject(e);
2151
2151
  }
2152
2152
  };
2153
- _proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
2154
- try {
2155
- var _this36 = this;
2156
- var _temp9 = function () {
2157
- if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
2158
- return Promise.resolve(_this36.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
2159
- _this36.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
2160
- });
2161
- }
2162
- }();
2163
- return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
2164
- } catch (e) {
2165
- return Promise.reject(e);
2166
- }
2167
- };
2168
2153
  _proto.updateMissions = function updateMissions() {
2169
2154
  try {
2170
- var _this37 = this;
2171
- return Promise.resolve(_this37.api.missionsGetItemsT(null)).then(function (payload) {
2172
- _this37.updateEntity(onUpdateContextKey.Missions, payload);
2155
+ var _this36 = this;
2156
+ return Promise.resolve(_this36.api.missionsGetItemsT(null)).then(function (payload) {
2157
+ _this36.updateEntity(onUpdateContextKey.Missions, payload);
2173
2158
  });
2174
2159
  } catch (e) {
2175
2160
  return Promise.reject(e);
@@ -2177,9 +2162,9 @@ var WSAPI = /*#__PURE__*/function () {
2177
2162
  };
2178
2163
  _proto.updateBonuses = function updateBonuses() {
2179
2164
  try {
2180
- var _this38 = this;
2181
- return Promise.resolve(_this38.api.bonusesGetItemsT(null)).then(function (payload) {
2182
- _this38.updateEntity(onUpdateContextKey.Bonuses, payload);
2165
+ var _this37 = this;
2166
+ return Promise.resolve(_this37.api.bonusesGetItemsT(null)).then(function (payload) {
2167
+ _this37.updateEntity(onUpdateContextKey.Bonuses, payload);
2183
2168
  });
2184
2169
  } catch (e) {
2185
2170
  return Promise.reject(e);
@@ -2187,9 +2172,9 @@ var WSAPI = /*#__PURE__*/function () {
2187
2172
  };
2188
2173
  _proto.updateTournaments = function updateTournaments() {
2189
2174
  try {
2190
- var _this39 = this;
2191
- return Promise.resolve(_this39.api.tournamentsGetLobbyT(null)).then(function (payload) {
2192
- _this39.updateEntity(onUpdateContextKey.TournamentList, payload);
2175
+ var _this38 = this;
2176
+ return Promise.resolve(_this38.api.tournamentsGetLobbyT(null)).then(function (payload) {
2177
+ _this38.updateEntity(onUpdateContextKey.TournamentList, payload);
2193
2178
  });
2194
2179
  } catch (e) {
2195
2180
  return Promise.reject(e);
@@ -2197,9 +2182,9 @@ var WSAPI = /*#__PURE__*/function () {
2197
2182
  };
2198
2183
  _proto.updateInboxMessages = function updateInboxMessages() {
2199
2184
  try {
2200
- var _this40 = this;
2201
- return Promise.resolve(_this40.api.getInboxMessagesT(null)).then(function (payload) {
2202
- _this40.updateEntity(onUpdateContextKey.InboxMessages, payload);
2185
+ var _this39 = this;
2186
+ return Promise.resolve(_this39.api.getInboxMessagesT(null)).then(function (payload) {
2187
+ _this39.updateEntity(onUpdateContextKey.InboxMessages, payload);
2203
2188
  });
2204
2189
  } catch (e) {
2205
2190
  return Promise.reject(e);
@@ -2207,9 +2192,9 @@ var WSAPI = /*#__PURE__*/function () {
2207
2192
  };
2208
2193
  _proto.updateEntity = function updateEntity(contextKey, payload) {
2209
2194
  try {
2210
- var _this41 = this;
2195
+ var _this40 = this;
2211
2196
  OCache.set(contextKey, payload, exports.ECacheContext.WSAPI);
2212
- var onUpdate = _this41.onUpdateCallback.get(contextKey);
2197
+ var onUpdate = _this40.onUpdateCallback.get(contextKey);
2213
2198
  if (onUpdate) {
2214
2199
  onUpdate(payload);
2215
2200
  }
@@ -2249,17 +2234,17 @@ var WSAPI = /*#__PURE__*/function () {
2249
2234
  ;
2250
2235
  _proto.jackpotGet = function jackpotGet(filter) {
2251
2236
  try {
2252
- var _this42 = this;
2237
+ var _this41 = this;
2253
2238
  var signature = (filter == null ? void 0 : filter.jp_template_id) + ":" + (filter == null ? void 0 : filter.related_game_id);
2254
- if (signature !== _this42.jackpotGetSignature) {
2255
- _this42.jackpotGetSignature = signature;
2256
- _this42.jackpotClearCache();
2239
+ if (signature !== _this41.jackpotGetSignature) {
2240
+ _this41.jackpotGetSignature = signature;
2241
+ _this41.jackpotClearCache();
2257
2242
  }
2258
2243
  var jackpots = [];
2259
2244
  var pots = [];
2260
2245
  return Promise.resolve(OCache.use(onUpdateContextKey.Jackpots, exports.ECacheContext.WSAPI, function () {
2261
2246
  try {
2262
- return Promise.resolve(_this42.api.jackpotGet(null, filter)).then(function (_jackpots) {
2247
+ return Promise.resolve(_this41.api.jackpotGet(null, filter)).then(function (_jackpots) {
2263
2248
  var _pots = _jackpots.items.map(function (jp) {
2264
2249
  return jp.pot;
2265
2250
  });
@@ -2270,7 +2255,7 @@ var WSAPI = /*#__PURE__*/function () {
2270
2255
  return Promise.reject(e);
2271
2256
  }
2272
2257
  }, JACKPOT_TEMPLATE_CACHE_SEC)).then(function (_OCache$use) {
2273
- function _temp11() {
2258
+ function _temp10() {
2274
2259
  return jackpots.map(function (jp) {
2275
2260
  var _jp = _extends({}, jp, {
2276
2261
  pot: pots.find(function (p) {
@@ -2281,17 +2266,17 @@ var WSAPI = /*#__PURE__*/function () {
2281
2266
  });
2282
2267
  }
2283
2268
  jackpots = _OCache$use;
2284
- var _temp10 = function () {
2269
+ var _temp9 = function () {
2285
2270
  if (jackpots.length > 0) {
2286
2271
  return Promise.resolve(OCache.use(onUpdateContextKey.Pots, exports.ECacheContext.WSAPI, function () {
2287
2272
  try {
2288
2273
  var jp_template_ids = jackpots.map(function (jp) {
2289
2274
  return jp.jp_template_id;
2290
2275
  });
2291
- return Promise.resolve(_this42.api.potGet(null, {
2276
+ return Promise.resolve(_this41.api.potGet(null, {
2292
2277
  jp_template_ids: jp_template_ids
2293
- })).then(function (_this42$api$potGet) {
2294
- return _this42$api$potGet.items;
2278
+ })).then(function (_this41$api$potGet) {
2279
+ return _this41$api$potGet.items;
2295
2280
  });
2296
2281
  } catch (e) {
2297
2282
  return Promise.reject(e);
@@ -2301,7 +2286,7 @@ var WSAPI = /*#__PURE__*/function () {
2301
2286
  });
2302
2287
  }
2303
2288
  }();
2304
- return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
2289
+ return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9);
2305
2290
  });
2306
2291
  } catch (e) {
2307
2292
  return Promise.reject(e);
@@ -2324,11 +2309,11 @@ var WSAPI = /*#__PURE__*/function () {
2324
2309
  ;
2325
2310
  _proto.jackpotOptIn = function jackpotOptIn(filter) {
2326
2311
  try {
2327
- var _this43 = this;
2312
+ var _this42 = this;
2328
2313
  if (!filter.jp_template_id) {
2329
2314
  throw new Error('jp_template_id is required in jackpotOptIn');
2330
2315
  }
2331
- return Promise.resolve(_this43.api.jackpotOptIn(null, filter));
2316
+ return Promise.resolve(_this42.api.jackpotOptIn(null, filter));
2332
2317
  } catch (e) {
2333
2318
  return Promise.reject(e);
2334
2319
  }
@@ -2350,11 +2335,11 @@ var WSAPI = /*#__PURE__*/function () {
2350
2335
  ;
2351
2336
  _proto.jackpotOptOut = function jackpotOptOut(filter) {
2352
2337
  try {
2353
- var _this44 = this;
2338
+ var _this43 = this;
2354
2339
  if (!filter.jp_template_id) {
2355
2340
  throw new Error('jp_template_id is required in jackpotOptOut');
2356
2341
  }
2357
- return Promise.resolve(_this44.api.jackpotOptOut(null, filter));
2342
+ return Promise.resolve(_this43.api.jackpotOptOut(null, filter));
2358
2343
  } catch (e) {
2359
2344
  return Promise.reject(e);
2360
2345
  }
@@ -2380,8 +2365,8 @@ var WSAPI = /*#__PURE__*/function () {
2380
2365
  ;
2381
2366
  _proto.getRelatedItemsForGame = function getRelatedItemsForGame(related_game_id) {
2382
2367
  try {
2383
- var _this45 = this;
2384
- return Promise.resolve(_this45.api.getRelatedItemsForGame(null, related_game_id));
2368
+ var _this44 = this;
2369
+ return Promise.resolve(_this44.api.getRelatedItemsForGame(null, related_game_id));
2385
2370
  } catch (e) {
2386
2371
  return Promise.reject(e);
2387
2372
  }