@smartico/public-api 0.0.174 → 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.
@@ -1,4 +1,5 @@
1
1
  declare enum JackpotType {
2
- Main = 1
2
+ Main = 1,
3
+ Personal = 2
3
4
  }
4
5
  export { JackpotType };
@@ -1,5 +1,4 @@
1
1
  import { ProtocolMessage } from '../Base/ProtocolMessage';
2
2
  export interface GetRelatedAchTourRequest extends ProtocolMessage {
3
3
  related_game_id?: string;
4
- force_language?: string;
5
4
  }
@@ -126,6 +126,6 @@ declare class SmarticoAPI {
126
126
  deleteInboxMessage(user_ext_id: string, messageGuid: string): Promise<MarkInboxMessageDeletedResponse>;
127
127
  deleteAllInboxMessages(user_ext_id: string): Promise<MarkInboxMessageDeletedResponse>;
128
128
  getWSCalls(): WSAPI;
129
- getRelatedItemsForGame(user_ext_id: string, related_game_id: string, force_language?: string): Promise<GetRelatedAchTourResponse>;
129
+ getRelatedItemsForGame(user_ext_id: string, related_game_id: string): Promise<GetRelatedAchTourResponse>;
130
130
  }
131
131
  export { SmarticoAPI, MessageSender };
@@ -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;
@@ -531,5 +528,5 @@ export declare class WSAPI {
531
528
  * });
532
529
  * ```
533
530
  */
534
- getRelatedItemsForGame(related_game_id: string, force_language?: string): Promise<GetAchievementMapResponse>;
531
+ getRelatedItemsForGame(related_game_id: string): Promise<GetAchievementMapResponse>;
535
532
  }
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();
@@ -1267,11 +1271,15 @@ var WSAPI = /*#__PURE__*/function () {
1267
1271
  on(exports.ClassId.JP_OPTOUT_RESPONSE, function (data) {
1268
1272
  return _this.jackpotClearCache();
1269
1273
  });
1274
+ on(exports.ClassId.JP_OPTIN_RESPONSE, function (data) {
1275
+ return _this.jackpotClearCache();
1276
+ });
1270
1277
  on(exports.ClassId.CLAIM_BONUS_RESPONSE, function () {
1271
1278
  return _this.updateBonuses();
1272
1279
  });
1273
1280
  on(exports.ClassId.SAW_DO_SPIN_BATCH_RESPONSE, function () {
1274
- return _this.updateOnAddSpin();
1281
+ _this.reloadMiniGameTemplate();
1282
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
1275
1283
  });
1276
1284
  }
1277
1285
  }
@@ -1702,8 +1710,7 @@ var WSAPI = /*#__PURE__*/function () {
1702
1710
  * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
1703
1711
  * The maximum number of items per request is limited to 20.
1704
1712
  * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
1705
- * 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.
1706
- * Updated templates will be passed to onUpdate callback.
1713
+ * The returned list of mini-games history is cached for 30 seconds.
1707
1714
  *
1708
1715
  * **Example**:
1709
1716
  * ```
