@smartico/public-api 0.0.122 → 0.0.124

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.
Files changed (47) hide show
  1. package/dist/Base/ClassId.d.ts +3 -0
  2. package/dist/Core/CheckSegmentMatchRequest.d.ts +4 -0
  3. package/dist/Core/CheckSegmentMatchResponse.d.ts +7 -0
  4. package/dist/Jackpots/GetJackpotsPotsRequest.d.ts +1 -1
  5. package/dist/Jackpots/GetJackpotsPotsResponse.d.ts +1 -1
  6. package/dist/Jackpots/GetJackpotsRequest.d.ts +1 -1
  7. package/dist/Jackpots/JackPotWinner.d.ts +8 -0
  8. package/dist/Jackpots/JackpotWinPush.d.ts +7 -0
  9. package/dist/MiniGames/SAWPrizeDropWinPush.d.ts +2 -0
  10. package/dist/MiniGames/SAWTemplateUI.d.ts +6 -0
  11. package/dist/MiniGames/index.d.ts +1 -0
  12. package/dist/Missions/AchClaimPrizeResponse.d.ts +2 -2
  13. package/dist/Missions/index.d.ts +2 -0
  14. package/dist/SmarticoAPI.d.ts +4 -2
  15. package/dist/WSAPI/WSAPI.d.ts +7 -1
  16. package/dist/WSAPI/WSAPITypes.d.ts +19 -0
  17. package/dist/index.js +260 -188
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.modern.mjs +48 -2
  20. package/dist/index.modern.mjs.map +1 -1
  21. package/docs/README.md +2 -0
  22. package/docs/classes/WSAPI.md +55 -0
  23. package/docs/enums/SAWGameTypeName.md +6 -0
  24. package/docs/interfaces/TMiniGamePrize.md +9 -1
  25. package/docs/interfaces/TMiniGameTemplate.md +1 -1
  26. package/docs/interfaces/TMissionClaimRewardResult.md +19 -0
  27. package/docs/interfaces/TMissionOrBadge.md +32 -0
  28. package/docs/interfaces/TSegmentCheckResult.md +13 -0
  29. package/package.json +1 -1
  30. package/src/Base/ClassId.ts +4 -1
  31. package/src/Core/CheckSegmentMatchRequest.ts +6 -0
  32. package/src/Core/CheckSegmentMatchResponse.ts +8 -0
  33. package/src/Jackpots/GetJackpotsPotsRequest.ts +1 -1
  34. package/src/Jackpots/GetJackpotsPotsResponse.ts +1 -1
  35. package/src/Jackpots/GetJackpotsRequest.ts +1 -1
  36. package/src/Jackpots/JackPotWinner.ts +10 -0
  37. package/src/Jackpots/JackpotWinPush.ts +8 -0
  38. package/src/MiniGames/SAWPrizeDropWinPush.ts +2 -0
  39. package/src/MiniGames/SAWTemplateUI.ts +10 -0
  40. package/src/MiniGames/index.ts +2 -1
  41. package/src/Missions/AchClaimPrizeResponse.ts +2 -3
  42. package/src/Missions/UserAchievement.ts +3 -0
  43. package/src/Missions/index.ts +3 -1
  44. package/src/SmarticoAPI.ts +32 -2
  45. package/src/WSAPI/WSAPI.ts +30 -1
  46. package/src/WSAPI/WSAPITypes.ts +24 -0
  47. package/src/Jackpots/jackpotsWSApi.zip +0 -0
@@ -28,6 +28,8 @@ var ClassId;
28
28
  ClassId[ClassId["CLIENT_SET_AVATAR_RESPONSE"] = 158] = "CLIENT_SET_AVATAR_RESPONSE";
29
29
  ClassId[ClassId["CLIENT_SET_CUSTOM_USERNAME_REQUEST"] = 159] = "CLIENT_SET_CUSTOM_USERNAME_REQUEST";
30
30
  ClassId[ClassId["CLIENT_SET_CUSTOM_USERNAME_RESPONSE"] = 160] = "CLIENT_SET_CUSTOM_USERNAME_RESPONSE";
31
+ ClassId[ClassId["CHECK_SEGMENT_MATCH_REQUEST"] = 161] = "CHECK_SEGMENT_MATCH_REQUEST";
32
+ ClassId[ClassId["CHECK_SEGMENT_MATCH_RESPONSE"] = 162] = "CHECK_SEGMENT_MATCH_RESPONSE";
31
33
  // 500-1000 - Achievements
32
34
  ClassId[ClassId["GET_LEVEL_MAP_REQUEST"] = 500] = "GET_LEVEL_MAP_REQUEST";
33
35
  ClassId[ClassId["GET_LEVEL_MAP_RESPONSE"] = 501] = "GET_LEVEL_MAP_RESPONSE";
@@ -93,7 +95,7 @@ var ClassId;
93
95
  ClassId[ClassId["JP_OPTIN_RESPONSE"] = 805] = "JP_OPTIN_RESPONSE";
94
96
  ClassId[ClassId["JP_OPTOUT_REQUEST"] = 806] = "JP_OPTOUT_REQUEST";
95
97
  ClassId[ClassId["JP_OPTOUT_RESPONSE"] = 807] = "JP_OPTOUT_RESPONSE";
