@smartico/public-api 0.0.380 → 0.0.382

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 (178) hide show
  1. package/CLAUDE.md +103 -0
  2. package/README.md +32 -10
  3. package/dist/Base/ClassId.d.ts +2 -0
  4. package/dist/Jackpots/JackpotDetails.d.ts +14 -15
  5. package/dist/Jackpots/JackpotPot.d.ts +10 -6
  6. package/dist/MiniGames/SAWGameType.d.ts +3 -1
  7. package/dist/MiniGames/SAWTemplateUI.d.ts +7 -0
  8. package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
  9. package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
  10. package/dist/Raffle/index.d.ts +2 -0
  11. package/dist/SmarticoAPI.d.ts +6 -1
  12. package/dist/SmarticoLib/index.d.ts +5 -1
  13. package/dist/WSAPI/WSAPIAvatars.d.ts +267 -49
  14. package/dist/WSAPI/WSAPIBonuses.d.ts +224 -10
  15. package/dist/WSAPI/WSAPIGamePick.d.ts +538 -253
  16. package/dist/WSAPI/WSAPIGeneral.d.ts +156 -14
  17. package/dist/WSAPI/WSAPIInbox.d.ts +547 -58
  18. package/dist/WSAPI/WSAPIJackpots.d.ts +292 -57
  19. package/dist/WSAPI/WSAPILeaderBoard.d.ts +127 -13
  20. package/dist/WSAPI/WSAPIMiniGames.d.ts +465 -49
  21. package/dist/WSAPI/WSAPIRaffles.d.ts +576 -52
  22. package/dist/WSAPI/WSAPITournaments.d.ts +3 -3
  23. package/dist/WSAPI/WSAPITypes.d.ts +243 -132
  24. package/dist/WSAPI/WSAPIUser.d.ts +193 -43
  25. package/dist/index.js +3412 -616
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.modern.mjs +3395 -609
  28. package/dist/index.modern.mjs.map +1 -1
  29. package/docs/Callbacks.md +162 -0
  30. package/docs/SmarticoObject.md +445 -0
  31. package/docs/Transforms.md +99 -0
  32. package/docs/api/README.md +26 -0
  33. package/docs/api/classes/WSAPIAvatars.md +282 -54
  34. package/docs/api/classes/WSAPIBonuses.md +233 -12
  35. package/docs/api/classes/WSAPIClans.md +380 -10
  36. package/docs/api/classes/WSAPIGamePick.md +555 -26
  37. package/docs/api/classes/WSAPIGeneral.md +165 -16
  38. package/docs/api/classes/WSAPIInbox.md +588 -64
  39. package/docs/api/classes/WSAPIJackpots.md +320 -66
  40. package/docs/api/classes/WSAPILeaderBoard.md +133 -15
  41. package/docs/api/classes/WSAPIMiniGames.md +501 -64
  42. package/docs/api/classes/WSAPIMissions.md +58 -79
  43. package/docs/api/classes/WSAPIRaffles.md +647 -69
  44. package/docs/api/classes/WSAPIStore.md +83 -108
  45. package/docs/api/classes/WSAPITournaments.md +495 -28
  46. package/docs/api/classes/WSAPIUser.md +520 -83
  47. package/docs/api/documents/Callbacks.md +162 -0
  48. package/docs/api/documents/SmarticoObject.md +445 -0
  49. package/docs/api/documents/Transforms.md +99 -0
  50. package/docs/api/enumerations/BonusStatus-1.md +11 -6
  51. package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
  52. package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
  53. package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
  54. package/docs/api/interfaces/AvatarCustomized.md +25 -0
  55. package/docs/api/interfaces/AvatarDefinition.md +94 -0
  56. package/docs/api/interfaces/AvatarPrompt.md +45 -0
  57. package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
  58. package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
  59. package/docs/api/interfaces/Clan.md +4 -0
  60. package/docs/api/interfaces/ClanInfo.md +109 -0
  61. package/docs/api/interfaces/ClanMember.md +53 -0
  62. package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
  63. package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
  64. package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
  65. package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
  66. package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
  67. package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
  68. package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
  69. package/docs/api/interfaces/JackpotDetails.md +14 -15
  70. package/docs/api/interfaces/JackpotPot.md +9 -6
  71. package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
  72. package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
  73. package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
  74. package/docs/api/interfaces/PointsLog.md +43 -0
  75. package/docs/api/interfaces/RaffleWonPrize.md +59 -0
  76. package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
  77. package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
  78. package/docs/api/interfaces/TAchCategory.md +2 -7
  79. package/docs/api/interfaces/TAvatarCustomized.md +4 -4
  80. package/docs/api/interfaces/TAvatarDefinition.md +13 -14
  81. package/docs/api/interfaces/TAvatarPrompt.md +6 -6
  82. package/docs/api/interfaces/TBonus.md +16 -8
  83. package/docs/api/interfaces/TBuyStoreItemResult.md +4 -29
  84. package/docs/api/interfaces/TClaimBonusResult.md +5 -5
  85. package/docs/api/interfaces/TClan.md +8 -4
  86. package/docs/api/interfaces/TClanInfo.md +47 -0
  87. package/docs/api/interfaces/TClanJoinResult.md +11 -1
  88. package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
  89. package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
  90. package/docs/api/interfaces/TClans.md +3 -1
  91. package/docs/api/interfaces/TGetTranslations.md +4 -0
  92. package/docs/api/interfaces/TInboxMessage.md +14 -6
  93. package/docs/api/interfaces/TInboxMessageBody.md +18 -12
  94. package/docs/api/interfaces/TLevel.md +17 -20
  95. package/docs/api/interfaces/TLevelCurrent.md +19 -18
  96. package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
  97. package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
  98. package/docs/api/interfaces/TMissionClaimRewardResult.md +1 -9
  99. package/docs/api/interfaces/TMissionOptInResult.md +1 -5
  100. package/docs/api/interfaces/TMissionOrBadge.md +4 -7
  101. package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
  102. package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
  103. package/docs/api/interfaces/TSetAvatarResult.md +3 -3
  104. package/docs/api/interfaces/TStoreItem.md +3 -13
  105. package/docs/api/interfaces/TTournament.md +1 -1
  106. package/docs/api/interfaces/TTournamentDetailed.md +1 -1
  107. package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
  108. package/docs/api/interfaces/TUICustomSection.md +23 -19
  109. package/docs/api/interfaces/TUserProfile.md +18 -16
  110. package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
  111. package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
  112. package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
  113. package/docs/native/ADDING_METHODS.md +7 -2
  114. package/docs/native/PROTOCOL.md +337 -0
  115. package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
  116. package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
  117. package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
  118. package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
  119. package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
  120. package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
  121. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
  122. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
  123. package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
  124. package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
  125. package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
  126. package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
  127. package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
  128. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
  129. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
  130. package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
  131. package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
  132. package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
  133. package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
  134. package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
  135. package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
  136. package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
  137. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
  138. package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
  139. package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
  140. package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
  141. package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
  142. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
  143. package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
  144. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
  145. package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
  146. package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
  147. package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
  148. package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
  149. package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
  150. package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
  151. package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
  152. package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
  153. package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
  154. package/docs/ui/user/UIGuide_getLevels.md +47 -42
  155. package/package.json +1 -1
  156. package/src/Base/ClassId.ts +2 -0
  157. package/src/Jackpots/JackpotDetails.ts +14 -15
  158. package/src/Jackpots/JackpotPot.ts +10 -6
  159. package/src/MiniGames/SAWGameType.ts +3 -0
  160. package/src/MiniGames/SAWTemplateUI.ts +10 -0
  161. package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
  162. package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
  163. package/src/Raffle/index.ts +3 -1
  164. package/src/SmarticoAPI.ts +14 -1
  165. package/src/SmarticoLib/index.ts +4 -0
  166. package/src/WSAPI/WSAPIAvatars.ts +267 -49
  167. package/src/WSAPI/WSAPIBonuses.ts +224 -10
  168. package/src/WSAPI/WSAPIGamePick.ts +538 -253
  169. package/src/WSAPI/WSAPIGeneral.ts +156 -14
  170. package/src/WSAPI/WSAPIInbox.ts +545 -56
  171. package/src/WSAPI/WSAPIJackpots.ts +297 -61
  172. package/src/WSAPI/WSAPILeaderBoard.ts +127 -13
  173. package/src/WSAPI/WSAPIMiniGames.ts +465 -49
  174. package/src/WSAPI/WSAPIRaffles.ts +592 -64
  175. package/src/WSAPI/WSAPITournaments.ts +3 -3
  176. package/src/WSAPI/WSAPITypes.ts +243 -132
  177. package/src/WSAPI/WSAPIUser.ts +193 -43
  178. package/tsconfig.json +9 -1
