@smartico/public-api 0.0.379 → 0.0.381

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 (219) hide show
  1. package/.nvmrc +1 -1
  2. package/CLAUDE.md +103 -0
  3. package/README.md +53 -2
  4. package/dist/Base/ClassId.d.ts +2 -0
  5. package/dist/Jackpots/JackpotDetails.d.ts +14 -15
  6. package/dist/Jackpots/JackpotPot.d.ts +10 -6
  7. package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
  8. package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
  9. package/dist/Raffle/index.d.ts +2 -0
  10. package/dist/SmarticoAPI.d.ts +6 -1
  11. package/dist/SmarticoLib/index.d.ts +5 -1
  12. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  13. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  14. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  15. package/dist/WSAPI/WSAPIAvatars.d.ts +296 -0
  16. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  17. package/dist/WSAPI/WSAPIBonuses.d.ts +240 -0
  18. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  19. package/dist/WSAPI/WSAPIGamePick.d.ts +593 -0
  20. package/dist/WSAPI/WSAPIGeneral.d.ts +172 -0
  21. package/dist/WSAPI/WSAPIInbox.d.ts +615 -0
  22. package/dist/WSAPI/WSAPIJackpots.d.ts +344 -0
  23. package/dist/WSAPI/WSAPILeaderBoard.d.ts +139 -0
  24. package/dist/WSAPI/WSAPIMiniGames.d.ts +510 -0
  25. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  26. package/dist/WSAPI/WSAPIRaffles.d.ts +643 -0
  27. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  28. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  29. package/dist/WSAPI/WSAPITypes.d.ts +376 -205
  30. package/dist/WSAPI/WSAPIUser.d.ts +533 -0
  31. package/dist/index.js +6745 -1661
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.modern.mjs +6324 -1342
  34. package/dist/index.modern.mjs.map +1 -1
  35. package/docs/Callbacks.md +162 -0
  36. package/docs/SmarticoObject.md +445 -0
  37. package/docs/Transforms.md +99 -0
  38. package/docs/api/README.md +82 -2
  39. package/docs/api/classes/WSAPIAvatars.md +344 -0
  40. package/docs/api/classes/WSAPIBonuses.md +271 -0
  41. package/docs/api/classes/WSAPIClans.md +436 -0
  42. package/docs/api/classes/WSAPIGamePick.md +710 -0
  43. package/docs/api/classes/WSAPIGeneral.md +212 -0
  44. package/docs/api/classes/WSAPIInbox.md +801 -0
  45. package/docs/api/classes/WSAPIJackpots.md +439 -0
  46. package/docs/api/classes/WSAPILeaderBoard.md +157 -0
  47. package/docs/api/classes/WSAPIMiniGames.md +612 -0
  48. package/docs/api/classes/WSAPIMissions.md +590 -0
  49. package/docs/api/classes/WSAPIRaffles.md +773 -0
  50. package/docs/api/classes/WSAPIStore.md +719 -0
  51. package/docs/api/classes/WSAPITournaments.md +571 -0
  52. package/docs/api/classes/WSAPIUser.md +637 -0
  53. package/docs/api/documents/Callbacks.md +162 -0
  54. package/docs/api/documents/SmarticoObject.md +445 -0
  55. package/docs/api/documents/Transforms.md +99 -0
  56. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  57. package/docs/api/enumerations/BonusStatus-1.md +11 -6
  58. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  59. package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
  60. package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
  61. package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
  62. package/docs/api/interfaces/AvatarCustomized.md +25 -0
  63. package/docs/api/interfaces/AvatarDefinition.md +94 -0
  64. package/docs/api/interfaces/AvatarPrompt.md +45 -0
  65. package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
  66. package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
  67. package/docs/api/interfaces/Clan.md +4 -0
  68. package/docs/api/interfaces/ClanInfo.md +109 -0
  69. package/docs/api/interfaces/ClanMember.md +53 -0
  70. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  71. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  72. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  73. package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
  74. package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
  75. package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
  76. package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
  77. package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
  78. package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
  79. package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
  80. package/docs/api/interfaces/JackpotDetails.md +14 -15
  81. package/docs/api/interfaces/JackpotPot.md +9 -6
  82. package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
  83. package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
  84. package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
  85. package/docs/api/interfaces/PointsLog.md +43 -0
  86. package/docs/api/interfaces/RaffleWonPrize.md +59 -0
  87. package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
  88. package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
  89. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  90. package/docs/api/interfaces/TAchCategory.md +14 -4
  91. package/docs/api/interfaces/TAvatarCustomized.md +4 -4
  92. package/docs/api/interfaces/TAvatarDefinition.md +13 -14
  93. package/docs/api/interfaces/TAvatarPrompt.md +6 -6
  94. package/docs/api/interfaces/TBonus.md +16 -8
  95. package/docs/api/interfaces/TBuyStoreItemResult.md +4 -11
  96. package/docs/api/interfaces/TClaimBonusResult.md +5 -5
  97. package/docs/api/interfaces/TClan.md +8 -4
  98. package/docs/api/interfaces/TClanInfo.md +47 -0
  99. package/docs/api/interfaces/TClanJoinResult.md +11 -1
  100. package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
  101. package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
  102. package/docs/api/interfaces/TClans.md +3 -1
  103. package/docs/api/interfaces/TGetTranslations.md +4 -0
  104. package/docs/api/interfaces/TInboxMessage.md +14 -6
  105. package/docs/api/interfaces/TInboxMessageBody.md +18 -12
  106. package/docs/api/interfaces/TLevel.md +17 -20
  107. package/docs/api/interfaces/TLevelCurrent.md +19 -18
  108. package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
  109. package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
  110. package/docs/api/interfaces/TMissionClaimRewardResult.md +6 -3
  111. package/docs/api/interfaces/TMissionOptInResult.md +6 -3
  112. package/docs/api/interfaces/TMissionOrBadge.md +5 -4
  113. package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
  114. package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
  115. package/docs/api/interfaces/TSetAvatarResult.md +3 -3
  116. package/docs/api/interfaces/TStoreItem.md +11 -1
  117. package/docs/api/interfaces/TTournament.md +1 -1
  118. package/docs/api/interfaces/TTournamentDetailed.md +9 -1
  119. package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
  120. package/docs/api/interfaces/TUICustomSection.md +23 -19
  121. package/docs/api/interfaces/TUserProfile.md +18 -16
  122. package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
  123. package/docs/api/interfaces/UserAchievement.md +1 -1
  124. package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
  125. package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
  126. package/docs/native/ADDING_METHODS.md +7 -2
  127. package/docs/native/PROTOCOL.md +337 -0
  128. package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
  129. package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
  130. package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
  131. package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
  132. package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
  133. package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
  134. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  135. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  136. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  137. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
  138. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
  139. package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
  140. package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
  141. package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
  142. package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
  143. package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
  144. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
  145. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
  146. package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
  147. package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
  148. package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
  149. package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
  150. package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
  151. package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
  152. package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
  153. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
  154. package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
  155. package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
  156. package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
  157. package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
  158. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
  159. package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
  160. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
  161. package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
  162. package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
  163. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  164. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  165. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  166. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  167. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  168. package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
  169. package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
  170. package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
  171. package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
  172. package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
  173. package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
  174. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  175. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  176. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  177. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  178. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  179. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  180. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  181. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  182. package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
  183. package/docs/ui/user/UIGuide_getLevels.md +167 -0
  184. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  185. package/package.json +3 -3
  186. package/scripts/postdoc-cleanup.js +195 -0
  187. package/src/Base/ClassId.ts +2 -0
  188. package/src/Jackpots/JackpotDetails.ts +14 -15
  189. package/src/Jackpots/JackpotPot.ts +10 -6
  190. package/src/Missions/MissionsUtils.ts +5 -2
  191. package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
  192. package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
  193. package/src/Raffle/index.ts +3 -1
  194. package/src/SmarticoAPI.ts +14 -1
  195. package/src/SmarticoLib/index.ts +4 -0
  196. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  197. package/src/Store/StoreItem.ts +1 -0
  198. package/src/Store/StoreItemPurchased.ts +1 -0
  199. package/src/Store/StoreItemType.ts +1 -1
  200. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  201. package/src/WSAPI/WSAPI.ts +27 -2007
  202. package/src/WSAPI/WSAPIAvatars.ts +345 -0
  203. package/src/WSAPI/WSAPIBase.ts +93 -0
  204. package/src/WSAPI/WSAPIBonuses.ts +268 -0
  205. package/src/WSAPI/WSAPIClans.ts +417 -0
  206. package/src/WSAPI/WSAPIGamePick.ts +667 -0
  207. package/src/WSAPI/WSAPIGeneral.ts +199 -0
  208. package/src/WSAPI/WSAPIInbox.ts +711 -0
  209. package/src/WSAPI/WSAPIJackpots.ts +448 -0
  210. package/src/WSAPI/WSAPILeaderBoard.ts +154 -0
  211. package/src/WSAPI/WSAPIMiniGames.ts +597 -0
  212. package/src/WSAPI/WSAPIMissions.ts +572 -0
  213. package/src/WSAPI/WSAPIRaffles.ts +703 -0
  214. package/src/WSAPI/WSAPIStore.ts +732 -0
  215. package/src/WSAPI/WSAPITournaments.ts +541 -0
  216. package/src/WSAPI/WSAPITypes.ts +376 -207
  217. package/src/WSAPI/WSAPIUser.ts +606 -0
  218. package/tsconfig.json +26 -2
  219. package/docs/api/classes/WSAPI.md +0 -1927
