@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,612 @@
1
+ # Class: WSAPIMiniGames
2
+ ## Methods
3
+
4
+ ### getMiniGames()
5
+
6
+ > **getMiniGames**(`params?`): `Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
7
+
8
+ Returns all mini-game templates ("SAW" = Spin And Win — the
9
+ umbrella term for wheel-spin, scratch-card, lootbox, gift-box,
10
+ treasure-hunt, plinko, coin-flip, quiz, and several other formats)
11
+ configured for the label. Optionally subscribes to live updates
12
+ via `onUpdate`: the callback fires whenever the user's
13
+ `spin_count` changes, jackpot grows, a manual spin is issued, or
14
+ a spin response lands.
15
+
16
+ The list is NOT filtered by spin availability — every configured
17
+ template is returned, including ones the user cannot currently
18
+ play. The `visibile_when_can_spin` flag on each template hints
19
+ which to hide in a default lobby view (consumer-side filter).
20
+
21
+ #### Parameters
22
+
23
+ ##### params?
24
+
25
+ Optional. Omit to fetch without subscribing.
26
+
27
+ ###### onUpdate?
28
+
29
+ (`data`) => `void`
30
+
31
+ Callback invoked with the full refreshed
32
+ template array after any spin-count
33
+ change, spin response, or acknowledge
34
+ response on this connection.
35
+
36
+ #### Returns
37
+
38
+ `Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
39
+
40
+ Promise resolving to the template
41
+ array. Empty if no templates are
42
+ visible to the user.
43
+
44
+ #### Remarks
45
+
46
+ **Subscription model (`onUpdate`)**
47
+ The callback receives the FULL refreshed template list (never a
48
+ diff/patch). Each subsequent call to `getMiniGames({ onUpdate })`
49
+ REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
50
+ it) to keep the prior callback in place; the callback is never
51
+ auto-cleared.
52
+
53
+ **Update triggers** — the callback fires when:
54
+
55
+ 1. The server pushes a `spin_count` change (campaign award,
56
+ store purchase, BO manual issuance, mission reward).
57
+ 2. Any [playMiniGame](#playminigame) or [playMiniGameBatch](#playminigamebatch)
58
+ resolves on this connection — the cached array refreshes
59
+ with updated `spin_count`, `jackpot_current`, and any new
60
+ `next_available_spin_ts`.
61
+ 3. Acknowledge responses land (via auto-acknowledge or
62
+ [miniGameWinAcknowledgeRequest](#minigamewinacknowledgerequest)).
63
+
64
+ Jackpot growth is observable on the refreshed `jackpot_current`
65
+ field — the SDK inlines the live value into template `name` /
66
+ `promo_text` / prize `name` via a `{{jackpot}}` template
67
+ substitution at fetch time.
68
+
69
+ **Game-type variants**
70
+ All twelve `SAWGameType` values (`SpinAWheel`, `ScratchCard`,
71
+ `MatchX`, `GiftBox`, `PrizeDrop`, `Quiz`, `LootboxWeekdays`,
72
+ `LootboxCalendarDays`, `TreasureHunt`, `Voyager`, `Plinko`,
73
+ `CoinFlip`) surface through the same template shape. Most are
74
+ played via [playMiniGame](#playminigame); the exceptions are:
75
+ - `PrizeDrop` — server-push only; the consumer does NOT call
76
+ `playMiniGame`. Prizes arrive via the prize-drop push channel.
77
+ - `MatchX` / `Quiz` — predictions are submitted via a separate
78
+ games server (not this SDK); the SAW spin is fired
79
+ server-internally to deduct the buy-in.
80
+
81
+ **Cache TTL**: the SDK caches the response for 30 seconds. Cache
82
+ is fully cleared on login / logout.
83
+
84
+ **Idempotency / Side effects**: safe. Read-only.
85
+
86
+ **UI guidance**: see [UI Guide — `getMiniGames`](../_media/UIGuide_getMiniGames.md).
87
+
88
+ **Visitor mode**: supported. Only templates configured with
89
+ `is_visitor_mode = true` in the BO are returned for anonymous
90
+ sessions. Spins from these templates may also be played (visitor
91
+ mode is the one mini-game flow that does support play — see
92
+ [playMiniGame](#playminigame) for the visitor-stop semantics).
93
+
94
+ #### Example
95
+
96
+ ```ts
97
+ const games = await window._smartico.api.getMiniGames({
98
+ onUpdate: (refreshed) => {
99
+ console.log('[smartico] mini-game templates refreshed — re-render lobby from this array:', refreshed);
100
+ },
101
+ });
102
+
103
+ // Filter the lobby view per the visibility flag.
104
+ const visible = games.filter(g =>
105
+ !g.visibile_when_can_spin || (g.spin_count && g.spin_count > 0)
106
+ );
107
+
108
+ for (const g of visible) {
109
+ console.log('[smartico] render game card', g.id, '—', g.name,
110
+ '— type:', g.saw_game_type,
111
+ '— buy-in:', g.saw_buyin_type,
112
+ '— spins available:', g.spin_count ?? 0,
113
+ '— jackpot:', g.jackpot_current, g.jackpot_symbol);
114
+ }
115
+ ```
116
+
117
+ ***
118
+
119
+ ### getMiniGamesHistory()
120
+
121
+ > **getMiniGamesHistory**(`params`): `Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
122
+
123
+ Returns a paginated, newest-first list of the user's past
124
+ mini-game spins — each row carries the won prize ID, the
125
+ client-side `request_id` used for the spin, and a
126
+ server-recorded `is_claimed` flag (`true` if the spin has been
127
+ acknowledged). Optionally filter to a single template via
128
+ `saw_template_id`.
129
+
130
+ Use this to power a "My prizes" / win-history surface, or to
131
+ recover unacknowledged spins (rows with `is_claimed === false`
132
+ carry a `client_request_id` you can pass to
133
+ [miniGameWinAcknowledgeRequest](#minigamewinacknowledgerequest)).
134
+
135
+ #### Parameters
136
+
137
+ ##### params
138
+
139
+ Optional pagination + filter bag.
140
+
141
+ ###### limit?
142
+
143
+ `number`
144
+
145
+ Page size. Defaults to 20.
146
+
147
+ ###### offset?
148
+
149
+ `number`
150
+
151
+ Number of rows to skip. Defaults to 0.
152
+
153
+ ###### saw_template_id?
154
+
155
+ `number`
156
+
157
+ When set, scopes the history to
158
+ a single template's spins.
159
+
160
+ #### Returns
161
+
162
+ `Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
163
+
164
+ Promise resolving to `TSawHistory[]` in newest-first
165
+ order. Empty when the user has no history.
166
+
167
+ #### Remarks
168
+
169
+ **Pagination**
170
+ `limit` defaults to 20, `offset` defaults to 0. Sort order is
171
+ `create_date` DESC (newest first) — no client-side re-sort
172
+ required. For "load more" pagination, advance `offset` by the
173
+ page size on each subsequent call.
174
+
175
+ The underlying protocol carries a `hasMore` boolean on the
176
+ response, but the SDK strips it from the public surface —
177
+ detect end of list when the returned array length is less than
178
+ `limit`.
179
+
180
+ **`is_claimed` semantics**
181
+ Maps directly to the server's "acknowledge_date is non-null"
182
+ state. A spin where the auto-acknowledge fire-and-forget
183
+ succeeded shows `is_claimed: true`; a spin where the
184
+ acknowledge was lost (network drop) or where the user is on an
185
+ explicit-acknowledge flow shows `is_claimed: false` with a
186
+ usable `client_request_id`. A server-side fallback job
187
+ auto-acknowledges stale rows every ~60 seconds — so even
188
+ "lost" prizes are eventually delivered without consumer action.
189
+
190
+ **Cache TTL**: the SDK caches the response for 30 seconds.
191
+ Cache is invalidated implicitly when a new spin or acknowledge
192
+ response lands.
193
+
194
+ **Idempotency / Side effects**: safe. Read-only.
195
+
196
+ **UI guidance**: see [UI Guide — `getMiniGamesHistory`](../_media/UIGuide_getMiniGamesHistory.md).
197
+
198
+ **Visitor mode**: not supported.
199
+
200
+ #### Example
201
+
202
+ ```ts
203
+ const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
204
+
205
+ // Show unacknowledged spins with a Claim CTA.
206
+ const unacknowledged = history.filter(h => !h.is_claimed);
207
+ console.log('[smartico] surface a "Claim" CTA on these', unacknowledged.length, 'history rows:',
208
+ unacknowledged.map(h => h.client_request_id));
209
+
210
+ // Load-more pagination — advance offset by the prior page size.
211
+ const page2 = await window._smartico.api.getMiniGamesHistory({ limit: 20, offset: 20 });
212
+ console.log('[smartico] page 2 loaded —', page2.length, 'more rows;',
213
+ page2.length < 20 ? 'end of list reached, hide "Load more"' : 'keep "Load more" visible');
214
+ ```
215
+
216
+ ***
217
+
218
+ ### playMiniGame()
219
+
220
+ > **playMiniGame**(`template_id`, `params?`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
221
+
222
+ Plays one round of a mini-game template — runs the server's
223
+ randomised prize selection, deducts the buy-in cost (if any),
224
+ and returns the won `prize_id`. After the play resolves, the SDK
225
+ automatically fires a server-side acknowledgement on a
226
+ fire-and-forget basis, marking the spin as "delivered" so the
227
+ prize takes effect.
228
+
229
+ Works for all `SAWGameType` values EXCEPT:
230
+ - `PrizeDrop` — prizes arrive server-pushed; do NOT call
231
+ `playMiniGame` for this type.
232
+ - `MatchX` / `Quiz` — prediction submission goes through a
233
+ separate games server; `playMiniGame` is not the entry point.
234
+
235
+ #### Parameters
236
+
237
+ ##### template\_id
238
+
239
+ `number`
240
+
241
+ The mini-game template ID (from
242
+ `TMiniGameTemplate.id`).
243
+
244
+ ##### params?
245
+
246
+ Optional. Pass an `onUpdate` callback to
247
+ subscribe to subsequent template refreshes.
248
+
249
+ ###### onUpdate?
250
+
251
+ (`data`) => `void`
252
+
253
+ #### Returns
254
+
255
+ `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
256
+
257
+ `{ err_code, err_message, prize_id }` — success when
258
+ `err_code === 0`. `prize_id` is always populated; look
259
+ it up in `template.prizes` to interpret the prize.
260
+
261
+ #### Remarks
262
+
263
+ **Preconditions**
264
+ Read the candidate template from [getMiniGames](#getminigames) and check:
265
+ - `spin_count > 0` for spin-based templates
266
+ (`saw_buyin_type === 'spins'`).
267
+ - Sufficient balance for paid templates — points / gems /
268
+ diamonds from [getUserProfile](WSAPIUser.md#getuserprofile) against
269
+ `buyin_cost_points` / `_gems` / `_diamonds`.
270
+ - `next_available_spin_ts` is in the past (or unset) — the
271
+ server enforces a per-period max-attempts cap.
272
+ - Template is currently in its active period
273
+ (operator-configured `activeFromDate` / `activeTillDate`).
274
+
275
+ **Error codes** (in `err_code`, typed as [SAWSpinErrorCode](../enumerations/SAWSpinErrorCode.md))
276
+ - `0` (`SAW_OK`) — success; `prize_id` identifies the won prize
277
+ in `template.prizes`.
278
+ - `40001` (`SAW_NO_SPINS`) — user has no spin attempts for a
279
+ spin-based template.
280
+ - `40002` (`SAW_PRIZE_POOL_EMPTY`) — all prize slots in the
281
+ template are depleted.
282
+ - `40003` (`SAW_NOT_ENOUGH_POINTS`) — insufficient points for a
283
+ points-cost template.
284
+ - `40004` (`SAW_FAILED_MAX_SPINS_REACHED`) — per-period
285
+ max-attempts cap reached. The server's
286
+ `first_spin_in_period` value (exposed in
287
+ [TMiniGamePlayBatchResult](../interfaces/TMiniGamePlayBatchResult.md); not surfaced in the single
288
+ `TMiniGamePlayResult`) marks the period start.
289
+ - `40007` (`SAW_TEMPLATE_NOT_ACTIVE`) — template outside its
290
+ active time window.
291
+ - `40009` (`SAW_NOT_IN_SEGMENT`) — user fails the template's
292
+ visibility segment check, OR (for lootbox variants) the day's
293
+ prize pool is empty.
294
+ - `40011` (`SAW_NO_BALANCE_GEMS`) — insufficient gems.
295
+ - `40012` (`SAW_NO_BALANCE_DIAMONDS`) — insufficient diamonds.
296
+ - `-40001` (`SAW_VISITOR_STOP_SPIN_REQUEST`) — visitor session
297
+ tried to play a non-visitor-mode template. The default UI
298
+ silently stops the game; no prize awarded.
299
+ - other non-zero — generic server error. Surface `err_message`.
300
+
301
+ **Prize handling**
302
+ On `err_code === 0`, `prize_id` matches an entry in
303
+ `template.prizes`. Look up the prize's `prize_type`
304
+ ([MiniGamePrizeTypeName](../enumerations/MiniGamePrizeTypeName.md)) to decide UI treatment:
305
+ - `'no-prize'` — the user spun but won nothing (an operator-
306
+ configured "loss" slot). Buy-in is still deducted.
307
+ - `'points'` / `'gems-and-diamonds'` / `'spin'` — value
308
+ credited to the user's profile / spin balance; visible on
309
+ the next refresh.
310
+ - `'bonus'` — surfaces via [getBonuses](#getbonuses).
311
+ - `'jackpot'` — drains the template's `jackpot_current` to the
312
+ user; resets the accumulator.
313
+ - `'raffle-ticket'` — adds tickets to the relevant raffle.
314
+ - `'mission'` / `'change-level'` — visible via the
315
+ corresponding domain methods.
316
+ - `'manual'` — operator delivers offline.
317
+
318
+ **Auto-acknowledge**
319
+ The SDK calls the server's acknowledge endpoint immediately
320
+ after the spin response, on a fire-and-forget basis (not
321
+ awaited). This marks the spin as "delivered" so prize effects
322
+ take hold. If the auto-acknowledge fails (network drop), the
323
+ spin appears as `is_claimed: false` in
324
+ [getMiniGamesHistory](#getminigameshistory); the consumer can recover it by
325
+ passing the `client_request_id` to
326
+ [miniGameWinAcknowledgeRequest](#minigamewinacknowledgerequest). A server-side fallback
327
+ job auto-acknowledges stale spins every ~60 seconds, so prizes
328
+ are eventually delivered even without consumer action.
329
+
330
+ **Idempotency**: NOT idempotent. A double-click sends two
331
+ spins and deducts the buy-in twice. The SDK does NOT guard
332
+ against rapid clicks at the public API level — guard the call
333
+ site with an in-flight flag. The server enforces a per-user
334
+ per-template lock that serialises concurrent requests, so two
335
+ simultaneous calls won't be processed in parallel, but they
336
+ will both be processed sequentially (i.e. both deduct).
337
+
338
+ **Refresh after success (and after failure)**
339
+ The SDK automatically refreshes the templates cache on every
340
+ spin response and fires any `onUpdate` callback registered via
341
+ [getMiniGames](#getminigames) or this method. After `err_code === 0`, the
342
+ affected template's `spin_count` / `jackpot_current` /
343
+ `next_available_spin_ts` reflect the new state on the
344
+ refreshed array.
345
+
346
+ **Side effects** (on `err_code === 0`)
347
+ - Buy-in deducted from the user's balance (points / gems /
348
+ diamonds / spin tickets — depending on `saw_buyin_type`).
349
+ Balance updates flow via the user-properties channel
350
+ (subscribe to [getUserProfile](WSAPIUser.md#getuserprofile) `props_change` to
351
+ observe).
352
+ - Prize value credited per the prize's type (see "Prize
353
+ handling" above).
354
+ - A `minigame_attempt` analytics event fires server-side with
355
+ the result status.
356
+
357
+ **UI guidance**: see [UI Guide — `playMiniGame`](../_media/UIGuide_playMiniGame.md).
358
+
359
+ **Visitor mode**: not supported. Visitor sessions trying to
360
+ spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
361
+
362
+ #### Example
363
+
364
+ ```ts
365
+ const games = await window._smartico.api.getMiniGames({
366
+ onUpdate: (refreshed) => console.log('[smartico] templates refreshed — re-render lobby', refreshed),
367
+ });
368
+ const game = games.find(g => g.id === templateId);
369
+
370
+ if (!game) {
371
+ console.log('[smartico] template not in current list — refresh getMiniGames');
372
+ return;
373
+ }
374
+ if (game.saw_buyin_type === 'spins' && (game.spin_count ?? 0) === 0) {
375
+ console.log('[smartico] no spins available — disable Play button, show "No spins" message');
376
+ return;
377
+ }
378
+
379
+ console.log('[smartico] play starting — set in-flight flag, start game animation (wheel spin / scratch / lootbox open / etc.)');
380
+ const r = await window._smartico.api.playMiniGame(game.id);
381
+ console.log('[smartico] play response received');
382
+
383
+ if (r.err_code === 0) {
384
+ const prize = game.prizes.find(p => p.id === r.prize_id);
385
+ if (prize?.prize_type === 'no-prize') {
386
+ console.log('[smartico] user lost — animate to the no-prize slot and show "Better luck next time" modal');
387
+ } else {
388
+ console.log('[smartico] user won — animate to prize', prize?.name,
389
+ '— show acknowledge modal per template.acknowledge_type;',
390
+ 'getMiniGames onUpdate fires shortly with refreshed spin_count / jackpot');
391
+ }
392
+ } else if (r.err_code === 40004) {
393
+ console.error('[smartico] max spins reached — show countdown to next available spin (use playMiniGameBatch for first_spin_in_period if needed)');
394
+ } else if (r.err_code === -40001) {
395
+ console.log('[smartico] visitor stopped — silently end the game, no prize modal');
396
+ } else {
397
+ console.error('[smartico] play failed — show generic error with this message:', r.err_message);
398
+ }
399
+ ```
400
+
401
+ ***
402
+
403
+ ### miniGameWinAcknowledgeRequest()
404
+
405
+ > **miniGameWinAcknowledgeRequest**(`request_id`): `Promise`\<[`SAWDoAknowledgeResponse`](../interfaces/SAWDoAknowledgeResponse.md)\>
406
+
407
+ Manually acknowledges a mini-game spin — marks the spin as
408
+ "delivered" so the prize takes effect server-side. Most consumers
409
+ do NOT need to call this method directly; [playMiniGame](#playminigame)
410
+ and [playMiniGameBatch](#playminigamebatch) auto-acknowledge on success. Use
411
+ this only for recovery scenarios.
412
+
413
+ #### Parameters
414
+
415
+ ##### request\_id
416
+
417
+ `string`
418
+
419
+ The `client_request_id` from a `TSawHistory`
420
+ row returned by [getMiniGamesHistory](#getminigameshistory).
421
+
422
+ #### Returns
423
+
424
+ `Promise`\<[`SAWDoAknowledgeResponse`](../interfaces/SAWDoAknowledgeResponse.md)\>
425
+
426
+ #### Remarks
427
+
428
+ **When to call**
429
+ - **Lost auto-acknowledge** — when the WebSocket dropped between
430
+ the spin response and the auto-acknowledge fire-and-forget,
431
+ the spin shows `is_claimed: false` in
432
+ [getMiniGamesHistory](#getminigameshistory). Pass that row's
433
+ `client_request_id` here to deliver the prize.
434
+ - **Explicit-acknowledge UI** — for templates configured with
435
+ the `ExplicitAcknowledge` acknowledge type (operator
436
+ decision), the consumer's UI shows a "Claim" CTA after the
437
+ prize animation. Click handler calls this method with the
438
+ spin's `client_request_id` rather than auto-acknowledging.
439
+
440
+ **No-op on already-acknowledged spins**
441
+ The server's acknowledge SQL matches on `acknowledge_date IS
442
+ NULL` — a duplicate call returns successfully with no effect.
443
+
444
+ **Server-side fallback**
445
+ Even without ever calling this method, a server-side job
446
+ auto-acknowledges stale spins every ~60 seconds — so prizes are
447
+ eventually delivered. The `is_claimed` flag flips on the next
448
+ `getMiniGamesHistory` call after the job runs.
449
+
450
+ **Idempotency**: safe. Repeated calls have no effect after the
451
+ first.
452
+
453
+ **Side effects** (on first successful call for an unacknowledged
454
+ spin)
455
+ - Prize value credited per the prize's type (see
456
+ [playMiniGame](#playminigame) "Prize handling").
457
+ - The spin's `is_claimed` flag flips to `true` on the next
458
+ [getMiniGamesHistory](#getminigameshistory) call.
459
+
460
+ **Visitor mode**: not supported.
461
+
462
+ #### Example
463
+
464
+ ```ts
465
+ const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
466
+ const unacknowledged = history.filter(h => !h.is_claimed);
467
+
468
+ for (const row of unacknowledged) {
469
+ console.log('[smartico] re-acknowledging stale spin', row.client_request_id);
470
+ await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
471
+ }
472
+
473
+ // Re-fetch history to see the updated is_claimed flags.
474
+ const fresh = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
475
+ console.log('[smartico] history after recovery —', fresh.filter(h => !h.is_claimed).length, 'still unacknowledged');
476
+ ```
477
+
478
+ ***
479
+
480
+ ### playMiniGameBatch()
481
+
482
+ > **playMiniGameBatch**(`template_id`, `spin_count`, `params?`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
483
+
484
+ Plays a mini-game template `spin_count` times in one round-trip.
485
+ Returns an array of per-spin results — each independent, each
486
+ with its own error code. Like [playMiniGame](#playminigame), the SDK
487
+ auto-acknowledges every result on a fire-and-forget basis.
488
+
489
+ Use this when a UI offers "spin N times" affordances
490
+ (multi-spin buttons, lootbox open-N flows). The server processes
491
+ each spin independently — there is no atomicity / rollback if
492
+ one fails.
493
+
494
+ #### Parameters
495
+
496
+ ##### template\_id
497
+
498
+ `number`
499
+
500
+ The mini-game template ID.
501
+
502
+ ##### spin\_count
503
+
504
+ `number`
505
+
506
+ Number of spins to play. The server attempts
507
+ all `spin_count` spins — partial successes
508
+ are normal when the user runs out of
509
+ balance / spins mid-batch.
510
+
511
+ ##### params?
512
+
513
+ Optional. Pass an `onUpdate` callback to
514
+ subscribe to subsequent template refreshes.
515
+
516
+ ###### onUpdate?
517
+
518
+ (`data`) => `void`
519
+
520
+ #### Returns
521
+
522
+ `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
523
+
524
+ `TMiniGamePlayBatchResult[]` — one entry per requested
525
+ spin, in request order. Note the camelCase `errCode` /
526
+ `errMessage` keys (see "Result shape note" above).
527
+
528
+ #### Remarks
529
+
530
+ **Result shape note** — `TMiniGamePlayBatchResult` uses
531
+ `errCode` / `errMessage` (camelCase) — DIFFERENT from
532
+ [TMiniGamePlayResult](../interfaces/TMiniGamePlayResult.md) which uses `err_code` / `err_message`
533
+ (snake_case). Branch on the camelCase keys when reading batch
534
+ results.
535
+
536
+ **Per-spin independence**
537
+ The server iterates the requested spins and calls the prize
538
+ engine once per entry. If spin #2 fails with `SAW_NO_SPINS`,
539
+ spin #3 is still attempted — the server does NOT stop on first
540
+ error and does NOT roll back successful spins. Each
541
+ `results[i].errCode` is independent.
542
+
543
+ Practical implication: if the user has 3 spins available and
544
+ requests 5, expect results 0-2 with `errCode === 0` and results
545
+ 3-4 with `errCode === SAW_NO_SPINS`.
546
+
547
+ **Error codes**
548
+ Per-result `errCode` is from [SAWSpinErrorCode](../enumerations/SAWSpinErrorCode.md). See
549
+ [playMiniGame](#playminigame) for the full table; the same codes apply
550
+ per spin.
551
+
552
+ **`first_spin_in_period` field**
553
+ Populated on results where `errCode === SAW_FAILED_MAX_SPINS_REACHED`
554
+ (40004). The value is the epoch-ms timestamp of the user's
555
+ first spin in the current cooldown period. Compute the
556
+ countdown as:
557
+ `template.max_spins_period_ms - (Date.now() - first_spin_in_period)`.
558
+
559
+ **`jackpot_amount` field**
560
+ Populated on results where the won prize is a jackpot
561
+ (`prize_type === 'jackpot'`). The amount the user just claimed
562
+ from the template's jackpot accumulator.
563
+
564
+ **Auto-acknowledge**
565
+ The SDK fires a batch-acknowledge for all `request_id`s after
566
+ the batch response lands — fire-and-forget. Same recovery
567
+ semantics as [playMiniGame](#playminigame): lost acknowledgements
568
+ become recoverable via [miniGameWinAcknowledgeRequest](#minigamewinacknowledgerequest)
569
+ per row, and a server-side fallback job auto-acknowledges
570
+ stale spins every ~60 seconds.
571
+
572
+ **Idempotency**: NOT idempotent. A double-click sends two
573
+ batches. Guard the call site with an in-flight flag.
574
+
575
+ **Refresh after success (and after failure)**
576
+ Same as [playMiniGame](#playminigame) — the templates cache refreshes
577
+ and any `onUpdate` callback registered via [getMiniGames](#getminigames)
578
+ fires with the updated `spin_count` / `jackpot_current`.
579
+
580
+ **Side effects** (per-spin, on `errCode === 0`)
581
+ Same as [playMiniGame](#playminigame) — buy-in deducted, prize value
582
+ credited per prize type.
583
+
584
+ **UI guidance**: see [UI Guide — `playMiniGameBatch`](../_media/UIGuide_playMiniGameBatch.md).
585
+
586
+ **Visitor mode**: not supported.
587
+
588
+ #### Example
589
+
590
+ ```ts
591
+ const game = (await window._smartico.api.getMiniGames()).find(g => g.id === templateId);
592
+ if (!game) return;
593
+
594
+ console.log('[smartico] batch play starting — set in-flight flag, animate the chosen N spins sequentially in UI');
595
+ const results = await window._smartico.api.playMiniGameBatch(game.id, 5);
596
+ console.log('[smartico] batch response received — clear in-flight flag');
597
+
598
+ for (const [i, r] of results.entries()) {
599
+ if (r.errCode === 0) {
600
+ const prize = game.prizes.find(p => p.id === r.saw_prize_id);
601
+ console.log('[smartico] spin', i, 'won:', prize?.name,
602
+ r.jackpot_amount ? '(jackpot: ' + r.jackpot_amount + ')' : '');
603
+ } else if (r.errCode === 40004) {
604
+ const msTillNext = game.max_spins_period_ms! - (Date.now() - (r.first_spin_in_period ?? 0));
605
+ console.log('[smartico] spin', i, 'capped — ' + Math.ceil(msTillNext / 1000) + ' s until next allowed');
606
+ } else {
607
+ console.error('[smartico] spin', i, 'failed —', r.errCode, r.errMessage);
608
+ }
609
+ }
610
+ ```
611
+
612
+ ***