@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.
- package/dist/MiniGames/SAWTemplateUI.d.ts +1 -0
- package/dist/Missions/AchievementTaskPublicMeta.d.ts +1 -0
- package/dist/SmarticoAPI.d.ts +2 -1
- package/dist/SmarticoLib/index.d.ts +1 -0
- package/dist/WSAPI/WSAPI.d.ts +14 -1
- package/dist/WSAPI/WSAPITypes.d.ts +9 -0
- package/dist/index.js +231 -176
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +39 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/interfaces/SAWTemplateUI.md +6 -0
- package/package.json +1 -1
- package/src/MiniGames/SAWTemplateUI.ts +1 -0
- package/src/Missions/AchievementTaskPublicMeta.ts +1 -0
- package/src/Missions/UserAchievement.ts +1 -0
- package/src/SmarticoAPI.ts +30 -0
- package/src/SmarticoLib/index.ts +1 -0
- package/src/WSAPI/WSAPI.ts +18 -0
- package/src/WSAPI/WSAPITypes.ts +11 -0
- package/tsconfig.json +4 -5
package/package.json
CHANGED
|
@@ -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,
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -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,
|
package/src/SmarticoLib/index.ts
CHANGED
|
@@ -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;
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -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.
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -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/
|
|
22
|
-
"src/MiniGames/
|
|
23
|
-
"src/
|
|
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"],
|