@@ -0,0 +1,667 @@
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 every open round for a MatchX or Quiz game template, with the full
16
+ * event list (matches / questions) and the current user's selections per event.
17
+ *
18
+ * Use to power the rounds-lobby screen — typically a list of round cards a user
19
+ * can tap into to make predictions. For a single round, use
20
+ * {@link gamePickGetActiveRound} (lighter payload when only one round is shown).
21
+ *
22
+ * @remarks
23
+ * **Preconditions**
24
+ * - User must be authenticated.
25
+ * - `saw_template_id` must reference a MatchX or Quiz game template. The SDK
26
+ * throws synchronously if it's missing.
27
+ *
28
+ * **Transport**
29
+ * Game Pick methods are HTTP REST calls to a separate Game Pick games server
30
+ * (not the main WebSocket). One consequence: there is no SDK cache and no push
31
+ * subscription — every call is a fresh server roundtrip.
32
+ *
33
+ * **Round status**
34
+ * Each round's `round_status_id` is a {@link GPRoundStatus} value. Rounds with
35
+ * status `NoEventsDefined` (1) are filtered out server-side and never appear
36
+ * here. Other values: `Other` (-1, normally open), `NoMoreBetsAllowed` (2),
37
+ * `AllEventsResolved_ButNotRound` (3), `RoundResolved` (4 — appears here only
38
+ * briefly during transition; use {@link gamePickGetHistory} for resolved rounds).
39
+ *
40
+ * **Error codes** (in `errCode`)
41
+ * - `0` — success.
42
+ * - `100002` — template not found (the `saw_template_id` doesn't reference a
43
+ * MatchX/Quiz game).
44
+ * - `100003` — no open rounds available for this template right now.
45
+ * - `100000` — auth hash invalid; SDK session needs re-initialization.
46
+ * - `100004` — generic server error.
47
+ *
48
+ * **Refresh**
49
+ * - No cache; every call is live.
50
+ * - No push subscription. Poll while the user is on the screen if you need
51
+ * live round-status changes (typically every 30–60 s is enough).
52
+ *
53
+ * **Visitor mode**: not supported. The SDK throws synchronously on visitor
54
+ * sessions.
55
+ *
56
+ * **UI guidance**: see [UI Guide — `gamePickGetActiveRounds`](../../docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md).
57
+ *
58
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
59
+ * @returns Wrapped {@link GamesApiResponse} of {@link GamePickRound} array.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const r = await window._smartico.api.gamePickGetActiveRounds({ saw_template_id: 1083 });
64
+ *
65
+ * if (r.errCode !== 0) {
66
+ * console.error('[smartico] active rounds fetch failed — show empty rounds lobby:', r.errMessage);
67
+ * return;
68
+ * }
69
+ *
70
+ * for (const round of r.data ?? []) {
71
+ * console.log('[smartico] render a round card:', round.round_name, '— events:', round.events.length, 'user has placed bet:', round.user_placed_bet);
72
+ * }
73
+ * ```
74
+ */
75
+ public async gamePickGetActiveRounds(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>> {
76
+ if (!props.saw_template_id) {
77
+ throw new Error('saw_template_id is required');
78
+ }
79
+ return this.api.gpGetActiveRounds(props.saw_template_id);
80
+ }
81
+
82
+ /**
83
+ * Returns a single round (events, user selections, scoring rules) for a
84
+ * MatchX or Quiz game. Use to power the round-detail / prediction-input
85
+ * screen the user lands on after picking a round from the lobby.
86
+ *
87
+ * Same shape as one entry of {@link gamePickGetActiveRounds}; cheaper when the
88
+ * UI only shows one round at a time.
89
+ *
90
+ * @remarks
91
+ * **Preconditions**
92
+ * - User must be authenticated. Visitor mode not supported.
93
+ * - `saw_template_id` and `round_id` are mandatory — the SDK throws if either
94
+ * is missing.
95
+ *
96
+ * **Error codes** (in `errCode`)
97
+ * - `0` — success.
98
+ * - `4` — round / event not found (e.g. round resolved after the last
99
+ * `gamePickGetActiveRounds` poll); non-fatal — retry after a fresh active-
100
+ * rounds fetch.
101
+ * - `100002` — template not found.
102
+ * - `100000` — auth hash invalid.
103
+ * - `100004` — generic server error.
104
+ *
105
+ * **Refresh**
106
+ * - No cache; every call is live.
107
+ * - Re-call after {@link gamePickSubmitSelection} or
108
+ * {@link gamePickSubmitSelectionQuiz} to surface the persisted predictions.
109
+ * - Poll while the user is on the prediction screen if event resolution
110
+ * updates are needed (typically every 30–60 s).
111
+ *
112
+ * **Visitor mode**: not supported.
113
+ *
114
+ * **UI guidance**: see [UI Guide — `gamePickGetActiveRound`](../../docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md).
115
+ *
116
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
117
+ * @param props.round_id ID of the round to fetch.
118
+ * @returns Wrapped {@link GamesApiResponse} of a single {@link GamePickRound}.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const r = await window._smartico.api.gamePickGetActiveRound({
123
+ * saw_template_id: 1083,
124
+ * round_id: 31652,
125
+ * });
126
+ *
127
+ * if (r.errCode === 0 && r.data) {
128
+ * console.log('[smartico] render round detail page —', r.data.round_name, '— user has placed bet:', r.data.user_placed_bet, 'score so far:', r.data.user_score);
129
+ * } else {
130
+ * console.error('[smartico] round fetch failed — bounce back to the lobby and refresh:', r.errMessage);
131
+ * }
132
+ * ```
133
+ */
134
+ public async gamePickGetActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>> {
135
+ if (!props.saw_template_id) {
136
+ throw new Error('saw_template_id is required');
137
+ }
138
+ if (!props.round_id) {
139
+ throw new Error('round_id is required');
140
+ }
141
+ return this.api.gpGetActiveRound(props.saw_template_id, props.round_id);
142
+ }
143
+
144
+ /**
145
+ * Returns the full round history (active + resolved) for a MatchX or Quiz game
146
+ * template, newest-first. Each round carries the user's predictions plus the
147
+ * server-resolved outcome on each event.
148
+ *
149
+ * Use to power a "Past predictions" / history tab. For just the open rounds,
150
+ * use {@link gamePickGetActiveRounds} (faster — skips resolved data).
151
+ *
152
+ * @remarks
153
+ * **Preconditions**
154
+ * - User must be authenticated. Visitor mode not supported.
155
+ *
156
+ * **Sort order**
157
+ * Server returns rounds newest-first. No client-side sort needed.
158
+ *
159
+ * **Per-event resolution**
160
+ * Each event in the rounds carries `resolution_type_id` — values are from
161
+ * {@link GamePickResolutionType}: `None` (0, not yet resolved), `Lost` (2),
162
+ * `PartialWin` (3), `FullWin` (4). Use these to render result badges on
163
+ * each event row.
164
+ *
165
+ * **Error codes** (in `errCode`)
166
+ * - `0` — success.
167
+ * - `100002` — template not found.
168
+ * - `100000` — auth hash invalid.
169
+ * - `100004` — generic server error.
170
+ *
171
+ * **Refresh**
172
+ * - No cache.
173
+ * - No push subscription. Re-call when the user opens the history tab.
174
+ *
175
+ * **Visitor mode**: not supported.
176
+ *
177
+ * **UI guidance**: see [UI Guide — `gamePickGetHistory`](../../docs/ui/gamepick/UIGuide_gamePickGetHistory.md).
178
+ *
179
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
180
+ * @returns Wrapped {@link GamesApiResponse} of {@link GamePickRound} array,
181
+ * newest-first.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const r = await window._smartico.api.gamePickGetHistory({ saw_template_id: 1083 });
186
+ *
187
+ * for (const round of r.data ?? []) {
188
+ * console.log('[smartico] history row —', round.round_name, 'score:', round.user_score, 'resolved:', round.is_resolved);
189
+ * }
190
+ * ```
191
+ */
192
+ public async gamePickGetHistory(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>> {
193
+ if (!props.saw_template_id) {
194
+ throw new Error('saw_template_id is required');
195
+ }
196
+ return this.api.gpGetGamesHistory(props.saw_template_id);
197
+ }
198
+
199
+ /**
200
+ * Returns the leaderboard for a MatchX or Quiz game round — ranked list of
201
+ * players plus the current user's entry (`my_user`). Pass `round_id: -1` for
202
+ * the season / overall leaderboard across every round in the template.
203
+ *
204
+ * @remarks
205
+ * **Preconditions**
206
+ * - User must be authenticated. Visitor mode not supported.
207
+ *
208
+ * **`round_id` semantics**
209
+ * - Positive `round_id` — per-round leaderboard scoped to that round's events.
210
+ * - `-1` — season / overall leaderboard aggregating scores across every round
211
+ * of the template.
212
+ *
213
+ * **`my_user`**
214
+ * The current user's entry is returned separately from the `users[]` array
215
+ * — `my_user` may be `null` if the user has never made a prediction on this
216
+ * round / template. Use it to render the user's rank in a sticky footer or
217
+ * "you are here" highlight regardless of pagination.
218
+ *
219
+ * **Username masking**
220
+ * `public_username` on other players may be masked / anonymized by operator
221
+ * label settings. Always pair with `avatar_url` so the user can recognize
222
+ * themselves in the ranking by avatar even when usernames are hidden.
223
+ *
224
+ * **Error codes** (in `errCode`)
225
+ * - `0` — success.
226
+ * - `100002` — template not found.
227
+ * - `100000` — auth hash invalid.
228
+ * - `100004` — generic server error.
229
+ *
230
+ * **Refresh**
231
+ * - No cache.
232
+ * - No push subscription. Poll while the leaderboard is visible
233
+ * (every 30–60 s) if you want live rank updates after match
234
+ * resolution.
235
+ *
236
+ * **Visitor mode**: not supported.
237
+ *
238
+ * **UI guidance**: see [UI Guide — `gamePickGetBoard`](../../docs/ui/gamepick/UIGuide_gamePickGetBoard.md).
239
+ *
240
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
241
+ * @param props.round_id Round ID, or `-1` for the season leaderboard.
242
+ * @returns Wrapped {@link GamesApiResponse} of {@link GamePickRoundBoard}.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * const r = await window._smartico.api.gamePickGetBoard({
247
+ * saw_template_id: 1083,
248
+ * round_id: -1, // season leaderboard
249
+ * });
250
+ *
251
+ * if (r.errCode === 0 && r.data) {
252
+ * console.log('[smartico] render leaderboard rows for top', r.data.users.length, 'players');
253
+ * if (r.data.my_user) {
254
+ * console.log('[smartico] pin "you are rank #' + r.data.my_user.gp_position + '" footer to bottom');
255
+ * } else {
256
+ * console.log('[smartico] user not ranked — render "Play a round to join the leaderboard" CTA');
257
+ * }
258
+ * }
259
+ * ```
260
+ */
261
+ public async gamePickGetBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>> {
262
+ if (!props.saw_template_id) {
263
+ throw new Error('saw_template_id is required');
264
+ }
265
+ if (!props.round_id) {
266
+ throw new Error('round_id is required');
267
+ }
268
+ return this.api.gpGetGameBoard(props.saw_template_id, props.round_id);
269
+ }
270
+
271
+ /**
272
+ * Submits all score predictions for a round in a MatchX game in one shot.
273
+ * Each event in the round must carry `team1_user_selection` and
274
+ * `team2_user_selection` (the predicted scores).
275
+ *
276
+ * On the user's FIRST submit for a round, the server charges one buy-in (one
277
+ * "spin" / one currency deduction based on the template's `saw_buyin_type_id`).
278
+ * Subsequent edits within the same round are free and only persist changed
279
+ * selections.
280
+ *
281
+ * @remarks
282
+ * **Preconditions**
283
+ * - User must be authenticated. Visitor mode not supported.
284
+ * - `saw_template_id` and `props.round.round_id` are mandatory — SDK throws if
285
+ * either is missing.
286
+ * - Each event passed must include `gp_event_id` and the two
287
+ * `team{1,2}_user_selection` fields. Missing events default to "no change".
288
+ *
289
+ * **Error codes** (in `errCode`)
290
+ * - `0` — success; the response `data` is the updated round with
291
+ * `user_placed_bet === true` and `has_not_submitted_changes === false`.
292
+ * - `3` (`NoBetsUpdatedOnSubmit`) — submit produced no changes, OR every event
293
+ * is past its `last_bet_date` deadline. The buy-in is NOT consumed; the
294
+ * current round is still returned in `data`.
295
+ * - `4` — round / event not found; refresh state and retry.
296
+ * - `100002` — template not found.
297
+ * - `100000` — auth hash invalid.
298
+ * - `100004` — generic server error.
299
+ *
300
+ * Buy-in failures pass through the {@link SAWSpinErrorCode} values on first
301
+ * submit:
302
+ * - `40001` — no spins left (when `saw_buyin_type_id` is Spins).
303
+ * - `40003` — insufficient points.
304
+ * - `40004` — global max-spins cap hit.
305
+ * - `40007` — template outside its active date window.
306
+ * - `40009` — user excluded by segment rule.
307
+ * - `40011` — insufficient gems.
308
+ * - `40012` — insufficient diamonds.
309
+ *
310
+ * **Idempotency**
311
+ * Re-submitting identical selections returns `errCode: 3` (no changes); the
312
+ * buy-in is consumed exactly once per round-per-user. Re-submitting after
313
+ * `last_bet_date` also returns `errCode: 3` without consuming the buy-in.
314
+ *
315
+ * **Side effects**
316
+ * - First successful submit deducts the buy-in (Points / Gems / Diamonds /
317
+ * one Spin) per `saw_buyin_type_id`.
318
+ * - Reports a `minigame_matchx_prediction` event to the operator's event log.
319
+ * - Updates the round's participant counter (`users_cnt`) and per-event
320
+ * counters (`num_users`).
321
+ * - Score is awarded after the operator resolves the round
322
+ * ({@link GPRoundStatus} = `RoundResolved`).
323
+ *
324
+ * **Visitor mode**: not supported.
325
+ *
326
+ * **UI guidance**: see [UI Guide — `gamePickSubmitSelection`](../../docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md).
327
+ *
328
+ * @param props.saw_template_id ID of the MatchX game template.
329
+ * @param props.round Round object with `round_id` + `events[]`
330
+ * carrying the user's score predictions.
331
+ * @returns Wrapped {@link GamesApiResponse} with the updated round.
332
+ *
333
+ * @example
334
+ * ```ts
335
+ * const ar = await window._smartico.api.gamePickGetActiveRound({
336
+ * saw_template_id: 1190,
337
+ * round_id: 38665,
338
+ * });
339
+ * if (ar.errCode !== 0 || !ar.data) {
340
+ * console.error('[smartico] could not fetch round to submit — show error and bounce back');
341
+ * return;
342
+ * }
343
+ *
344
+ * const round = ar.data;
345
+ * round.events = round.events.map(e => ({
346
+ * gp_event_id: e.gp_event_id,
347
+ * team1_user_selection: 1,
348
+ * team2_user_selection: 0,
349
+ * }));
350
+ *
351
+ * const r = await window._smartico.api.gamePickSubmitSelection({
352
+ * saw_template_id: 1190,
353
+ * round,
354
+ * });
355
+ *
356
+ * switch (r.errCode) {
357
+ * case 0:
358
+ * console.log('[smartico] predictions saved — show confirmation, refresh leaderboard');
359
+ * break;
360
+ * case 3:
361
+ * console.log('[smartico] nothing changed (or all events closed) — silent no-op');
362
+ * break;
363
+ * case 40001:
364
+ * case 40003:
365
+ * case 40011:
366
+ * case 40012:
367
+ * console.error('[smartico] insufficient balance / spins — show top-up CTA:', r.errMessage);
368
+ * break;
369
+ * default:
370
+ * console.error('[smartico] submit failed — show generic error toast:', r.errMessage);
371
+ * }
372
+ * ```
373
+ */
374
+ public async gamePickSubmitSelection(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
375
+ if (!props.saw_template_id) {
376
+ throw new Error('saw_template_id is required');
377
+ }
378
+ if (!props.round?.round_id) {
379
+ throw new Error('round is required');
380
+ }
381
+ return this.api.gpSubmitSelection(props.saw_template_id, props.round, false);
382
+ }
383
+
384
+ /**
385
+ * Submits all quiz answers for a round in one shot. Each event in the round
386
+ * must carry `user_selection` (the answer value — typically `"1"` / `"2"` /
387
+ * `"x"` for 1×2 markets, `"yes"` / `"no"` for binary markets, or any
388
+ * operator-defined string for custom markets).
389
+ *
390
+ * Same first-submit buy-in behavior as {@link gamePickSubmitSelection} — one
391
+ * buy-in is charged on the first successful submit; subsequent edits within
392
+ * the same round are free.
393
+ *
394
+ * @remarks
395
+ * **Preconditions**
396
+ * - User must be authenticated. Visitor mode not supported.
397
+ * - `saw_template_id` and `props.round.round_id` are mandatory — SDK throws if
398
+ * either is missing.
399
+ * - Each event must include `gp_event_id` and `user_selection`. Missing
400
+ * events default to "no change".
401
+ *
402
+ * **Error codes** (in `errCode`)
403
+ * - `0` — success.
404
+ * - `3` (`NoBetsUpdatedOnSubmit`) — no changes, OR every event past
405
+ * `last_bet_date`. Buy-in NOT consumed; current round returned in `data`.
406
+ * - `4` — round / event not found.
407
+ * - `100002` — template not found.
408
+ * - `100000` — auth hash invalid.
409
+ * - `100004` — generic server error.
410
+ *
411
+ * Buy-in failures use the same {@link SAWSpinErrorCode} pass-through values
412
+ * as {@link gamePickSubmitSelection} — see that method's TSDoc for the
413
+ * `40001` / `40003` / `40004` / `40007` / `40009` / `40011` / `40012`
414
+ * semantics.
415
+ *
416
+ * **Idempotency**: identical to {@link gamePickSubmitSelection} — re-submit
417
+ * returns `errCode: 3` and never double-charges the buy-in.
418
+ *
419
+ * **Side effects**: identical to {@link gamePickSubmitSelection}, with the
420
+ * reported event being `minigame_quiz_prediction` instead of
421
+ * `minigame_matchx_prediction`.
422
+ *
423
+ * **Visitor mode**: not supported.
424
+ *
425
+ * **UI guidance**: see [UI Guide — `gamePickSubmitSelectionQuiz`](../../docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md).
426
+ *
427
+ * @param props.saw_template_id ID of the Quiz game template.
428
+ * @param props.round Round object with `round_id` + `events[]`
429
+ * carrying the user's answer selections.
430
+ * @returns Wrapped {@link GamesApiResponse} with the updated round.
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * const ar = await window._smartico.api.gamePickGetActiveRound({
435
+ * saw_template_id: 1183,
436
+ * round_id: 37974,
437
+ * });
438
+ * if (ar.errCode !== 0 || !ar.data) {
439
+ * console.error('[smartico] could not fetch round to submit answers — show error');
440
+ * return;
441
+ * }
442
+ *
443
+ * const round = ar.data;
444
+ * round.events = round.events.map(e => ({
445
+ * gp_event_id: e.gp_event_id,
446
+ * user_selection: 'x',
447
+ * }));
448
+ *
449
+ * const r = await window._smartico.api.gamePickSubmitSelectionQuiz({
450
+ * saw_template_id: 1183,
451
+ * round,
452
+ * });
453
+ *
454
+ * if (r.errCode === 0) {
455
+ * console.log('[smartico] quiz answers saved — show confirmation');
456
+ * } else if (r.errCode === 3) {
457
+ * console.log('[smartico] nothing changed — silent no-op');
458
+ * } else {
459
+ * console.error('[smartico] quiz submit failed:', r.errMessage);
460
+ * }
461
+ * ```
462
+ */
463
+ public async gamePickSubmitSelectionQuiz(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
464
+ if (!props.saw_template_id) {
465
+ throw new Error('saw_template_id is required');
466
+ }
467
+ if (!props.round?.round_id) {
468
+ throw new Error('round is required');
469
+ }
470
+ return this.api.gpSubmitSelection(props.saw_template_id, props.round, true);
471
+ }
472
+
473
+ /**
474
+ * Returns the current user's profile within the Game Pick system — display
475
+ * name, avatar, balances, and last wallet-sync timestamp. The Game Pick server
476
+ * maintains its own user record that mirrors the user's Smartico balances; the
477
+ * mirror is updated at most once per minute, so `last_wallet_sync_time` tells
478
+ * the consumer how stale the balances on the response are.
479
+ *
480
+ * On the user's first call for a given game, the Game Pick server lazily
481
+ * provisions a user record — so this method doubles as a "register the user
482
+ * with this game" call.
483
+ *
484
+ * @remarks
485
+ * **Preconditions**
486
+ * - User must be authenticated. Visitor mode not supported.
487
+ *
488
+ * **Balance freshness**
489
+ * The balances returned here are the cached mirror — at most ~1 minute stale.
490
+ * For an up-to-the-second view of Points / Gems / Diamonds, read from
491
+ * {@link getUserProfile} instead. Use this method's balances only for
492
+ * in-Game-Pick display.
493
+ *
494
+ * **Error codes** (in `errCode`)
495
+ * - `0` — success.
496
+ * - `100002` — template not found.
497
+ * - `100000` — auth hash invalid.
498
+ * - `100004` — generic server error.
499
+ *
500
+ * **Refresh**
501
+ * - No cache. Server-side mirror refreshes at most every 60 s.
502
+ * - No push subscription.
503
+ *
504
+ * **Visitor mode**: not supported.
505
+ *
506
+ * **UI guidance**: see [UI Guide — `gamePickGetUserInfo`](../../docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md).
507
+ *
508
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
509
+ * @returns Wrapped {@link GamesApiResponse} of {@link GamePickUserInfo}.
510
+ *
511
+ * @example
512
+ * ```ts
513
+ * const r = await window._smartico.api.gamePickGetUserInfo({ saw_template_id: 1083 });
514
+ *
515
+ * if (r.errCode === 0 && r.data) {
516
+ * console.log('[smartico] render Game Pick header — name:', r.data.public_username, '— points:', r.data.ach_points_balance, '— synced:', r.data.last_wallet_sync_time);
517
+ * }
518
+ * ```
519
+ */
520
+ public async gamePickGetUserInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickUserInfo>> {
521
+ if (!props.saw_template_id) {
522
+ throw new Error('saw_template_id is required');
523
+ }
524
+ return this.api.gpGetUserInfo(props.saw_template_id);
525
+ }
526
+
527
+ /**
528
+ * Returns the game template configuration plus a metadata listing of every
529
+ * round (without events). Use to power the game's welcome / lobby screen —
530
+ * shows the template name, buy-in cost, the user's remaining attempts, and
531
+ * the full round list.
532
+ *
533
+ * The `allRounds[]` here is a lightweight metadata-only view — to render
534
+ * predictions or leaderboards, call {@link gamePickGetActiveRound} /
535
+ * {@link gamePickGetActiveRounds} / {@link gamePickGetBoard} for the rounds
536
+ * the user actually opens.
537
+ *
538
+ * @remarks
539
+ * **Preconditions**
540
+ * - User must be authenticated. Visitor mode not supported.
541
+ *
542
+ * **Buy-in semantics**
543
+ * The `sawTemplate.saw_buyin_type_id` value determines which currency is
544
+ * deducted on the user's first prediction in any round:
545
+ * - Free — no deduction.
546
+ * - Points — `buyin_cost_points` deducted from the user's points balance.
547
+ * - Gems — deducted from the user's gems balance.
548
+ * - Diamonds — deducted from the user's diamonds balance.
549
+ * - Spins — one spin counted from `spin_count`.
550
+ *
551
+ * **Error codes** (in `errCode`)
552
+ * - `0` — success.
553
+ * - `100002` — template not found.
554
+ * - `100000` — auth hash invalid.
555
+ * - `100004` — generic server error.
556
+ *
557
+ * **Refresh**
558
+ * - No cache.
559
+ * - No push subscription. Re-call after a successful
560
+ * {@link gamePickSubmitSelection} to refresh `spin_count`.
561
+ *
562
+ * **Visitor mode**: not supported.
563
+ *
564
+ * **UI guidance**: see [UI Guide — `gamePickGetGameInfo`](../../docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md).
565
+ *
566
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
567
+ * @returns Wrapped {@link GamesApiResponse} of {@link GamePickGameInfo}.
568
+ *
569
+ * @example
570
+ * ```ts
571
+ * const r = await window._smartico.api.gamePickGetGameInfo({ saw_template_id: 1189 });
572
+ *
573
+ * if (r.errCode === 0 && r.data) {
574
+ * console.log('[smartico] render Game Pick lobby — title:', r.data.sawTemplate.saw_template_ui_definition.name);
575
+ * console.log('[smartico] rounds available:', r.data.allRounds.length, '— buy-in type:', r.data.sawTemplate.saw_buyin_type_id, 'cost:', r.data.sawTemplate.buyin_cost_points);
576
+ * }
577
+ * ```
578
+ */
579
+ public async gamePickGetGameInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickGameInfo>> {
580
+ if (!props.saw_template_id) {
581
+ throw new Error('saw_template_id is required');
582
+ }
583
+ return this.api.gpGetGameInfo(props.saw_template_id);
584
+ }
585
+
586
+ /**
587
+ * Returns a round with another player's predictions instead of the current
588
+ * user's. The target player is identified by `int_user_id` (the Game Pick
589
+ * system's internal user ID, obtained from {@link gamePickGetBoard}'s
590
+ * `users[].int_user_id`).
591
+ *
592
+ * Use to power "view this player's picks" affordances opened from leaderboard
593
+ * rows — community / social inspection of how a top-ranked user predicted.
594
+ *
595
+ * @remarks
596
+ * **Preconditions**
597
+ * - User must be authenticated. Visitor mode not supported.
598
+ * - `saw_template_id`, `round_id`, and `int_user_id` are all mandatory — SDK
599
+ * throws synchronously if any is missing.
600
+ * - `int_user_id` must come from a leaderboard fetch in the same game
601
+ * template; it is stable within a template but not portable across
602
+ * templates.
603
+ *
604
+ * **Shape vs `gamePickGetActiveRound`**
605
+ * Same {@link GamePickRound} structure, but `user_selection` /
606
+ * `team1_user_selection` / `team2_user_selection` reflect the TARGET user's
607
+ * predictions instead of the caller's. Each event still carries its own
608
+ * `resolution_type_id` (see {@link GamePickResolutionType}) so the UI can
609
+ * render result badges per pick.
610
+ *
611
+ * **Error codes** (in `errCode`)
612
+ * - `0` — success.
613
+ * - `4` — round / event / user not found.
614
+ * - `100002` — template not found.
615
+ * - `100000` — auth hash invalid.
616
+ * - `100004` — generic server error.
617
+ *
618
+ * **Refresh**
619
+ * - No cache. Re-call when opening a different leaderboard row's
620
+ * "view picks" modal.
621
+ * - No push subscription.
622
+ *
623
+ * **Visitor mode**: not supported.
624
+ *
625
+ * **UI guidance**: see [UI Guide — `gamePickGetRoundInfoForUser`](../../docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md).
626
+ *
627
+ * @param props.saw_template_id ID of the MatchX or Quiz game template.
628
+ * @param props.round_id ID of the round to inspect.
629
+ * @param props.int_user_id Internal user ID from
630
+ * `gamePickGetBoard.users[].int_user_id`.
631
+ * @returns Wrapped {@link GamesApiResponse} with the target user's
632
+ * {@link GamePickRound}.
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * const board = await window._smartico.api.gamePickGetBoard({
637
+ * saw_template_id: 1083, round_id: 31652,
638
+ * });
639
+ * const topPlayer = board.data?.users?.[0];
640
+ * if (!topPlayer) return;
641
+ *
642
+ * const r = await window._smartico.api.gamePickGetRoundInfoForUser({
643
+ * saw_template_id: 1083,
644
+ * round_id: 31652,
645
+ * int_user_id: topPlayer.int_user_id,
646
+ * });
647
+ *
648
+ * if (r.errCode === 0 && r.data) {
649
+ * for (const ev of r.data.events) {
650
+ * console.log('[smartico] render row —', ev.event_meta.team1_name, 'vs', ev.event_meta.team2_name, '— picked:', ev.user_selection, '— resolution:', ev.resolution_type_id);
651
+ * }
652
+ * }
653
+ * ```
654
+ */
655
+ public async gamePickGetRoundInfoForUser(props: GamePickRoundRequestParams & { int_user_id: number }): Promise<GamesApiResponse<GamePickRound>> {
656
+ if (!props.saw_template_id) {
657
+ throw new Error('saw_template_id is required');
658
+ }
659
+ if (!props.round_id) {
660
+ throw new Error('round_id is required');
661
+ }
662
+ if (!props.int_user_id) {
663
+ throw new Error('int_user_id is required');
664
+ }
665
+ return this.api.gpGetRoundInfoForUser(props.saw_template_id, props.round_id, props.int_user_id);
666
+ }
667
+ }