@smartico/public-api 0.0.280 → 0.0.282

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.
@@ -188,6 +188,12 @@ ___
188
188
 
189
189
  ___
190
190
 
191
+ ### prize\_pool\_image
192
+
193
+ • `Optional` **prize\_pool\_image**: `string`
194
+
195
+ ___
196
+
191
197
  ### ask\_for\_username
192
198
 
193
199
  • `Optional` **ask\_for\_username**: [`SAWAskForUsername`](../enums/SAWAskForUsername.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.280",
3
+ "version": "0.0.282",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,7 @@ export interface SAWTemplateUI {
35
35
  matchx_is_completed?: boolean;
36
36
  matchx_general_board_users_count?: number;
37
37
  matchx_hide_ranking?: boolean;
38
+ prize_pool_image?: string;
38
39
  ask_for_username?: SAWAskForUsername;
39
40
  show_prize_board?: boolean;
40
41
 
@@ -1,4 +1,5 @@
1
1
  export interface AchievementTaskPublicMeta {
2
2
  name?: string;
3
3
  display_progress_as_count?: boolean;
4
+ stage_image?: string;
4
5
  }
@@ -92,6 +92,7 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
92
92
  execution_count_expected: t.executionCount,
93
93
  execution_count_actual: t.userExecutedCount,
94
94
  display_progress_as_count: t.task_public_meta.display_progress_as_count,
95
+ stage_image: t.task_public_meta.stage_image,
95
96
  })),
