@smartico/public-api 0.0.172 → 0.0.174

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.
@@ -108,6 +108,8 @@ var ClassId;
108
108
  ClassId[ClassId["SAW_DO_SPIN_BATCH_RESPONSE"] = 713] = "SAW_DO_SPIN_BATCH_RESPONSE";
109
109
  ClassId[ClassId["SAW_AKNOWLEDGE_BATCH_REQUEST"] = 714] = "SAW_AKNOWLEDGE_BATCH_REQUEST";
110
110
  ClassId[ClassId["SAW_AKNOWLEDGE_BATCH_RESPONSE"] = 715] = "SAW_AKNOWLEDGE_BATCH_RESPONSE";
111
+ ClassId[ClassId["GET_SAW_HISTORY_REQUEST"] = 716] = "GET_SAW_HISTORY_REQUEST";
112
+ ClassId[ClassId["GET_SAW_HISTORY_RESPONSE"] = 717] = "GET_SAW_HISTORY_RESPONSE";
111
113
  /*
112
114
  !Important, if adding new messages that are 'acting' on behalf of the client,
113
115
  you need to include them in the CLASS_ID_IGNORE_FOR_SIMULATION
@@ -378,7 +380,10 @@ const SAWTemplatesTransform = items => {
378
380
  acknowledge_action_title: p.saw_prize_ui_definition.acknowledge_action_title,
379
381
  pool: p.pool,
380
382
  pool_initial: p.pool_initial,
381
- wins_count: p.wins_count
383
+ wins_count: p.wins_count,
384
+ weekdays: p.weekdays,
385
+ active_from_ts: p.active_from_ts,
386
+ active_till_ts: p.active_till_ts
382
387
  };
383
388
  return y;
384
389
  })
@@ -421,6 +426,20 @@ const SAWWinSoundFiles = {
421
426
  [SAWWinSoundType.HighlyPositive]: 'saw-highly-positive.m4a'
422
427
  };
423
428
 
429
+ const SAWHistoryTransform = items => {
430
+ return items.map(r => {
431
+ const x = {
432
+ template: r.template,
433
+ saw_template_id: r.saw_template_id,
434
+ saw_prize_id: r.saw_prize_id,
435
+ prize_amount: r.prize_amount,
436
+ client_request_id: r.client_request_id,
437
+ is_claimed: r.is_claimed
438
+ };
439
+ return x;
440
+ });
441
+ };
442
+
424
443
  class NodeCache {
425
444
  constructor() {
426
445
  if (NodeCache.ttlChecker === undefined) {
@@ -1194,6 +1213,7 @@ class WSAPI {
1194
1213
  on(ClassId.JP_WIN_PUSH, data => this.jackpotClearCache());
1195
1214
  on(ClassId.JP_OPTOUT_RESPONSE, data => this.jackpotClearCache());
1196
1215
  on(ClassId.CLAIM_BONUS_RESPONSE, () => this.updateBonuses());
1216
+ on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => this.updateOnAddSpin());
1197
1217
  }
1198
1218
  }
1199
1219
  /** Returns information about current user
@@ -1502,8 +1522,37 @@ class WSAPI {
1502
1522
  }
1503
1523
  return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
1504
1524
  }
1525
+ /**
1526
+ * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
1527
+ * The maximum number of items per request is limited to 20.
1528
+ * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
1529
+ * 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.
1530
+ * Updated templates will be passed to onUpdate callback.
1531
+ *
1532
+ * **Example**:
1533
+ * ```
1534
+ * _smartico.api.getMiniGamesHistory().then((result) => {
1535
+ * console.log(result);
1536
+ * });
1537
+ * ```
1538
+ *
1539
+ * **Visitor mode: not supported**
1540
+ */
1541
+ async getMiniGamesHistory({
1542
+ limit,
1543
+ offset,
1544
+ saw_template_id,
1545
+ onUpdate
1546
+ }) {
1547
+ if (onUpdate) {
1548
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1549
+ }
1550
+ return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.getSawWinningHistoryT(null, limit, offset, saw_template_id), CACHE_DATA_SEC);
1551
+ }
1505
1552
  /**
1506
1553
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
1554
+ * After playMiniGame is called, you can call getMiniGames to get the list of mini-games.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 playMiniGame with a new onUpdate callback, the old one will be overwritten by the new one.
1555
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
1507
1556
  *
1508
1557
  * **Example**:
1509
1558
  * ```
@@ -1514,7 +1563,12 @@ class WSAPI {
1514
1563
  *
1515
1564
  * **Visitor mode: not supported**
1516
1565
  */