@@ -5,58 +5,116 @@
5
5
 
6
6
  > **jackpotGet**(`filter?`): `Promise`\<[`JackpotDetails`](../interfaces/JackpotDetails.md)[]\>
7
7
 
8
- Returns list of Jackpots that are active in the system and matching to the filter definition.
9
- If filter is not provided, all active jackpots will be returned.
10
- Filter can be used to get jackpots related to specific game or specific jackpot template.
11
- You can call this method every second in order to get up to date information about current value of the jackpot(s) and present them to the end-users
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.
12
11
 
13
- **Example**:
14
- ```
15
- _smartico.api.jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
16
- console.log(result);
17
- });
18
- ```
19
-
20
- **Example in the Visitor mode**:
21
- ```
22
- _smartico.vapi('EN').jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
23
- console.log(result);
24
- });
25
- ```
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.
26
16
 
27
17
  #### Parameters
28
18
 
29
19
  ##### filter?
30
20
 
21
+ Optional filter narrowing the result set.
22
+
31
23
  ###### related_game_id?
32
24
 
33
25
  `string`
34
26
 
27
+ Limit to jackpots linked to this game ID
28
+ (from the operator's games catalog).
29
+
35
30
  ###### jp_template_id?
36
31
 
37
32
  `number`
38
33
 
34
+ Limit to a single template.
35
+
39
36
  #### Returns
40
37
 
41
38
  `Promise`\<[`JackpotDetails`](../interfaces/JackpotDetails.md)[]\>
42
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
+
43
105
  ***
44
106
 
45
107
  ### jackpotOptIn()
46
108
 
47
109
  > **jackpotOptIn**(`filter`): `Promise`\<[`JackpotsOptinResponse`](../interfaces/JackpotsOptinResponse.md)\>
48
110
 
49
- Opt-in currently logged in user to the jackpot with the specified jp_template_id.
50
- You may call jackpotGet method after doing optin to see that user is opted in to the jackpot.
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.
51
114
 
52
- **Example**:
53
- ```
54
- _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
55
- console.log('Opted in to the jackpot');
56
- });
57
- ```
58
-
59
- **Visitor mode: not supported**
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`.
60
118
 
61
119
  #### Parameters
62
120
 
@@ -66,27 +124,79 @@ _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
66
124
 
67
125
  `number`
68
126
 
127
+ ID of the jackpot template to join.
128
+
69
129
  #### Returns
70
130
 
71
131
  `Promise`\<[`JackpotsOptinResponse`](../interfaces/JackpotsOptinResponse.md)\>
72
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
+
73
189
  ***
74
190
 
75
191
  ### jackpotOptOut()
76
192
 
77
193
  > **jackpotOptOut**(`filter`): `Promise`\<[`JackpotsOptoutResponse`](../interfaces/JackpotsOptoutResponse.md)\>
78
194
 
79
- Opt-out currently logged in user from the jackpot with the specified jp_template_id.
80
- You may call jackpotGet method after doing optout to see that user is not opted in to the jackpot.
81
-
82
- **Example**:
83
- ```
84
- _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
85
- console.log('Opted out from the jackpot');
86
- });
87
- ```
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.
88
197
 
89
- **Visitor mode: not supported**
198
+ The user can re-join later via [jackpotOptIn](#jackpotoptin) — opt-out is not
199
+ permanent.
90
200
 
91
201
  #### Parameters
92
202
 
@@ -96,75 +206,173 @@ _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
96
206
 
97
207
  `number`
98
208
 
209
+ ID of the jackpot template to leave.
210
+
99
211
  #### Returns
100
212
 
101
213
  `Promise`\<[`JackpotsOptoutResponse`](../interfaces/JackpotsOptoutResponse.md)\>
102
214
 
103
- ***
215
+ [JackpotsOptoutResponse](../interfaces/JackpotsOptoutResponse.md) — `errCode === 0` on success.
104
216
 
105
- ### getJackpotWinners()
217
+ #### Remarks
106
218
 
107
- > **getJackpotWinners**(`params`): `Promise`\<[`JackpotWinnerHistory`](../interfaces/JackpotWinnerHistory.md)[]\>
219
+ **Preconditions**
220
+ - User must be authenticated. Visitor mode not supported.
221
+ - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
108
222
 
109
- Returns jackpot winners for the given `jp_template_id` (paginated on the server).
110
- Default page size on the wire is 20; use `limit`, `offset`, and repeated calls to load more.
111
- The full protocol response also includes `has_more`; this method returns only the `winners` array.
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.
112
231
 
113
- **Example**:
114
- ```
115
- _smartico.api.getJackpotWinners({
116
- jp_template_id: 123,
117
- }).then((result) => {
118
- console.log(result);
119
- });
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
+ }
120
266
  ```
121
267
 
122
- **Visitor mode: not supported**
268
+ ***
123
269
 
124
- #### Parameters
270
+ ### getJackpotWinners()
125
271
 
126
- ##### params
272
+ > **getJackpotWinners**(`__namedParameters`): `Promise`\<[`JackpotWinnerHistory`](../interfaces/JackpotWinnerHistory.md)[]\>
127
273
 
128
- Jackpot winners parameters
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
129
285
 
130
286
  ###### limit?
131
287
 
132
288
  `number`
133
289
 
134
- Page size (server default 20 when omitted)
290
+ Page size (default 20).
135
291
 
136
292
  ###### offset?
137
293
 
138
294
  `number`
139
295
 
140
- Offset into the winner list
296
+ Pagination offset (default 0).
141
297
 
142
298
  ###### jp_template_id?
143
299
 
144
300
  `number`
145
301
 
146
- Jackpot template id (required; throws if missing)
302
+ Jackpot template ID (required).
147
303
 
148
304
  #### Returns
149
305
 
150
306
  `Promise`\<[`JackpotWinnerHistory`](../interfaces/JackpotWinnerHistory.md)[]\>
151
307
 
152
- ***
308
+ Array of [JackpotWinnerHistory](../interfaces/JackpotWinnerHistory.md) entries newest-first.
153
309
 
154
- ### getJackpotEligibleGames()
310
+ #### Remarks
155
311
 
156
- > **getJackpotEligibleGames**(`__namedParameters`): `Promise`\<[`TGetJackpotEligibleGamesResponse`](../interfaces/TGetJackpotEligibleGamesResponse.md)\>
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.
157
318
 
158
- Returns the eligible games for the jackpot with the specified jp_template_id.
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`.
159
324
 