96
97
  related_games: (r.related_games || []).map((g) => ({
97
98
  ext_game_id: g.ext_game_id,
@@ -94,6 +94,7 @@ import {
94
94
  TUICustomSection,
95
95
  TBonus,
96
96
  TRaffle,
97
+ TLevelCurrent,
97
98
  } from './WSAPI/WSAPITypes';
98
99
  import { getLeaderBoardTransform } from './Leaderboard/LeaderBoards';
99
100
  import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
@@ -1028,6 +1029,35 @@ class SmarticoAPI {
1028
1029
  return GetLevelMapResponseTransform(await this.levelsGet(user_ext_id));
1029
1030
  }
1030
1031
 
1032
+ public async getLevelCurrent(user_ext_id: string): Promise<TLevelCurrent> {
1033
+ const levels = await this.levelsGetT(user_ext_id);
1034
+ const userInfo = await this.getUserGamificationInfo(user_ext_id);
1035
+ if (!levels || levels.length === 0) return null;
1036
+
1037
+ const userPoints = userInfo.points_balance;
1038
+
1039
+ const sortedLevels = levels.sort((a, b) => a.required_points - b.required_points);
1040
+
1041
+ let currentLevelIndex = sortedLevels.findIndex((level, index) => {
1042
+ const nextLevel = sortedLevels[index + 1];
1043
+ return userPoints >= level.required_points && (!nextLevel || userPoints < nextLevel.required_points);
1044
+ });
1045
+
1046
+ if (currentLevelIndex === -1) {
1047
+ currentLevelIndex = sortedLevels.length - 1;
1048
+ }
1049
+
1050
+ const currentLevel = sortedLevels[currentLevelIndex];
1051
+ const nextLevel = sortedLevels[currentLevelIndex + 1];
1052
+ const progress = nextLevel ? ((userPoints - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points)) * 100 : 100;
1053
+
1054
+ return {
1055
+ ...currentLevel,
1056
+ ordinal_position: currentLevelIndex + 1,
1057
+ progress: Math.min(Math.max(progress, 0), 100)
1058
+ };
1059
+ }
1060
+
1031
1061
  public async customSectionsGet(user_ext_id: string, force_language?: string): Promise<GetCustomSectionsResponse> {
1032
1062
  const message = this.buildMessage<GetCustomSectionsRequest, GetCustomSectionsResponse>(
1033
1063
  user_ext_id,
@@ -414,6 +414,7 @@ export interface SAWTemplateUI {
414
414
  matchx_is_completed?: boolean;
415
415
  matchx_general_board_users_count?: number;
416
416
  matchx_hide_ranking?: boolean;
417
+ prize_pool_image?: string;
417
418
  ask_for_username?: SAWAskForUsername;
418
419
  show_prize_board?: boolean;
419
420
  max_spins_period_ms?: number;
@@ -36,6 +36,7 @@ import {
36
36
  TRaffleDraw,
37
37
  TRaffleDrawRun,
38
38
  TransformedRaffleClaimPrizeResponse,
39
+ TLevelCurrent
39
40
  } from './WSAPITypes';
40
41
  import { LeaderBoardPeriodType } from '../Leaderboard';
41
42
  import {
@@ -88,6 +89,7 @@ enum onUpdateContextKey {
88
89
  JackpotWinners = 'jackpotWinners',
89
90
  Raffles = 'raffles',
90
91
  JackpotEligibleGames = 'jackpotEligibleGames',
92
+ CurrentLevel = 'currentLevel',
91
93
  }
92
94
 
93
95
  /** @group General API */
@@ -211,6 +213,22 @@ export class WSAPI {
211
213
  return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
212
214
  }
213
215
 
216
+ /**
217
+ * Returns the current level of the user with extended information including ordinal position and progress.
218
+ *
219
+ * **Example**:
220
+ * ```
221
+ * _smartico.api.getCurrentLevel().then((result) => {
222
+ * console.log(result);
223
+ * });
224
+ * ```
225
+ *
226
+ * **Visitor mode: not supported**
227
+ */
228
+ public async getCurrentLevel(): Promise<TLevelCurrent> {
229
+ return OCache.use(onUpdateContextKey.CurrentLevel, ECacheContext.WSAPI, () => this.api.getLevelCurrent(null), CACHE_DATA_SEC);
230
+ }
231
+
214
232
  /** Returns all the missions available the current user.
215
233
  * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
216
234
  * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
@@ -260,6 +260,17 @@ export interface TLevel {
260
260
  custom_data: string;
261
261
  }
262
262
 
263
+ /**
264
+ * TLevelCurrent describes the information of each level defined in the system along with ordinal position and progress of the current level
265
+ */
266
+
267
+ export interface TLevelCurrent extends TLevel {
268
+ /** The ordinal position of the level */
269
+ ordinal_position: number;
270
+ /** The progress of the level */
271
+ progress: number;
272
+ }
273
+
263
274
  /**
264
275
  * TTournament describes the general information of the tournament item
265
276
  */
package/tsconfig.json CHANGED
@@ -18,17 +18,16 @@
18
18
  "src/WSAPI/WSAPITypes.ts",
19
19
  "src/Tournaments/TournamentRegistrationStatus.ts",
20
20
  "src/Tournaments/TournamentRegistrationType.ts",
21
- "src/MiniGames/SAWBuyInType.ts",
22
- "src/MiniGames/SAWGameType.ts",
23
- "src/MiniGames/SAWPrizeType.ts",
24
- "src/MiniGames/SAWSpinErrorCode.ts",
21
+ "src/Bonuses/BonusStatus.ts",
22
+ "src/MiniGames/index.ts",
23
+ "src/CustomSections/AchCustomSection.ts",
25
24
  "src/Tournaments/TournamentRegistrationError.ts",
26
25
  "src/Store/BuyStoreItemErrorCode.ts",
27
26
  "src/Leaderboard/LeaderBoardPeriodType.ts",
28
27
  "src/Base/AchRelatedGame.ts",
29
28
  "src/Jackpots/index.ts",
30
29
  "src/Raffle/index.ts",
31
- "src/Missions/AchievementAvailabilityStatus.ts"
30
+ "src/Missions/AchievementAvailabilityStatus.ts",
32
31
  ],
33
32
  "out": "docs",
34
33
  "plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],