@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,439 @@
1
+ # Class: WSAPIJackpots
2
+ ## Methods
3
+
4
+ ### jackpotGet()
5
+
6
+ > **jackpotGet**(`filter?`): `Promise`\<[`JackpotDetails`](../interfaces/JackpotDetails.md)[]\>
7
+
8
+ Returns the user-eligible jackpots active for the label, fused with their live
9
+ pot values. Each entry carries the static template (name, description, opt-in
10
+ state, eligible games, currency) plus a freshly-fetched `pot` snapshot.
11
+
12
+ Designed to be polled at high frequency (every 1 second is fine) — the SDK
13
+ splits the response into a 30-second template cache and a 1-second pot-value
14
+ cache so consumers can render a live-counting pot amount without hammering
15
+ the server for the static template data.
16
+
17
+ #### Parameters
18
+
19
+ ##### filter?
20
+
21
+ Optional filter narrowing the result set.
22
+
23
+ ###### related_game_id?
24
+
25
+ `string`
26
+
27
+ Limit to jackpots linked to this game ID
28
+ (from the operator's games catalog).
29
+
30
+ ###### jp_template_id?
31
+
32
+ `number`
33
+
34
+ Limit to a single template.
35
+
36
+ #### Returns
37
+
38
+ `Promise`\<[`JackpotDetails`](../interfaces/JackpotDetails.md)[]\>
39
+
40
+ Array of [JackpotDetails](../interfaces/JackpotDetails.md) — empty if the user is eligible
41
+ for no active jackpots.
42
+
43
+ #### Remarks
44
+
45
+ **Preconditions**
46
+ - No prerequisite calls.
47
+ - Visitor mode supported via `_smartico.vapi(lang).jackpotGet(...)`.
48
+
49
+ **Server-side eligibility filtering**
50
+ Jackpots are filtered server-side by the user's segments before being
51
+ returned. Templates the user is ineligible for never appear in this
52
+ response — there is no "locked" state to render. An empty result for a
53
+ known-good user typically means none of the configured templates match
54
+ the user's segments / level / brand.
55
+
56
+ **Filter behavior**
57
+ Passing `related_game_id` returns only jackpots linked to that game (from
58
+ the operator's games catalog). Passing `jp_template_id` returns just that
59
+ single template. With no filter, all active templates the user is
60
+ eligible for are returned. Changing the filter between calls flushes both
61
+ the template cache and the pot cache.
62
+
63
+ **Two-tier cache**
64
+ - Template definitions: 30 s cache. Re-fetched on filter change or when
65
+ opt-in / opt-out / a jackpot-win push lands.
66
+ - Pot values: 1 s cache. Re-fetched on every call past the 1-second
67
+ window so a 1 Hz poll renders a smoothly counting pot.
68
+
69
+ **`jp_public_meta.custom_data`**
70
+ Server returns this as a JSON-encoded string; the SDK parses it inline so
71
+ consumers always receive either a parsed object or the raw string.
72
+
73
+ **Personal vs MultiUser jackpots** (see [JackpotType](../enumerations/JackpotType.md))
74
+ - `MultiUser` (1) — shared pot; `registration_count` reflects real opted-in
75
+ user count; temperature transitions fire push events.
76
+ - `Personal` (2) — independent per-user pot; `registration_count` is
77
+ always 1; temperature push events are suppressed.
78
+
79
+ **Refresh**
80
+ - `jp_status_id`, segment changes, and operator template edits surface
81
+ after the 30 s template cache TTL.
82
+ - Opt-in / opt-out / jackpot-win push events all clear the template and
83
+ pot caches — the next call re-fetches.
84
+
85
+ **Visitor mode**: supported.
86
+
87
+ **UI guidance**: see [UI Guide — `jackpotGet`](../_media/UIGuide_jackpotGet.md).
88
+
89
+ #### Example
90
+
91
+ ```ts
92
+ // Poll every second for live pot counter
93
+ setInterval(async () => {
94
+ const jackpots = await window._smartico.api.jackpotGet();
95
+ for (const jp of jackpots) {
96
+ console.log('[smartico] update pot widget for', jp.jp_public_meta.name, '— amount:', jp.pot.current_pot_amount_user_currency, jp.user_currency, '— temperature:', jp.pot.current_pot_temperature);
97
+ }
98
+ }, 1000);
99
+
100
+ // Filtered fetch for a specific game tile
101
+ const linked = await window._smartico.api.jackpotGet({ related_game_id: 'gold-slot2' });
102
+ console.log('[smartico] linked jackpots for game:', linked.length);
103
+ ```
104
+
105
+ ***
106
+
107
+ ### jackpotOptIn()
108
+
109
+ > **jackpotOptIn**(`filter`): `Promise`\<[`JackpotsOptinResponse`](../interfaces/JackpotsOptinResponse.md)\>
110
+
111
+ Opts the authenticated user into a jackpot. From this point on, the user
112
+ contributes to the pot (per the template's `contribution_type` and
113
+ `contribution_value`) and is eligible to win when the pot explodes.
114
+
115
+ On success the SDK clears the jackpot caches — the next
116
+ [jackpotGet](#jackpotget) call returns the updated `is_opted_in: true` and an
117
+ incremented `registration_count`.
118
+
119
+ #### Parameters
120
+
121
+ ##### filter
122
+
123
+ ###### jp_template_id
124
+
125
+ `number`
126
+
127
+ ID of the jackpot template to join.
128
+
129
+ #### Returns
130
+
131
+ `Promise`\<[`JackpotsOptinResponse`](../interfaces/JackpotsOptinResponse.md)\>
132
+
133
+ [JackpotsOptinResponse](../interfaces/JackpotsOptinResponse.md) — `errCode === 0` on success.
134
+
135
+ #### Remarks
136
+
137
+ **Preconditions**
138
+ - User must be authenticated. Visitor mode not supported.
139
+ - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
140
+ - The jackpot must currently be active and the user must be in its
141
+ eligibility segment. Ineligible jackpots are filtered out of
142
+ [jackpotGet](#jackpotget) entirely, so a card the user sees is opt-in-able.
143
+
144
+ **Error handling**
145
+ The server returns a non-zero `errCode` with a human-readable `errMsg`
146
+ for any failure. Common causes:
147
+ - User is in a control group.
148
+ - Jackpot template is not active (status changed since the user opened
149
+ the card).
150
+ - User is already opted in (the SDK has no client-side guard against a
151
+ double-tap; the server enforces).
152
+ - DB race / generic server error.
153
+
154
+ The SDK does NOT enumerate distinct numeric codes for each cause — branch
155
+ on `errCode === 0` for success and surface `errMsg` as-is for failures.
156
+
157
+ **Idempotency / re-opt-in semantics**
158
+ - **Already opted in** → returns non-zero `errCode` ("User already opted in").
159
+ - **Previously opted in then opted out** → succeeds silently; the server
160
+ re-activates the registration. This is not an error path — a user can
161
+ freely cycle opt-in / opt-out.
162
+
163
+ **Refresh after success**
164
+ - The SDK clears the template, pot, and winners caches.
165
+ - The next [jackpotGet](#jackpotget) call returns `is_opted_in: true` for this
166
+ template.
167
+
168
+ **Side effects**
169
+ Fires a `JACKPOT_OPT_IN` engagement event (visible to operator-side
170
+ automation rules). Does NOT immediately move points / gems — contributions
171
+ happen per-bet via the user's gameplay, not on opt-in.
172
+
173
+ **Visitor mode**: not supported.
174
+
175
+ **UI guidance**: see [UI Guide — `jackpotOptIn`](../_media/UIGuide_jackpotOptIn.md).
176
+
177
+ #### Example
178
+
179
+ ```ts
180
+ const r = await window._smartico.api.jackpotOptIn({ jp_template_id: 42 });
181
+
182
+ if (r.errCode === 0) {
183
+ console.log('[smartico] opted in — refresh jackpot card to show opt-out CTA');
184
+ } else {
185
+ console.error('[smartico] opt-in failed — show this message in an error toast:', r.errMsg);
186
+ }
187
+ ```
188
+
189
+ ***
190
+
191
+ ### jackpotOptOut()
192
+
193
+ > **jackpotOptOut**(`filter`): `Promise`\<[`JackpotsOptoutResponse`](../interfaces/JackpotsOptoutResponse.md)\>
194
+
195
+ Opts the authenticated user out of a jackpot. From this point on the user
196
+ no longer contributes to the pot and is not eligible to win.
197
+
198
+ The user can re-join later via [jackpotOptIn](#jackpotoptin) — opt-out is not
199
+ permanent.
200
+
201
+ #### Parameters
202
+
203
+ ##### filter
204
+
205
+ ###### jp_template_id
206
+
207
+ `number`
208
+
209
+ ID of the jackpot template to leave.
210
+
211
+ #### Returns
212
+
213
+ `Promise`\<[`JackpotsOptoutResponse`](../interfaces/JackpotsOptoutResponse.md)\>
214
+
215
+ [JackpotsOptoutResponse](../interfaces/JackpotsOptoutResponse.md) — `errCode === 0` on success.
216
+
217
+ #### Remarks
218
+
219
+ **Preconditions**
220
+ - User must be authenticated. Visitor mode not supported.
221
+ - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
222
+
223
+ **Error handling**
224
+ The server returns a non-zero `errCode` with a human-readable `errMsg` for
225
+ any failure. Common causes:
226
+ - User has never opted in OR is already opted out — server returns
227
+ non-zero `errCode` for the "already opted out" case. Calling opt-out
228
+ on a jackpot the user has never registered for typically returns
229
+ success (the server finds no registration row to update).
230
+ - DB race / generic server error.
231
+
232
+ Unlike [jackpotOptIn](#jackpotoptin), opt-out does NOT check the template's status
233
+ — the user can opt out of a jackpot that has been deactivated by the
234
+ operator.
235
+
236
+ **Idempotency**
237
+ - First opt-out → success.
238
+ - Second opt-out → non-zero `errCode` ("Already opted out").
239
+ - Opt-out of a never-joined jackpot → typically succeeds silently
240
+ (no registration row to act on).
241
+
242
+ **Refresh after success**
243
+ - The SDK clears the template, pot, and winners caches.
244
+ - The next [jackpotGet](#jackpotget) call returns `is_opted_in: false` for this
245
+ template and a decremented `registration_count`.
246
+
247
+ **Side effects**
248
+ Fires a `JACKPOT_OPT_OUT` engagement event for operator-side automation
249
+ rules. The user's existing contributions to the current pot remain in
250
+ place — opt-out stops future contributions but does not refund past ones.
251
+
252
+ **Visitor mode**: not supported.
253
+
254
+ **UI guidance**: see [UI Guide — `jackpotOptOut`](../_media/UIGuide_jackpotOptOut.md).
255
+
256
+ #### Example
257
+
258
+ ```ts
259
+ const r = await window._smartico.api.jackpotOptOut({ jp_template_id: 42 });
260
+
261
+ if (r.errCode === 0) {
262
+ console.log('[smartico] opted out — refresh jackpot card to show join CTA');
263
+ } else {
264
+ console.error('[smartico] opt-out failed — show this message in an error toast:', r.errMsg);
265
+ }
266
+ ```
267
+
268
+ ***
269
+
270
+ ### getJackpotWinners()
271
+
272
+ > **getJackpotWinners**(`__namedParameters`): `Promise`\<[`JackpotWinnerHistory`](../interfaces/JackpotWinnerHistory.md)[]\>
273
+
274
+ Returns past winners of a specific jackpot template, paginated. Use to
275
+ power a "Recent winners" panel inside the jackpot detail modal.
276
+
277
+ **Important**: respect the `expose_winners_over_api` flag on the jackpot's
278
+ [JackpotDetails](../interfaces/JackpotDetails.md) before calling this method. The server-side handler
279
+ does NOT enforce that flag — it is a UI-only gate. Custom UIs that ignore
280
+ the flag will display winners the operator intended to keep private.
281
+
282
+ #### Parameters
283
+
284
+ ##### \_\_namedParameters
285
+
286
+ ###### limit?
287
+
288
+ `number`
289
+
290
+ Page size (default 20).
291
+
292
+ ###### offset?
293
+
294
+ `number`
295
+
296
+ Pagination offset (default 0).
297
+
298
+ ###### jp_template_id?
299
+
300
+ `number`
301
+
302
+ Jackpot template ID (required).
303
+
304
+ #### Returns
305
+
306
+ `Promise`\<[`JackpotWinnerHistory`](../interfaces/JackpotWinnerHistory.md)[]\>
307
+
308
+ Array of [JackpotWinnerHistory](../interfaces/JackpotWinnerHistory.md) entries newest-first.
309
+
310
+ #### Remarks
311
+
312
+ **Preconditions**
313
+ - User must be authenticated. Visitor mode not supported.
314
+ - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
315
+ - The consumer SHOULD check
316
+ [JackpotDetails.expose\_winners\_over\_api](../interfaces/JackpotDetails.md#expose_winners_over_api) before calling, since
317
+ the server does not enforce it.
318
+
319
+ **Pagination**
320
+ Server default page size is 20. Pass `limit` and `offset` to paginate
321
+ (e.g. infinite-scroll). The wire response carries a `has_more` flag, but
322
+ this SDK method returns only the `winners` array — detect end-of-list by
323
+ a returned array shorter than `limit`.
324
+
325
+ **Currency caveat**
326
+ Winner amounts in the response (`winner.winning_amount_jp_currency`) are
327
+ in the jackpot's NATIVE currency, NOT the user's wallet currency. If a
328
+ user-currency display is needed, the consumer must convert client-side.
329
+
330
+ **Refresh**
331
+ - The SDK caches per `jp_template_id` for 30 seconds.
332
+ - Caches clear on jackpot-win push events and on opt-in / opt-out.
333
+
334
+ **Error handling**
335
+ Non-zero `errCode` on control-group users or generic server errors. The
336
+ SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
337
+ surface `errMsg` on failure.
338
+
339
+ **Visitor mode**: not supported.
340
+
341
+ **UI guidance**: see [UI Guide — `getJackpotWinners`](../_media/UIGuide_getJackpotWinners.md).
342
+
343
+ #### Example
344
+
345
+ ```ts
346
+ const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
347
+
348
+ if (!jp || !jp.expose_winners_over_api) {
349
+ console.log('[smartico] winners hidden by operator config — hide the winners tab');
350
+ return;
351
+ }
352
+
353
+ const winners = await window._smartico.api.getJackpotWinners({
354
+ jp_template_id: 42,
355
+ limit: 20,
356
+ offset: 0,
357
+ });
358
+ console.log('[smartico] render', winners.length, 'recent winner rows (amounts in', jp.jp_currency + ')');
359
+ ```
360
+
361
+ ***
362
+
363
+ ### getJackpotEligibleGames()
364
+
365
+ > **getJackpotEligibleGames**(`__namedParameters`): `Promise`\<[`TGetJackpotEligibleGamesResponse`](../interfaces/TGetJackpotEligibleGamesResponse.md)\>
366
+
367
+ Returns the casino games eligible to contribute to a specific jackpot —
368
+ the catalog the user must play to grow the pot. Use to power an
369
+ "Eligible games" carousel inside the jackpot detail modal.
370
+
371
+ **Shortcut**: when the jackpot's
372
+ [JackpotDetails.ach\_related\_game\_allow\_all](../interfaces/JackpotDetails.md#ach_related_game_allow_all) flag is `true`, every
373
+ game in the operator catalog contributes — there's no point calling this
374
+ method (the result would be the full catalog). The default Smartico UI
375
+ hides the Eligible Games tab entirely in that case.
376
+
377
+ #### Parameters
378
+
379
+ ##### \_\_namedParameters
380
+
381
+ ###### jp_template_id
382
+
383
+ `number`
384
+
385
+ Jackpot template ID (required).
386
+
387
+ ###### onUpdate?
388
+
389
+ () => `void`
390
+
391
+ Optional callback; not auto-invoked today.
392
+
393
+ #### Returns
394
+
395
+ `Promise`\<[`TGetJackpotEligibleGamesResponse`](../interfaces/TGetJackpotEligibleGamesResponse.md)\>
396
+
397
+ [TGetJackpotEligibleGamesResponse](../interfaces/TGetJackpotEligibleGamesResponse.md) —
398
+ `{ eligible_games: JackpotEligibleGame[] }`.
399
+
400
+ #### Remarks
401
+
402
+ **Preconditions**
403
+ - User must be authenticated. Visitor mode not supported.
404
+ - `jp_template_id` is mandatory.
405
+
406
+ **`onUpdate` caveat**
407
+ The `onUpdate` callback is accepted to match the SDK's subscription
408
+ contract but is NOT auto-invoked by any current server push. It will only
409
+ fire if a consumer (or a future SDK version) explicitly pushes an update.
410
+ Treat it as a no-op for now.
411
+
412
+ **Refresh**
413
+ - The SDK caches per `jp_template_id` for 30 seconds.
414
+ - Cache does NOT clear on opt-in / opt-out / jackpot-win — eligible-game
415
+ lists rarely change during a session. Wait for the 30 s TTL.
416
+
417
+ **Error handling**
418
+ Non-zero `errCode` on control-group users or generic server errors.
419
+ Branch on `errCode === 0` and surface `errMsg` on failure.
420
+
421
+ **Visitor mode**: not supported.
422
+
423
+ **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../_media/UIGuide_getJackpotEligibleGames.md).
424
+
425
+ #### Example
426
+
427
+ ```ts
428
+ const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
429
+
430
+ if (jp?.ach_related_game_allow_all) {
431
+ console.log('[smartico] all games eligible — hide the eligible-games tab');
432
+ return;
433
+ }
434
+
435
+ const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
436
+ console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
437
+ ```
438
+
439
+ ***
@@ -0,0 +1,157 @@
1
+ # Class: WSAPILeaderBoard
2
+ ## Methods
3
+
4
+ ### getLeaderBoard()
5
+
6
+ > **getLeaderBoard**(`periodType`, `getPreviousPeriod?`): `Promise`\<[`LeaderBoardDetailsT`](../interfaces/LeaderBoardDetailsT.md)\>
7
+
8
+ Returns the operator-configured standalone leaderboard for the
9
+ given period type — top-20 ranked entries, the current user's
10
+ own entry (when authenticated), and the configured prize table.
11
+ Use this to power a leaderboard page with daily / weekly /
12
+ monthly tabs.
13
+
14
+ The leaderboard for each period type is configured separately by
15
+ the operator. A label may have any combination of DAILY, WEEKLY,
16
+ and MONTHLY boards configured (or none).
17
+
18
+ #### Parameters
19
+
20
+ ##### periodType
21
+
22
+ [`LeaderBoardPeriodType`](../enumerations/LeaderBoardPeriodType.md)
23
+
24
+ The board's period type
25
+ ([LeaderBoardPeriodType](../enumerations/LeaderBoardPeriodType.md)).
26
+ Selects which pre-configured board to
27
+ fetch; the board itself is bound to one
28
+ period by the operator.
29
+
30
+ ##### getPreviousPeriod?
31
+
32
+ `boolean`
33
+
34
+ When `true`, returns the most recent
35
+ finalized snapshot for that period type
36
+ (e.g. last week's results). Defaults to
37
+ `false` (current in-progress period).
38
+
39
+ #### Returns
40
+
41
+ `Promise`\<[`LeaderBoardDetailsT`](../interfaces/LeaderBoardDetailsT.md)\>
42
+
43
+ Promise resolving to `LeaderBoardDetailsT`.
44
+ **At runtime, may resolve to `undefined`**
45
+ when no board is configured for the
46
+ requested period type — guard against it.
47
+
48
+ #### Remarks
49
+
50
+ **Return value note** — the runtime may return `undefined` if no
51
+ board is configured for the requested `periodType`, despite the
52
+ static return type being `Promise<LeaderBoardDetailsT>`. Defend
53
+ against that case in consumer code.
54
+
55
+ **Preconditions**
56
+ Pass a `periodType` from [LeaderBoardPeriodType](../enumerations/LeaderBoardPeriodType.md)
57
+ (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
58
+ `getPreviousPeriod: true` to fetch the most-recently-ended
59
+ period's snapshot (yesterday's results, last week's results,
60
+ last month's results) instead of the current live period. The
61
+ SDK only exposes one period back — older snapshots are not
62
+ reachable through this method.
63
+
64
+ **Top-20 cap**
65
+ The server hard-caps `users[]` at 20 entries, ordered by
66
+ `position` ASC. Position values are server-computed (DENSE_RANK
67
+ over all participants); the truncation at 20 is for transport
68
+ size only — `position` may exceed 20 elsewhere.
69
+
70
+ **The `me` field**
71
+ Always populated for authenticated users (even when they have
72
+ zero points in the period). `me.position === -1` is the signal
73
+ that the user is active but ranked outside the top 20 (or has no
74
+ activity yet). `me` is `undefined` for visitor-mode sessions.
75
+
76
+ **Rewards are points only**
77
+ `rewards[].points` are gamification points credited to the user's
78
+ balance when the period finalizes. The leaderboard never awards
79
+ gems, diamonds, store items, or bonuses. The first element of
80
+ the array is the prize for place 1, the second for place 2, and
81
+ so on. The array length is the number of paid places.
82
+
83
+ **Cache TTL — single shared key (known limitation)**
84
+ The SDK caches the response for 30 seconds under a SINGLE shared
85
+ key — calling `getLeaderBoard(DAILY)` followed by
86
+ `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
87
+ cached DAILY result for the WEEKLY call. Same applies to
88
+ switching `getPreviousPeriod`. To force a fresh fetch when
89
+ switching periods or current/previous, call
90
+ `_smartico.api.clearCaches()` before the second call, or simply
91
+ wait out the TTL.
92
+
93
+ **Period boundaries**
94
+ The server finalizes each period on a server-configurable
95
+ schedule: DAILY at midnight + operator-defined offset; WEEKLY
96
+ at the start of Monday; MONTHLY on the 1st of each month. At
97
+ finalization, the server distributes the configured `rewards[]`
98
+ points to the top placeholders and resets the live board. After
99
+ finalization, `getLeaderBoard(periodType, false)` returns the
100
+ NEW (empty) period's board; call with
101
+ `getPreviousPeriod: true` to see the just-ended standings.
102
+
103
+ **Refresh model**
104
+ - One-shot fetch (no subscription).
105
+ - No push event refreshes the cache; finalization at the period
106
+ boundary is NOT pushed to the client.
107
+ - Poll manually if the consumer needs near-live state during an
108
+ in-progress period.
109
+
110
+ **Idempotency / Side effects**: safe. Read-only.
111
+
112
+ **UI guidance**: see [UI Guide — `getLeaderBoard`](../_media/UIGuide_getLeaderBoard.md).
113
+
114
+ **Visitor mode**: supported. The same shape is returned, scoped
115
+ to the brand's public leaderboard. `me` is `undefined` for
116
+ visitors.
117
+
118
+ #### Example
119
+
120
+ ```ts
121
+ import { LeaderBoardPeriodType } from '@smartico/public-api';
122
+
123
+ const board = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY);
124
+
125
+ if (!board) {
126
+ console.log('[smartico] no weekly board configured for this label — hide the leaderboard surface');
127
+ return;
128
+ }
129
+
130
+ console.log('[smartico] render leaderboard tab —', board.name, '—', board.users.length, 'ranked entries (top 20 max)');
131
+
132
+ // Render prize table.
133
+ for (const reward of board.rewards) {
134
+ console.log('[smartico] prize row — place', reward.place, '→', reward.points, 'points');
135
+ }
136
+
137
+ // "Me" panel — sticky row showing the current user's rank.
138
+ if (board.me) {
139
+ if (board.me.position === -1) {
140
+ console.log('[smartico] user is unranked — show "You are unranked, earn points to enter the leaderboard"');
141
+ } else if (board.me.position > 20) {
142
+ console.log('[smartico] user is ranked', board.me.position, 'but outside the visible top-20 — show sticky "me" row with', board.me.points, 'points');
143
+ } else {
144
+ console.log('[smartico] user is in the top 20 at position', board.me.position, '— highlight their row in the main list');
145
+ }
146
+ }
147
+
148
+ // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
149
+ await window._smartico.api.clearCaches();
150
+ const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
151
+ console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
152
+
153
+ // Visitor-mode equivalent — me is always undefined.
154
+ // const visitorBoard = await window._smartico.vapi('EN').getLeaderBoard(LeaderBoardPeriodType.DAILY);
155
+ ```
156
+
157
+ ***