@@ -1718,14 +1725,10 @@ var WSAPI = /*#__PURE__*/function () {
1718
1725
  _proto.getMiniGamesHistory = function getMiniGamesHistory(_ref5) {
1719
1726
  var limit = _ref5.limit,
1720
1727
  offset = _ref5.offset,
1721
- saw_template_id = _ref5.saw_template_id,
1722
- onUpdate = _ref5.onUpdate;
1728
+ saw_template_id = _ref5.saw_template_id;
1723
1729
  try {
1724
1730
  var _this17 = this;
1725
- if (onUpdate) {
1726
- _this17.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1727
- }
1728
- return Promise.resolve(OCache.use(onUpdateContextKey.Saw, exports.ECacheContext.WSAPI, function () {
1731
+ return Promise.resolve(OCache.use(onUpdateContextKey.SAWHistory, exports.ECacheContext.WSAPI, function () {
1729
1732
  return _this17.api.getSawWinningHistoryT(null, limit, offset, saw_template_id);
1730
1733
  }, CACHE_DATA_SEC));
1731
1734
  } catch (e) {
@@ -2137,36 +2140,21 @@ var WSAPI = /*#__PURE__*/function () {
2137
2140
  return Promise.reject(e);
2138
2141
  }
2139
2142
  };
2140
- _proto.updateOnAddSpin = function updateOnAddSpin() {
2143
+ _proto.reloadMiniGameTemplate = function reloadMiniGameTemplate() {
2141
2144
  try {
2142
2145
  var _this35 = this;
2143
- return Promise.resolve(_this35.api.sawGetTemplatesT(null)).then(function (payload) {
2144
- _this35.updateEntity(onUpdateContextKey.Saw, payload);
2146
+ return Promise.resolve(_this35.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
2147
+ _this35.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
2145
2148
  });
2146
2149
  } catch (e) {
2147
2150
  return Promise.reject(e);
2148
2151
  }
2149
2152
  };
2150
- _proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
2151
- try {
2152
- var _this36 = this;
2153
- var _temp9 = function () {
2154
- if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
2155
- return Promise.resolve(_this36.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
2156
- _this36.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
2157
- });
2158
- }
2159
- }();
2160
- return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
2161
- } catch (e) {
2162
- return Promise.reject(e);
2163
- }
2164
- };
2165
2153
  _proto.updateMissions = function updateMissions() {
2166
2154
  try {
2167
- var _this37 = this;
2168
- return Promise.resolve(_this37.api.missionsGetItemsT(null)).then(function (payload) {
2169
- _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);
2170
2158
  });
2171
2159
  } catch (e) {
2172
2160
  return Promise.reject(e);
@@ -2174,9 +2162,9 @@ var WSAPI = /*#__PURE__*/function () {
2174
2162
  };
2175
2163
  _proto.updateBonuses = function updateBonuses() {
2176
2164
  try {
2177
- var _this38 = this;
2178
- return Promise.resolve(_this38.api.bonusesGetItemsT(null)).then(function (payload) {
2179
- _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);
2180
2168
  });
2181
2169
  } catch (e) {
2182
2170
  return Promise.reject(e);
@@ -2184,9 +2172,9 @@ var WSAPI = /*#__PURE__*/function () {
2184
2172
  };
2185
2173
  _proto.updateTournaments = function updateTournaments() {
2186
2174
  try {
2187
- var _this39 = this;
2188
- return Promise.resolve(_this39.api.tournamentsGetLobbyT(null)).then(function (payload) {
2189
- _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);
2190
2178
  });
2191
2179
  } catch (e) {
2192
2180
  return Promise.reject(e);
@@ -2194,9 +2182,9 @@ var WSAPI = /*#__PURE__*/function () {
2194
2182
  };
2195
2183
  _proto.updateInboxMessages = function updateInboxMessages() {
2196
2184
  try {
2197
- var _this40 = this;
2198
- return Promise.resolve(_this40.api.getInboxMessagesT(null)).then(function (payload) {
2199
- _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);
2200
2188
  });
2201
2189
  } catch (e) {
2202
2190
  return Promise.reject(e);
@@ -2204,9 +2192,9 @@ var WSAPI = /*#__PURE__*/function () {
2204
2192
  };
2205
2193
  _proto.updateEntity = function updateEntity(contextKey, payload) {
2206
2194
  try {
2207
- var _this41 = this;
2195
+ var _this40 = this;
2208
2196
  OCache.set(contextKey, payload, exports.ECacheContext.WSAPI);
2209
- var onUpdate = _this41.onUpdateCallback.get(contextKey);
2197
+ var onUpdate = _this40.onUpdateCallback.get(contextKey);
2210
2198
  if (onUpdate) {
2211
2199
  onUpdate(payload);
2212
2200
  }
@@ -2246,17 +2234,17 @@ var WSAPI = /*#__PURE__*/function () {
2246
2234
  ;
2247
2235
  _proto.jackpotGet = function jackpotGet(filter) {
2248
2236
  try {
2249
- var _this42 = this;
2237
+ var _this41 = this;
2250
2238
  var signature = (filter == null ? void 0 : filter.jp_template_id) + ":" + (filter == null ? void 0 : filter.related_game_id);
2251
- if (signature !== _this42.jackpotGetSignature) {
2252
- _this42.jackpotGetSignature = signature;
2253
- _this42.jackpotClearCache();
2239
+ if (signature !== _this41.jackpotGetSignature) {
2240
+ _this41.jackpotGetSignature = signature;
2241
+ _this41.jackpotClearCache();
2254
2242
  }
2255
2243
  var jackpots = [];
2256
2244
  var pots = [];
2257
2245
  return Promise.resolve(OCache.use(onUpdateContextKey.Jackpots, exports.ECacheContext.WSAPI, function () {
2258
2246
  try {
2259
- return Promise.resolve(_this42.api.jackpotGet(null, filter)).then(function (_jackpots) {
2247
+ return Promise.resolve(_this41.api.jackpotGet(null, filter)).then(function (_jackpots) {
2260
2248
  var _pots = _jackpots.items.map(function (jp) {
2261
2249
  return jp.pot;
2262
2250
  });
@@ -2267,7 +2255,7 @@ var WSAPI = /*#__PURE__*/function () {
2267
2255
  return Promise.reject(e);
2268
2256
  }
2269
2257
  }, JACKPOT_TEMPLATE_CACHE_SEC)).then(function (_OCache$use) {
2270
- function _temp11() {
2258
+ function _temp10() {
2271
2259
  return jackpots.map(function (jp) {
2272
2260
  var _jp = _extends({}, jp, {
2273
2261
  pot: pots.find(function (p) {
@@ -2278,17 +2266,17 @@ var WSAPI = /*#__PURE__*/function () {
2278
2266
  });
2279
2267
  }
2280
2268
  jackpots = _OCache$use;
2281
- var _temp10 = function () {
2269
+ var _temp9 = function () {
2282
2270
  if (jackpots.length > 0) {
2283
2271
  return Promise.resolve(OCache.use(onUpdateContextKey.Pots, exports.ECacheContext.WSAPI, function () {
2284
2272
  try {
2285
2273
  var jp_template_ids = jackpots.map(function (jp) {
2286
2274
  return jp.jp_template_id;
2287
2275
  });
2288
- return Promise.resolve(_this42.api.potGet(null, {
2276
+ return Promise.resolve(_this41.api.potGet(null, {
2289
2277
  jp_template_ids: jp_template_ids
2290
- })).then(function (_this42$api$potGet) {
2291
- return _this42$api$potGet.items;
2278
+ })).then(function (_this41$api$potGet) {
2279
+ return _this41$api$potGet.items;
2292
2280
  });
2293
2281
  } catch (e) {
2294
2282
  return Promise.reject(e);
@@ -2298,7 +2286,7 @@ var WSAPI = /*#__PURE__*/function () {
2298
2286
  });
2299
2287
  }
2300
2288
  }();
2301
- return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
2289
+ return _temp9 && _temp9.then ? _temp9.then(_temp10) : _temp10(_temp9);
2302
2290
  });
2303
2291
  } catch (e) {
2304
2292
  return Promise.reject(e);
@@ -2321,11 +2309,11 @@ var WSAPI = /*#__PURE__*/function () {
2321
2309
  ;
2322
2310
  _proto.jackpotOptIn = function jackpotOptIn(filter) {
2323
2311
  try {
2324
- var _this43 = this;
2312
+ var _this42 = this;
2325
2313
  if (!filter.jp_template_id) {
2326
2314
  throw new Error('jp_template_id is required in jackpotOptIn');
2327
2315
  }
2328
- return Promise.resolve(_this43.api.jackpotOptIn(null, filter));
2316
+ return Promise.resolve(_this42.api.jackpotOptIn(null, filter));
2329
2317
  } catch (e) {
2330
2318
  return Promise.reject(e);
2331
2319
  }
@@ -2347,11 +2335,11 @@ var WSAPI = /*#__PURE__*/function () {
2347
2335
  ;
2348
2336
  _proto.jackpotOptOut = function jackpotOptOut(filter) {
2349
2337
  try {
2350
- var _this44 = this;
2338
+ var _this43 = this;
2351
2339
  if (!filter.jp_template_id) {
2352
2340
  throw new Error('jp_template_id is required in jackpotOptOut');
2353
2341
  }
2354
- return Promise.resolve(_this44.api.jackpotOptOut(null, filter));
2342
+ return Promise.resolve(_this43.api.jackpotOptOut(null, filter));
2355
2343
  } catch (e) {
2356
2344
  return Promise.reject(e);
2357
2345
  }
@@ -2375,10 +2363,10 @@ var WSAPI = /*#__PURE__*/function () {
2375
2363
  * ```
2376
2364
  */
2377
2365
  ;
2378
- _proto.getRelatedItemsForGame = function getRelatedItemsForGame(related_game_id, force_language) {
2366
+ _proto.getRelatedItemsForGame = function getRelatedItemsForGame(related_game_id) {
2379
2367
  try {
2380
- var _this45 = this;
2381
- return Promise.resolve(_this45.api.getRelatedItemsForGame(null, related_game_id, force_language));
2368
+ var _this44 = this;
2369
+ return Promise.resolve(_this44.api.getRelatedItemsForGame(null, related_game_id));
2382
2370
  } catch (e) {
2383
2371
  return Promise.reject(e);
2384
2372
  }
@@ -3539,13 +3527,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
3539
3527
  _proto.getWSCalls = function getWSCalls() {
3540
3528
  return new WSAPI(this);
3541
3529
  };
3542
- _proto.getRelatedItemsForGame = function getRelatedItemsForGame(user_ext_id, related_game_id, force_language) {
3530
+ _proto.getRelatedItemsForGame = function getRelatedItemsForGame(user_ext_id, related_game_id) {
3543
3531
  try {
3544
3532
  var _this62 = this;
3545
3533
  var message = _this62.buildMessage(user_ext_id, exports.ClassId.GET_RELATED_ACH_N_TOURNAMENTS_REQUEST, {
3546
3534
  related_game_id: related_game_id
3547
3535
  });
3548
- return Promise.resolve(_this62.send(message, exports.ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE, force_language));
3536
+ return Promise.resolve(_this62.send(message, exports.ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE));
3549
3537
  } catch (e) {
3550
3538
  return Promise.reject(e);
3551
3539
  }
@@ -3947,6 +3935,7 @@ var JackPotTemparature;
3947
3935
  exports.JackpotType = void 0;
3948
3936
  (function (JackpotType) {
3949
3937
  JackpotType[JackpotType["Main"] = 1] = "Main";
3938
+ JackpotType[JackpotType["Personal"] = 2] = "Personal";
3950
3939
  })(exports.JackpotType || (exports.JackpotType = {}));
3951
3940
 
3952
3941
  exports.AchCategoryTransform = AchCategoryTransform;