160
- **Example**:
161
- ```
162
- _smartico.api.getJackpotEligibleGames({ jp_template_id: 123 }).then((result) => {
163
- console.log(result);
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,
164
357
  });
358
+ console.log('[smartico] render', winners.length, 'recent winner rows (amounts in', jp.jp_currency + ')');
165
359
  ```
166
360
 
167
- **Visitor mode: not supported**
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.
168
376
 
169
377
  #### Parameters
170
378
 
@@ -174,12 +382,58 @@ _smartico.api.getJackpotEligibleGames({ jp_template_id: 123 }).then((result) =>
174
382
 
175
383
  `number`
176
384
 
385
+ Jackpot template ID (required).
386
+
177
387
  ###### onUpdate?
178
388
 
179
389
  () => `void`
180
390
 
391
+ Optional callback; not auto-invoked today.
392
+
181
393
  #### Returns
182
394
 
183
395
  `Promise`\<[`TGetJackpotEligibleGamesResponse`](../interfaces/TGetJackpotEligibleGamesResponse.md)\>
184
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
+
185
439
  ***
@@ -5,22 +5,15 @@
5
5
 
6
6
  > **getLeaderBoard**(`periodType`, `getPreviousPeriod?`): `Promise`\<[`LeaderBoardDetailsT`](../interfaces/LeaderBoardDetailsT.md)\>
7
7
 
8
- Returns the leaderboard for the current type (default is Daily). If getPreviousPeriod is passed as true, a leaderboard for the previous period for the current type will be returned.
9
- For example, if the type is Weekly and getPreviousPeriod is true, a leaderboard for the previous week will be returned.
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.
10
13
 
11
- **Example**:
12
- ```
13
- _smartico.api.getLeaderBoard(1).then((result) => {
14
- console.log(result);
15
- });
16
- ```
17
-
18
- **Example in the Visitor mode**:
19
- ```
20
- _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
21
- console.log(result);
22
- });
23
- ```
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).
24
17
 
25
18
  #### Parameters
26
19
 
@@ -28,12 +21,137 @@ _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
28
21
 
29
22
  [`LeaderBoardPeriodType`](../enumerations/LeaderBoardPeriodType.md)
30
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
+
31
30
  ##### getPreviousPeriod?
32
31
 
33
32
  `boolean`
34
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
+
35
39
  #### Returns
36
40
 
37
41
  `Promise`\<[`LeaderBoardDetailsT`](../interfaces/LeaderBoardDetailsT.md)\>
38
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
+
39
157
  ***