1517
- async playMiniGame(template_id) {
1566
+ async playMiniGame(template_id, {
1567
+ onUpdate
1568
+ } = {}) {
1569
+ if (onUpdate) {
1570
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1571
+ }
1518
1572
  const r = await this.api.sawSpinRequest(null, template_id);
1519
1573
  this.api.doAcknowledgeRequest(null, r.request_id);
1520
1574
  const o = {
@@ -1526,6 +1580,8 @@ class WSAPI {
1526
1580
  }
1527
1581
  /**
1528
1582
  * Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
1583
+ * After playMiniGameBatch is called, you can call getMiniGames to get the list of mini-games. 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 playMiniGameBatch with a new onUpdate callback, the old one will be overwritten by the new one.
1584
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
1529
1585
  *
1530
1586
  * **Example**:
1531
1587
  * ```
@@ -1535,7 +1591,12 @@ class WSAPI {
1535
1591
  * ```
1536
1592
  * **Visitor mode: not supported**
1537
1593
  */
1538
- async playMiniGameBatch(template_id, spin_count) {
1594
+ async playMiniGameBatch(template_id, spin_count, {
1595
+ onUpdate
1596
+ } = {}) {
1597
+ if (onUpdate) {
1598
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
1599
+ }
1539
1600
  const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
1540
1601
  const request_ids = response.results.map(result => result.request_id);
1541
1602
  this.api.doAcknowledgeBatchRequest(null, request_ids);
@@ -1914,8 +1975,8 @@ class WSAPI {
1914
1975
  * });
1915
1976
  * ```
1916
1977
  */
1917
- async getRelatedItemsForGame(related_game_id) {
1918
- const result = await this.api.getRelatedItemsForGame(null, related_game_id);
1978
+ async getRelatedItemsForGame(related_game_id, force_language) {
1979
+ const result = await this.api.getRelatedItemsForGame(null, related_game_id, force_language);
1919
1980
  return result;
1920
1981
  }
1921
1982
  }
@@ -2346,6 +2407,17 @@ class SmarticoAPI {
2346
2407
  });
2347
2408
  return _extends({}, spinAttemptResponse);
2348
2409
  }
2410
+ async getSawWinningHistory(user_ext_id, limit = 20, offset = 0, saw_template_id) {
2411
+ const message = this.buildMessage(user_ext_id, ClassId.GET_SAW_HISTORY_REQUEST, {
2412
+ limit,
2413
+ offset,
2414
+ saw_template_id
2415
+ });
2416
+ return await this.send(message, ClassId.GET_SAW_HISTORY_RESPONSE);
2417
+ }
2418
+ async getSawWinningHistoryT(user_ext_id, limit, offset, saw_template_id) {
2419
+ return SAWHistoryTransform((await this.getSawWinningHistory(user_ext_id, limit, offset, saw_template_id)).prizes);
2420
+ }
2349
2421
  async missionOptIn(user_ext_id, mission_id) {
2350
2422
  if (!mission_id) {
2351
2423
  throw new Error('Missing mission id');
@@ -2625,11 +2697,11 @@ class SmarticoAPI {
2625
2697
  getWSCalls() {
2626
2698
  return new WSAPI(this);
2627
2699
  }
2628
- async getRelatedItemsForGame(user_ext_id, related_game_id) {
2700
+ async getRelatedItemsForGame(user_ext_id, related_game_id, force_language) {
2629
2701
  const message = this.buildMessage(user_ext_id, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_REQUEST, {
2630
2702
  related_game_id: related_game_id
2631
2703
  });
2632
- return await this.send(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE);
2704
+ return await this.send(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE, force_language);
2633
2705
  }
2634
2706
  }
2635
2707
 
@@ -3034,5 +3106,5 @@ var JackpotType;
3034
3106
  JackpotType[JackpotType["Main"] = 1] = "Main";
3035
3107
  })(JackpotType || (JackpotType = {}));
3036
3108
 
3037
- export { AchCategoryTransform, AchievementStatus, AchievementTaskType, AchievementType, ActivityTypeLimited, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GetLevelMapResponseTransform, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, JackpotContributionType, JackpotType, LeaderBoardPeriodType, MiniGamePrizeTypeName, MiniGamePrizeTypeNamed, OCache, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, SAWAcknowledgeType, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWGPMarketType, SAWGameType, SAWGameTypeName, SAWGameTypeNamed, SAWPrizeType, SAWSpinErrorCode, SAWTemplatesTransform, SAWUtils, SAWWinSoundFiles, SAWWinSoundType, ScheduledMissionType, SmarticoAPI, StoreCategoryTransform, StoreItemPurchasedTransform, StoreItemTransform, StoreItemType, StoreItemTypeName, StoreItemTypeNamed, TournamentInstanceStatus, TournamentInstanceStatusName, TournamentItemsTransform, TournamentRegistrationError, TournamentRegistrationStatus, TournamentRegistrationStatusName, TournamentRegistrationStatusNamed, TournamentRegistrationType, TournamentRegistrationTypeGetName, TournamentType, TournamentUtils, TranslationArea, UserAchievementTransform, marketsInfo, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, tournamentInfoItemTransform };
3109
+ export { AchCategoryTransform, AchievementStatus, AchievementTaskType, AchievementType, ActivityTypeLimited, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GetLevelMapResponseTransform, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, JackpotContributionType, JackpotType, LeaderBoardPeriodType, MiniGamePrizeTypeName, MiniGamePrizeTypeNamed, OCache, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, SAWAcknowledgeType, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWGPMarketType, SAWGameType, SAWGameTypeName, SAWGameTypeNamed, SAWHistoryTransform, SAWPrizeType, SAWSpinErrorCode, SAWTemplatesTransform, SAWUtils, SAWWinSoundFiles, SAWWinSoundType, ScheduledMissionType, SmarticoAPI, StoreCategoryTransform, StoreItemPurchasedTransform, StoreItemTransform, StoreItemType, StoreItemTypeName, StoreItemTypeNamed, TournamentInstanceStatus, TournamentInstanceStatusName, TournamentItemsTransform, TournamentRegistrationError, TournamentRegistrationStatus, TournamentRegistrationStatusName, TournamentRegistrationStatusNamed, TournamentRegistrationType, TournamentRegistrationTypeGetName, TournamentType, TournamentUtils, TranslationArea, UserAchievementTransform, marketsInfo, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, tournamentInfoItemTransform };
3038
3110
  //# sourceMappingURL=index.modern.mjs.map