@smartico/public-api 0.0.379 → 0.0.380

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 (99) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +31 -2
  3. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  4. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  5. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  6. package/dist/WSAPI/WSAPIAvatars.d.ts +78 -0
  7. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  8. package/dist/WSAPI/WSAPIBonuses.d.ts +26 -0
  9. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  10. package/dist/WSAPI/WSAPIGamePick.d.ts +308 -0
  11. package/dist/WSAPI/WSAPIGeneral.d.ts +30 -0
  12. package/dist/WSAPI/WSAPIInbox.d.ts +126 -0
  13. package/dist/WSAPI/WSAPIJackpots.d.ts +109 -0
  14. package/dist/WSAPI/WSAPILeaderBoard.d.ts +25 -0
  15. package/dist/WSAPI/WSAPIMiniGames.d.ts +94 -0
  16. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  17. package/dist/WSAPI/WSAPIRaffles.d.ts +119 -0
  18. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  19. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  20. package/dist/WSAPI/WSAPITypes.d.ts +145 -85
  21. package/dist/WSAPI/WSAPIUser.d.ts +383 -0
  22. package/dist/index.js +3818 -1528
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.modern.mjs +3180 -981
  25. package/dist/index.modern.mjs.map +1 -1
  26. package/docs/api/README.md +56 -2
  27. package/docs/api/classes/WSAPIAvatars.md +116 -0
  28. package/docs/api/classes/WSAPIBonuses.md +50 -0
  29. package/docs/api/classes/WSAPIClans.md +66 -0
  30. package/docs/api/classes/WSAPIGamePick.md +181 -0
  31. package/docs/api/classes/WSAPIGeneral.md +63 -0
  32. package/docs/api/classes/WSAPIInbox.md +277 -0
  33. package/docs/api/classes/WSAPIJackpots.md +185 -0
  34. package/docs/api/classes/WSAPILeaderBoard.md +39 -0
  35. package/docs/api/classes/WSAPIMiniGames.md +175 -0
  36. package/docs/api/classes/WSAPIMissions.md +611 -0
  37. package/docs/api/classes/WSAPIRaffles.md +195 -0
  38. package/docs/api/classes/WSAPIStore.md +744 -0
  39. package/docs/api/classes/WSAPITournaments.md +104 -0
  40. package/docs/api/classes/WSAPIUser.md +200 -0
  41. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  42. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  43. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  44. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  45. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  46. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  47. package/docs/api/interfaces/TAchCategory.md +19 -4
  48. package/docs/api/interfaces/TBuyStoreItemResult.md +26 -8
  49. package/docs/api/interfaces/TMissionClaimRewardResult.md +14 -3
  50. package/docs/api/interfaces/TMissionOptInResult.md +10 -3
  51. package/docs/api/interfaces/TMissionOrBadge.md +6 -2
  52. package/docs/api/interfaces/TStoreItem.md +21 -1
  53. package/docs/api/interfaces/TTournamentDetailed.md +8 -0
  54. package/docs/api/interfaces/UserAchievement.md +1 -1
  55. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  56. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  57. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  58. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  59. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  60. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  61. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  62. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  63. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  64. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  65. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  66. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  67. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  68. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  69. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  70. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  71. package/docs/ui/user/UIGuide_getLevels.md +162 -0
  72. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  73. package/package.json +3 -3
  74. package/scripts/postdoc-cleanup.js +195 -0
  75. package/src/Missions/MissionsUtils.ts +5 -2
  76. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  77. package/src/Store/StoreItem.ts +1 -0
  78. package/src/Store/StoreItemPurchased.ts +1 -0
  79. package/src/Store/StoreItemType.ts +1 -1
  80. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  81. package/src/WSAPI/WSAPI.ts +27 -2007
  82. package/src/WSAPI/WSAPIAvatars.ts +127 -0
  83. package/src/WSAPI/WSAPIBase.ts +93 -0
  84. package/src/WSAPI/WSAPIBonuses.ts +54 -0
  85. package/src/WSAPI/WSAPIClans.ts +417 -0
  86. package/src/WSAPI/WSAPIGamePick.ts +382 -0
  87. package/src/WSAPI/WSAPIGeneral.ts +57 -0
  88. package/src/WSAPI/WSAPIInbox.ts +222 -0
  89. package/src/WSAPI/WSAPIJackpots.ts +212 -0
  90. package/src/WSAPI/WSAPILeaderBoard.ts +40 -0
  91. package/src/WSAPI/WSAPIMiniGames.ts +181 -0
  92. package/src/WSAPI/WSAPIMissions.ts +572 -0
  93. package/src/WSAPI/WSAPIRaffles.ts +175 -0
  94. package/src/WSAPI/WSAPIStore.ts +732 -0
  95. package/src/WSAPI/WSAPITournaments.ts +541 -0
  96. package/src/WSAPI/WSAPITypes.ts +145 -87
  97. package/src/WSAPI/WSAPIUser.ts +456 -0
  98. package/tsconfig.json +17 -1
  99. package/docs/api/classes/WSAPI.md +0 -1927