96
- // JP_WIN_PUSH = 808,
98
+ ClassId[ClassId["JP_WIN_PUSH"] = 808] = "JP_WIN_PUSH";
97
99
  ClassId[ClassId["REGISTER_PUSH_NOTIFICATIONS_TOKEN_REQ"] = 1003] = "REGISTER_PUSH_NOTIFICATIONS_TOKEN_REQ";
98
100
  ClassId[ClassId["REGISTER_PUSH_NOTIFICATIONS_TOKEN_RESP"] = 2003] = "REGISTER_PUSH_NOTIFICATIONS_TOKEN_RESP";
99
101
  ClassId[ClassId["CLIENT_DEBUG_REQUEST"] = 77777] = "CLIENT_DEBUG_REQUEST";
@@ -678,7 +680,10 @@ const UserAchievementTransform = items => {
678
680
  game_provider: g.game_public_meta.game_provider
679
681
  }
680
682
  })),
681
- category_ids: (_r$ach_categories = r.ach_categories) != null ? _r$ach_categories : []
683
+ category_ids: (_r$ach_categories = r.ach_categories) != null ? _r$ach_categories : [],
684
+ ach_completed_id: r.ach_completed_id,
685
+ requires_prize_claim: r.requires_prize_claim,
686
+ prize_claimed_date_ts: r.prize_claimed_date_ts
682
687
  };
683
688
  return x;
684
689
  });
@@ -984,6 +989,7 @@ var onUpdateContextKey;
984
989
  onUpdateContextKey["AchCategories"] = "achCategories";
985
990
  onUpdateContextKey["LeaderBoards"] = "leaderBoards";
986
991
  onUpdateContextKey["LevelExtraCounters"] = "levelExtraCounters";
992
+ onUpdateContextKey["Segments"] = "segments";
987
993
  })(onUpdateContextKey || (onUpdateContextKey = {}));
988
994
  /** @group General API */
989
995
  class WSAPI {
@@ -1012,6 +1018,19 @@ class WSAPI {
1012
1018
  throw new Error('Tracker is not initialized, cannot getUserProfile');
1013
1019
  }
1014
1020
  }
1021
+ /** Check if user belongs to specific segments */
1022
+ async checkSegmentMatch(segment_id) {
1023
+ const r = await this.api.coreCheckSegments(null, [segment_id]);
1024
+ if (r && r.find(s => s.segment_id === segment_id && s.is_matching)) {
1025
+ return true;
1026
+ } else {
1027
+ return false;
1028
+ }
1029
+ }
1030
+ /** Check if user belongs to specific list of segments */
1031
+ async checkSegmentListMatch(segment_ids) {
1032
+ return await this.api.coreCheckSegments(null, segment_ids);
1033
+ }
1015
1034
  /** Returns all the levels available the current user */
1016
1035
  async getLevels() {
1017
1036
  return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
@@ -1094,6 +1113,15 @@ class WSAPI {
1094
1113
  };
1095
1114
  return o;
1096
1115
  }
1116
+ /** Request for claim reward for the specified mission id. Returns the err_code. */
1117
+ async requestMissionClaimReward(mission_id, ach_completed_id) {
1118
+ const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id);
1119
+ const o = {
1120
+ err_code: r.errCode,
1121
+ err_message: r.errMsg
1122
+ };
1123
+ return o;
1124
+ }
1097
1125
  /** Returns all the active instances of tournaments
1098
1126
  * The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
1099
1127
  * The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
@@ -1474,6 +1502,13 @@ class SmarticoAPI {
1474
1502
  });
1475
1503
  return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
1476
1504
  }
1505
+ async coreCheckSegments(user_ext_id, segment_id) {
1506
+ const message = this.buildMessage(user_ext_id, ClassId.CHECK_SEGMENT_MATCH_REQUEST, {
1507
+ segment_id
1508
+ });
1509
+ const results = await this.send(message, ClassId.CHECK_SEGMENT_MATCH_RESPONSE);
1510
+ return results.segments || [];
1511
+ }
1477
1512
  async sawGetTemplates(user_ext_id, lang, is_visitor_mode = false) {
1478
1513
  const message = this.buildMessage(user_ext_id, ClassId.SAW_GET_SPINS_REQUEST, lang ? {
1479
1514
  force_language: lang,
@@ -1546,6 +1581,17 @@ class SmarticoAPI {
1546
1581
  const res = await this.send(message, ClassId.MISSION_OPTIN_RESPONSE);
1547
1582
  return res;
1548
1583
  }
1584
+ async missionClaimPrize(user_ext_id, mission_id, ach_completed_id) {
1585
+ if (!mission_id) {
1586
+ throw new Error('Missing mission id');
1587
+ }
1588
+ const message = this.buildMessage(user_ext_id, ClassId.ACHIEVEMENT_CLAIM_PRIZE_REQUEST, {
1589
+ ach_id: mission_id,
1590
+ ach_completed_id: ach_completed_id
1591
+ });
1592
+ const res = await this.send(message, ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE);
1593
+ return res;
1594
+ }
1549
1595
  async registerInTournament(user_ext_id, tournamentInstanceId) {
1550
1596
  if (!tournamentInstanceId) {
1551
1597
  throw new Error('Missing tournament instance id');