@@ -0,0 +1,382 @@
1
+ import {
2
+ GamesApiResponse,
3
+ GamePickRound,
4
+ GamePickRoundBoard,
5
+ GamePickUserInfo,
6
+ GamePickGameInfo,
7
+ GamePickRequestParams,
8
+ GamePickRoundRequestParams,
9
+ } from './WSAPITypes';
10
+ import { WSAPIAvatars } from './WSAPIAvatars';
11
+
12
+ /** @group GamePick */
13
+ export class WSAPIGamePick extends WSAPIAvatars {
14
+ /**
15
+ * Returns the active rounds for the specified MatchX or Quiz game.
16
+ * Each round includes its events (matches/questions) along with the current user's selections and scores.
17
+ *
18
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
19
+ *
20
+ * **Response** `GamesApiResponse<GamePickRound[]>`:
21
+ * - `errCode` - 0 on success
22
+ * - `data` - Array of rounds, each containing:
23
+ * - `round_id`, `round_name` - Round identifier and display name
24
+ * - `open_date`, `last_bet_date` - Timestamps (ms) for round open and betting deadline
25
+ * - `is_active_now`, `is_resolved` - Round state flags
26
+ * - `round_status_id` - Round status: -1 (active), 2 (no more bets), 3 (all events resolved), 4 (round resolved)
27
+ * - `score_full_win`, `score_part_win`, `score_lost` - Scoring rules per prediction outcome
28
+ * - `user_score` - Current user's total score in this round
29
+ * - `user_placed_bet` - Whether the user has submitted predictions
30
+ * - `has_open_for_bet_events` - Whether there are events still open for betting
31
+ * - `events[]` - Array of events with `gp_event_id`, `market_type_id`, `event_meta` (team names, images, sport), `match_date`, `is_open_for_bets`, `odds_details`, and user selection fields
32
+ *
33
+ * **Example**:
34
+ * ```
35
+ * _smartico.api.gamePickGetActiveRounds({
36
+ * saw_template_id: 1083,
37
+ * }).then((result) => {
38
+ * console.log(result.data); // GamePickRound[]
39
+ * result.data.forEach(round => {
40
+ * console.log(round.round_name, round.events.length);
41
+ * });
42
+ * });
43
+ * ```
44
+ *
45
+ * **Visitor mode: not supported**
46
+ */
47
+ public async gamePickGetActiveRounds(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>> {
48
+ if (!props.saw_template_id) {
49
+ throw new Error('saw_template_id is required');
50
+ }
51
+ return this.api.gpGetActiveRounds(props.saw_template_id);
52
+ }
53
+
54
+ /**
55
+ * Returns a single active round for the specified MatchX or Quiz game.
56
+ * The round includes full event details with the current user's selections.
57
+ *
58
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
59
+ * @param props.round_id - The specific round to retrieve
60
+ *
61
+ * **Response** `GamesApiResponse<GamePickRound>`:
62
+ * - `errCode` - 0 on success
63
+ * - `data` - Single round object with the same structure as in `gamePickGetActiveRounds`,
64
+ * including `events[]` with full event details, user selections, and resolution info
65
+ *
66
+ * **Example**:
67
+ * ```
68
+ * _smartico.api.gamePickGetActiveRound({
69
+ * saw_template_id: 1083,
70
+ * round_id: 31652,
71
+ * }).then((result) => {
72
+ * console.log(result.data.round_name, result.data.events.length);
73
+ * console.log(result.data.user_score, result.data.user_placed_bet);
74
+ * });
75
+ * ```
76
+ *
77
+ * **Visitor mode: not supported**
78
+ */
79
+ public async gamePickGetActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>> {
80
+ if (!props.saw_template_id) {
81
+ throw new Error('saw_template_id is required');
82
+ }
83
+ if (!props.round_id) {
84
+ throw new Error('round_id is required');
85
+ }
86
+ return this.api.gpGetActiveRound(props.saw_template_id, props.round_id);
87
+ }
88
+
89
+ /**
90
+ * Returns the history of all rounds (including resolved ones) for the specified MatchX or Quiz game.
91
+ * Each round contains full event details with results and the current user's predictions.
92
+ *
93
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
94
+ *
95
+ * **Response** `GamesApiResponse<GamePickRound[]>`:
96
+ * - `errCode` - 0 on success
97
+ * - `data` - Array of rounds ordered by `round_row_id` descending (newest first).
98
+ * Each round has the same structure as in `gamePickGetActiveRounds`, including resolved events
99
+ * with `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) and `resolution_score`
100
+ *
101
+ * **Example**:
102
+ * ```
103
+ * _smartico.api.gamePickGetHistory({
104
+ * saw_template_id: 1083,
105
+ * }).then((result) => {
106
+ * result.data.forEach(round => {
107
+ * console.log(round.round_name, 'Score:', round.user_score, 'Resolved:', round.is_resolved);
108
+ * });
109
+ * });
110
+ * ```
111
+ *
112
+ * **Visitor mode: not supported**
113
+ */
114
+ public async gamePickGetHistory(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>> {
115
+ if (!props.saw_template_id) {
116
+ throw new Error('saw_template_id is required');
117
+ }
118
+ return this.api.gpGetGamesHistory(props.saw_template_id);
119
+ }
120
+
121
+ /**
122
+ * Returns the leaderboard for a specific round within a MatchX or Quiz game.
123
+ * Use `round_id = -1` (AllRoundsGameBoardID) to get the season/overall leaderboard across all rounds.
124
+ *
125
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
126
+ * @param props.round_id - The round to get the leaderboard for. Use -1 for overall/seasonal leaderboard
127
+ *
128
+ * **Response** `GamesApiResponse<GamePickRoundBoard>`:
129
+ * - `errCode` - 0 on success
130
+ * - `data` - Leaderboard object containing:
131
+ * - Round base fields (`round_id`, `round_name`, `open_date`, `last_bet_date`, etc.)
132
+ * - `users[]` - Ranked list of players, each with:
133
+ * - `ext_user_id`, `int_user_id` - User identifiers
134
+ * - `public_username`, `avatar_url` - Display info (usernames may be masked based on label settings)
135
+ * - `gp_position` - Leaderboard rank (null if not yet ranked)
136
+ * - `resolution_score` - Total score in this round
137
+ * - `full_wins_count`, `part_wins_count`, `lost_count` - Prediction outcome counts
138
+ * - `my_user` - Current user's entry (same fields as above), or null if user hasn't participated
139
+ *
140
+ * **Example**:
141
+ * ```
142
+ * _smartico.api.gamePickGetBoard({
143
+ * saw_template_id: 1083,
144
+ * round_id: 31652,
145
+ * }).then((result) => {
146
+ * console.log('Top players:', result.data.users);
147
+ * console.log('My position:', result.data.my_user?.gp_position);
148
+ * });
149
+ * ```
150
+ *
151
+ * **Visitor mode: not supported**
152
+ */
153
+ public async gamePickGetBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>> {
154
+ if (!props.saw_template_id) {
155
+ throw new Error('saw_template_id is required');
156
+ }
157
+ if (!props.round_id) {
158
+ throw new Error('round_id is required');
159
+ }
160
+ return this.api.gpGetGameBoard(props.saw_template_id, props.round_id);
161
+ }
162
+
163
+ /**
164
+ * Submits score predictions for a round in a MatchX game.
165
+ * Sends the round object with user selections for all events at once.
166
+ * Each event must include `team1_user_selection` and `team2_user_selection` representing predicted scores.
167
+ * If the user hasn't placed bets before, one game attempt (spin) will be consumed.
168
+ * Predictions can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
169
+ *
170
+ * @param props.saw_template_id - The ID of the MatchX game template
171
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `gamePickGetActiveRound`
172
+ * and modified with user predictions. Each event needs: `gp_event_id`, `team1_user_selection`, `team2_user_selection`
173
+ *
174
+ * **Response** `GamesApiResponse<GamePickRound>`:
175
+ * - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
176
+ * - `data` - Updated round with all events reflecting the submitted selections.
177
+ * `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
178
+ *
179
+ * **Example**:
180
+ * ```
181
+ * _smartico.api.gamePickGetActiveRound({
182
+ * saw_template_id: 1190,
183
+ * round_id: 38665,
184
+ * }).then((roundData) => {
185
+ * const round = roundData.data;
186
+ * round.events = round.events.map(e => ({
187
+ * gp_event_id: e.gp_event_id,
188
+ * team1_user_selection: 1,
189
+ * team2_user_selection: 0,
190
+ * }));
191
+ * _smartico.api.gamePickSubmitSelection({
192
+ * saw_template_id: 1190,
193
+ * round: round,
194
+ * }).then((result) => {
195
+ * console.log(result.data.user_placed_bet); // true
196
+ * });
197
+ * });
198
+ * ```
199
+ *
200
+ * **Visitor mode: not supported**
201
+ */
202
+ public async gamePickSubmitSelection(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
203
+ if (!props.saw_template_id) {
204
+ throw new Error('saw_template_id is required');
205
+ }
206
+ if (!props.round?.round_id) {
207
+ throw new Error('round is required');
208
+ }
209
+ return this.api.gpSubmitSelection(props.saw_template_id, props.round, false);
210
+ }
211
+
212
+ /**
213
+ * Submits answers for a round in a Quiz game.
214
+ * Sends the round object with user answers for all events at once.
215
+ * Each event must include `user_selection` with the answer value (e.g. '1', '2', 'x', 'yes', 'no' — depending on the market type).
216
+ * If the user hasn't placed bets before, one game attempt (spin) will be consumed.
217
+ * Answers can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
218
+ *
219
+ * @param props.saw_template_id - The ID of the Quiz game template
220
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `gamePickGetActiveRound`
221
+ * and modified with user answers. Each event needs: `gp_event_id`, `user_selection`
222
+ *
223
+ * **Response** `GamesApiResponse<GamePickRound>`:
224
+ * - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
225
+ * - `data` - Updated round with all events reflecting the submitted answers.
226
+ * `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
227
+ *
228
+ * **Example**:
229
+ * ```
230
+ * _smartico.api.gamePickGetActiveRound({
231
+ * saw_template_id: 1183,
232
+ * round_id: 37974,
233
+ * }).then((roundData) => {
234
+ * const round = roundData.data;
235
+ * round.events = round.events.map(e => ({
236
+ * gp_event_id: e.gp_event_id,
237
+ * user_selection: 'x',
238
+ * }));
239
+ * _smartico.api.gamePickSubmitSelectionQuiz({
240
+ * saw_template_id: 1183,
241
+ * round: round,
242
+ * }).then((result) => {
243
+ * console.log(result.data.user_placed_bet); // true
244
+ * });
245
+ * });
246
+ * ```
247
+ *
248
+ * **Visitor mode: not supported**
249
+ */
250
+ public async gamePickSubmitSelectionQuiz(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
251
+ if (!props.saw_template_id) {
252
+ throw new Error('saw_template_id is required');
253
+ }
254
+ if (!props.round?.round_id) {
255
+ throw new Error('round is required');
256
+ }
257
+ return this.api.gpSubmitSelection(props.saw_template_id, props.round, true);
258
+ }
259
+
260
+ /**
261
+ * Returns the current user's profile information within the specified MatchX or Quiz game.
262
+ * The user record is synced from the Smartico platform into the games DB (synced every 1 minute).
263
+ * If the user doesn't exist in the games DB yet, it will be created automatically on first call.
264
+ *
265
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
266
+ *
267
+ * **Response** `GamesApiResponse<GamePickUserInfo>`:
268
+ * - `errCode` - 0 on success
269
+ * - `data`:
270
+ * - `ext_user_id` - External user ID (Smartico internal numeric ID)
271
+ * - `int_user_id` - Internal user ID within the games system
272
+ * - `public_username` - Display name
273
+ * - `avatar_url` - User's avatar image URL
274
+ * - `last_wallet_sync_time` - Last time the user's balance was synced from Smartico
275
+ * - `ach_points_balance` - User's current points balance
276
+ * - `ach_gems_balance` - User's current gems balance
277
+ * - `ach_diamonds_balance` - User's current diamonds balance
278
+ * - `pubic_username_set` - Whether the user has set a custom username
279
+ *
280
+ * **Example**:
281
+ * ```
282
+ * _smartico.api.gamePickGetUserInfo({
283
+ * saw_template_id: 1083,
284
+ * }).then((result) => {
285
+ * console.log(result.data.public_username, result.data.ach_points_balance);
286
+ * });
287
+ * ```
288
+ *
289
+ * **Visitor mode: not supported**
290
+ */
291
+ public async gamePickGetUserInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickUserInfo>> {
292
+ if (!props.saw_template_id) {
293
+ throw new Error('saw_template_id is required');
294
+ }
295
+ return this.api.gpGetUserInfo(props.saw_template_id);
296
+ }
297
+
298
+ /**
299
+ * Returns the game configuration and the list of all rounds for the specified MatchX or Quiz game.
300
+ * Includes the SAW template definition, label settings, and round metadata (without events).
301
+ *
302
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
303
+ *
304
+ * **Response** `GamesApiResponse<GamePickGameInfo>`:
305
+ * - `errCode` - 0 on success
306
+ * - `data`:
307
+ * - `sawTemplate` - Game template configuration including:
308
+ * - `saw_template_id`, `saw_game_type_id` (6 = MatchX/Quiz)
309
+ * - `saw_template_ui_definition` - UI settings (name, ranking options, ask_for_username, etc.)
310
+ * - `saw_buyin_type_id` - Cost type (1=Free, 2=Points, 3=Gems, 4=Diamonds, 5=Spins)
311
+ * - `buyin_cost_points` - Cost per attempt
312
+ * - `spin_count` - Available attempts for the current user
313
+ * - `allRounds[]` - List of all rounds (metadata only, no events), each with:
314
+ * - `round_id`, `round_name`, `round_description`
315
+ * - `open_date`, `last_bet_date` - Timestamps (ms)
316
+ * - `is_active_now`, `is_resolved`, `round_status_id`
317
+ * - `labelInfo` - Label/brand configuration and settings
318
+ *
319
+ * **Example**:
320
+ * ```
321
+ * _smartico.api.gamePickGetGameInfo({
322
+ * saw_template_id: 1189,
323
+ * }).then((result) => {
324
+ * console.log(result.data.sawTemplate.saw_template_ui_definition.name);
325
+ * console.log('Rounds:', result.data.allRounds.length);
326
+ * console.log('Buy-in type:', result.data.sawTemplate.saw_buyin_type_id);
327
+ * });
328
+ * ```
329
+ *
330
+ * **Visitor mode: not supported**
331
+ */
332
+ public async gamePickGetGameInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickGameInfo>> {
333
+ if (!props.saw_template_id) {
334
+ throw new Error('saw_template_id is required');
335
+ }
336
+ return this.api.gpGetGameInfo(props.saw_template_id);
337
+ }
338
+
339
+ /**
340
+ * Returns round data with events and picks for a specific user (identified by their internal user ID).
341
+ * Useful for viewing another user's predictions from the leaderboard.
342
+ * The `int_user_id` can be obtained from the `gamePickGetBoard` response (`users[].int_user_id`).
343
+ *
344
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
345
+ * @param props.round_id - The round to get info for
346
+ * @param props.int_user_id - Internal user ID of the player whose predictions to view (from leaderboard data)
347
+ *
348
+ * **Response** `GamesApiResponse<GamePickRound>`:
349
+ * - `errCode` - 0 on success
350
+ * - `data` - Round object with the target user's selections.
351
+ * Same structure as `gamePickGetActiveRound`, but `user_selection`/`team1_user_selection`/`team2_user_selection`
352
+ * fields on events reflect the specified user's picks instead of the current user's.
353
+ * Events also include `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) showing how each prediction was scored
354
+ *
355
+ * **Example**:
356
+ * ```
357
+ * _smartico.api.gamePickGetRoundInfoForUser({
358
+ * saw_template_id: 1083,
359
+ * round_id: 31652,
360
+ * int_user_id: 65653810,
361
+ * }).then((result) => {
362
+ * result.data.events.forEach(e => {
363
+ * console.log(e.event_meta.team1_name, 'vs', e.event_meta.team2_name, '→', e.user_selection);
364
+ * });
365
+ * });
366
+ * ```
367
+ *
368
+ * **Visitor mode: not supported**
369
+ */
370
+ public async gamePickGetRoundInfoForUser(props: GamePickRoundRequestParams & { int_user_id: number }): Promise<GamesApiResponse<GamePickRound>> {
371
+ if (!props.saw_template_id) {
372
+ throw new Error('saw_template_id is required');
373
+ }
374
+ if (!props.round_id) {
375
+ throw new Error('round_id is required');
376
+ }
377
+ if (!props.int_user_id) {
378
+ throw new Error('int_user_id is required');
379
+ }
380
+ return this.api.gpGetRoundInfoForUser(props.saw_template_id, props.round_id, props.int_user_id);
381
+ }
382
+ }
@@ -0,0 +1,57 @@
1
+ import { ECacheContext, OCache } from '../OCache';
2
+ import {
3
+ TGetTranslations,
4
+ TUICustomSection,
5
+ } from './WSAPITypes';
6
+ import { GetRelatedAchTourResponse } from '../Missions/GetRelatedAchTourResponse';
7
+ import {
8
+ CACHE_DATA_SEC,
9
+ onUpdateContextKey,
10
+ } from './WSAPIBase';
11
+ import { WSAPIUser } from './WSAPIUser';
12
+
13
+ /** @group General */
14
+ export class WSAPIGeneral extends WSAPIUser {
15
+ public async getCustomSections(): Promise<TUICustomSection[]> {
16
+ return OCache.use(
17
+ onUpdateContextKey.CustomSections,
18
+ ECacheContext.WSAPI,
19
+ () => this.api.customSectionsGetT(this.userExtId),
20
+ CACHE_DATA_SEC,
21
+ );
22
+ }
23
+
24
+ /**
25
+ * Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
26
+ */
27
+ public async getTranslations(lang_code: string): Promise<TGetTranslations> {
28
+ const r = await this.api.getTranslationsT(this.userExtId, lang_code, []);
29
+
30
+ return {
31
+ translations: r.translations,
32
+ };
33
+ }
34
+
35
+ /**
36
+ * Returns all the related tournaments and missions for the provided game id for the current user
37
+ * The provided Game ID should correspond to the ID from the Games Catalog - https://help.smartico.ai/welcome/technical-guides/games-catalog-api
38
+ *
39
+ * **Example**:
40
+ * ```
41
+ * _smartico.api.getRelatedItemsForGame('gold-slot2').then((result) => {
42
+ * console.log(result);
43
+ * });
44
+ * ```
45
+ *
46
+ * **Example in the Visitor mode**:
47
+ * ```
48
+ * _smartico.vapi('EN').getRelatedItemsForGame('gold-slot2').then((result) => {
49
+ * console.log(result);
50
+ * });
51
+ * ```
52
+ */
53
+ public async getRelatedItemsForGame(related_game_id: string): Promise<GetRelatedAchTourResponse> {
54
+ const result = await this.api.getRelatedItemsForGame(this.userExtId, related_game_id);
55
+ return result;
56
+ }
57
+ }
@@ -0,0 +1,222 @@
1
+ import { ActivityTypeLimited } from '../Core';
2
+ import { ECacheContext, OCache } from '../OCache';
3
+ import {
4
+ InboxMarkMessageAction,
5
+ TInboxMessage,
6
+ TInboxMessageBody,
7
+ } from './WSAPITypes';
8
+ import { InboxCategories } from '../Inbox/InboxCategories';
9
+ import { InboxReadStatus } from '../Inbox/InboxReadStatus';
10
+ import {
11
+ CACHE_DATA_SEC,
12
+ onUpdateContextKey,
13
+ } from './WSAPIBase';
14
+ import { WSAPILeaderBoard } from './WSAPILeaderBoard';
15
+
16
+ /** @group Inbox */
17
+ export class WSAPIInbox extends WSAPILeaderBoard {
18
+ /**
19
+ * Reports an impression event for an engagement (when engagement content is displayed to the user).
20
+ * Use this method to track when users view engagement content such as inbox messages, popups.
21
+ * When using for Inbox cases, you need to use message guid as engagement_uid, and pass 31 as activityType.
22
+ *
23
+ * **Example**:
24
+ * ```
25
+ * _smartico.api.reportImpressionEvent({
26
+ * engagement_uid: 'abc123-def456',
27
+ * activityType: 31 // Inbox
28
+ * });
29
+ * ```
30
+ *
31
+ * **Visitor mode: not supported**
32
+ *
33
+ * @param params - Event parameters
34
+ * @param params.engagement_uid - Unique identifier for the engagement
35
+ * @param params.activityType - Type of engagement activity (Popup=30, Inbox=31)
36
+ */
37
+ public reportImpressionEvent({
38
+ engagement_uid,
39
+ activityType,
40
+ }: {
41
+ engagement_uid: string;
42
+ activityType: ActivityTypeLimited | number;
43
+ }): void {
44
+ this.api.reportEngagementImpression(this.userExtId, engagement_uid, activityType);
45
+ }
46
+
47
+ /**
48
+ * Reports a click/action event for an engagement (when user interacts with engagement content).
49
+ * Use this method to track when users click on or interact with engagement content such as inbox messages, popups.
50
+ * When using for Inbox cases, you need to use message guid as engagement_uid, and pass 31 as activityType, and pass the action/deeplink that was triggered by the user interaction as action.
51
+ *
52
+ * **Example**:
53
+ * ```
54
+ * _smartico.api.reportClickEvent({
55
+ * engagement_uid: 'abc123-def456',
56
+ * activityType: 31 // Inbox
57
+ * action: 'dp:gf_missions'
58
+ * });
59
+ * ```
60
+ *
61
+ * **Visitor mode: not supported**
62
+ *
63
+ * @param params - Event parameters
64
+ * @param params.engagement_uid - Unique identifier for the engagement
65
+ * @param params.activityType - Type of engagement activity (Popup=30, Inbox=31)
66
+ * @param params.action - Optional action/deeplink that was triggered by the user interaction
67
+ */
68
+ public reportClickEvent({
69
+ engagement_uid,
70
+ activityType,
71
+ action,
72
+ }: {
73
+ engagement_uid: string;
74
+ activityType: ActivityTypeLimited | number;
75
+ action?: string;
76
+ }): void {
77
+ this.api.reportEngagementAction(this.userExtId, engagement_uid, activityType, action);
78
+ }
79
+
80
+ /** Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
81
+ * The maximum number of messages per request is limited to 20.
82
+ * An indicator "onlyFavorite" can be passed to get only messages marked as favorites.
83
+ * An indicator "read_status" can be passed to get only messages marked as read or unread.
84
+ * You can leave this params empty and by default it will return list of messages ranging from 0 to 20.
85
+ * This function returns a list of messages without the body of each message.
86
+ * To get the body of the message you need to call getInboxMessageBody function and pass the message guid contained in each message of this request.
87
+ * All other action like mark as read, favorite, delete, etc. can be done using this message GUID.
88
+ * The "onUpdate" callback will be triggered when the user receives a new message. It will provide an updated list of messages, ranging from 0 to 20, to the onUpdate callback function.
89
+ *
90
+ * **Visitor mode: not supported**
91
+ *
92
+ * @param params
93
+ */
94
+ public async getInboxMessages({
95
+ from,
96
+ to,
97
+ onlyFavorite,
98
+ categoryId,
99
+ read_status,
100
+ onUpdate,
101
+ }: {
102
+ from?: number;
103
+ to?: number;
104
+ onlyFavorite?: boolean;
105
+ categoryId?: InboxCategories;
106
+ read_status?: InboxReadStatus;
107
+ onUpdate?: (data: TInboxMessage[]) => void;
108
+ } = {}): Promise<TInboxMessage[]> {
109
+ if (onUpdate) {
110
+ this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
111
+ }
112
+ return await this.api.getInboxMessagesT(this.userExtId, from, to, onlyFavorite, categoryId, read_status);
113
+ }
114
+
115
+ /**
116
+ * Returns inbox unread count.
117
+ *
118
+ * **Visitor mode: not supported**
119
+ * @param params
120
+ */
121
+ public async getInboxUnreadCount({ onUpdate }: { onUpdate?: (unread_count: number) => void } = {}): Promise<number> {
122
+ if (onUpdate) {
123
+ this.onUpdateCallback.set(onUpdateContextKey.InboxUnreadCount, onUpdate);
124
+ }
125
+ return OCache.use(
126
+ onUpdateContextKey.InboxUnreadCount,
127
+ ECacheContext.WSAPI,
128
+ () => this.api.getInboxUnreadCountT(this.userExtId),
129
+ CACHE_DATA_SEC,
130
+ );
131
+ }
132
+
133
+ /**
134
+ * Returns the message body of the specified message guid.
135
+ *
136
+ * **Visitor mode: not supported**
137
+ */
138
+ public async getInboxMessageBody(messageGuid: string): Promise<TInboxMessageBody> {
139
+ return await this.api.getInboxMessageBodyT(messageGuid);
140
+ }
141
+
142
+ /**
143
+ * Requests to mark inbox message with specified guid as read
144
+ *
145
+ * **Visitor mode: not supported**
146
+ */
147
+ public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
148
+ const r = await this.api.markInboxMessageRead(this.userExtId, messageGuid);
149
+
150
+ return {
151
+ err_code: r.errCode,
152
+ err_message: r.errMsg,
153
+ };
154
+ }
155
+
156
+ /**
157
+ * Requests to mark all inbox messages as read
158
+ *
159
+ * **Visitor mode: not supported**
160
+ */
161
+ public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
162
+ const r = await this.api.markAllInboxMessageRead(this.userExtId);
163
+
164
+ return {
165
+ err_code: r.errCode,
166
+ err_message: r.errMsg,
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Requests to mark inbox message with specified guid as favorite. Pass mark true to add message to favorite and false to remove.
172
+ *
173
+ * **Visitor mode: not supported**
174
+ */
175
+ public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
176
+ const r = await this.api.markUnmarkInboxMessageAsFavorite(this.userExtId, messageGuid, mark);
177
+
178
+ return {
179
+ err_code: r.errCode,
180
+ err_message: r.errMsg,
181
+ };
182
+ }
183
+
184
+ /**
185
+ * Requests to delete inbox message
186
+ *
187
+ * **Visitor mode: not supported**
188
+ */
189
+
190
+ public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
191
+ const r = await this.api.deleteInboxMessage(this.userExtId, messageGuid);
192
+
193
+ return {
194
+ err_code: r.errCode,
195
+ err_message: r.errMsg,
196
+ };
197
+ }
198
+
199
+ /**
200
+ * Requests to delete all inbox messages
201
+ *
202
+ * **Visitor mode: not supported**
203
+ */
204
+
205
+ public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
206
+ const r = await this.api.deleteAllInboxMessages(this.userExtId);
207
+
208
+ return {
209
+ err_code: r.errCode,
210
+ err_message: r.errMsg,
211
+ };
212
+ }
213
+
214
+ protected async updateInboxUnreadCount(count: number) {
215
+ this.updateEntity(onUpdateContextKey.InboxUnreadCount, count);
216
+ }
217
+
218
+ protected async updateInboxMessages() {
219
+ const payload = await this.api.getInboxMessagesT(this.userExtId);
220
+ this.updateEntity(onUpdateContextKey.InboxMessages, payload);
221
+ }
222
+ }