@smartico/public-api 0.0.380 → 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.
- package/CLAUDE.md +103 -0
- package/README.md +32 -10
- package/dist/Base/ClassId.d.ts +2 -0
- package/dist/Jackpots/JackpotDetails.d.ts +14 -15
- package/dist/Jackpots/JackpotPot.d.ts +10 -6
- package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
- package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
- package/dist/Raffle/index.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +6 -1
- package/dist/SmarticoLib/index.d.ts +5 -1
- package/dist/WSAPI/WSAPIAvatars.d.ts +267 -49
- package/dist/WSAPI/WSAPIBonuses.d.ts +224 -10
- package/dist/WSAPI/WSAPIGamePick.d.ts +538 -253
- package/dist/WSAPI/WSAPIGeneral.d.ts +156 -14
- package/dist/WSAPI/WSAPIInbox.d.ts +547 -58
- package/dist/WSAPI/WSAPIJackpots.d.ts +292 -57
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +127 -13
- package/dist/WSAPI/WSAPIMiniGames.d.ts +465 -49
- package/dist/WSAPI/WSAPIRaffles.d.ts +576 -52
- package/dist/WSAPI/WSAPITournaments.d.ts +3 -3
- package/dist/WSAPI/WSAPITypes.d.ts +243 -132
- package/dist/WSAPI/WSAPIUser.d.ts +193 -43
- package/dist/index.js +3409 -615
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +3391 -608
- package/dist/index.modern.mjs.map +1 -1
- package/docs/Callbacks.md +162 -0
- package/docs/SmarticoObject.md +445 -0
- package/docs/Transforms.md +99 -0
- package/docs/api/README.md +26 -0
- package/docs/api/classes/WSAPIAvatars.md +282 -54
- package/docs/api/classes/WSAPIBonuses.md +233 -12
- package/docs/api/classes/WSAPIClans.md +380 -10
- package/docs/api/classes/WSAPIGamePick.md +555 -26
- package/docs/api/classes/WSAPIGeneral.md +165 -16
- package/docs/api/classes/WSAPIInbox.md +588 -64
- package/docs/api/classes/WSAPIJackpots.md +320 -66
- package/docs/api/classes/WSAPILeaderBoard.md +133 -15
- package/docs/api/classes/WSAPIMiniGames.md +501 -64
- package/docs/api/classes/WSAPIMissions.md +58 -79
- package/docs/api/classes/WSAPIRaffles.md +647 -69
- package/docs/api/classes/WSAPIStore.md +83 -108
- package/docs/api/classes/WSAPITournaments.md +495 -28
- package/docs/api/classes/WSAPIUser.md +520 -83
- package/docs/api/documents/Callbacks.md +162 -0
- package/docs/api/documents/SmarticoObject.md +445 -0
- package/docs/api/documents/Transforms.md +99 -0
- package/docs/api/enumerations/BonusStatus-1.md +11 -6
- package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
- package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
- package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
- package/docs/api/interfaces/AvatarCustomized.md +25 -0
- package/docs/api/interfaces/AvatarDefinition.md +94 -0
- package/docs/api/interfaces/AvatarPrompt.md +45 -0
- package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
- package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
- package/docs/api/interfaces/Clan.md +4 -0
- package/docs/api/interfaces/ClanInfo.md +109 -0
- package/docs/api/interfaces/ClanMember.md +53 -0
- package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
- package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
- package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
- package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
- package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
- package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
- package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
- package/docs/api/interfaces/JackpotDetails.md +14 -15
- package/docs/api/interfaces/JackpotPot.md +9 -6
- package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
- package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
- package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
- package/docs/api/interfaces/PointsLog.md +43 -0
- package/docs/api/interfaces/RaffleWonPrize.md +59 -0
- package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
- package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
- package/docs/api/interfaces/TAchCategory.md +2 -7
- package/docs/api/interfaces/TAvatarCustomized.md +4 -4
- package/docs/api/interfaces/TAvatarDefinition.md +13 -14
- package/docs/api/interfaces/TAvatarPrompt.md +6 -6
- package/docs/api/interfaces/TBonus.md +16 -8
- package/docs/api/interfaces/TBuyStoreItemResult.md +4 -29
- package/docs/api/interfaces/TClaimBonusResult.md +5 -5
- package/docs/api/interfaces/TClan.md +8 -4
- package/docs/api/interfaces/TClanInfo.md +47 -0
- package/docs/api/interfaces/TClanJoinResult.md +11 -1
- package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
- package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
- package/docs/api/interfaces/TClans.md +3 -1
- package/docs/api/interfaces/TGetTranslations.md +4 -0
- package/docs/api/interfaces/TInboxMessage.md +14 -6
- package/docs/api/interfaces/TInboxMessageBody.md +18 -12
- package/docs/api/interfaces/TLevel.md +17 -20
- package/docs/api/interfaces/TLevelCurrent.md +19 -18
- package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
- package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
- package/docs/api/interfaces/TMissionClaimRewardResult.md +1 -9
- package/docs/api/interfaces/TMissionOptInResult.md +1 -5
- package/docs/api/interfaces/TMissionOrBadge.md +4 -7
- package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
- package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
- package/docs/api/interfaces/TSetAvatarResult.md +3 -3
- package/docs/api/interfaces/TStoreItem.md +3 -13
- package/docs/api/interfaces/TTournament.md +1 -1
- package/docs/api/interfaces/TTournamentDetailed.md +1 -1
- package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
- package/docs/api/interfaces/TUICustomSection.md +23 -19
- package/docs/api/interfaces/TUserProfile.md +18 -16
- package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
- package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
- package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
- package/docs/native/ADDING_METHODS.md +7 -2
- package/docs/native/PROTOCOL.md +337 -0
- package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
- package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
- package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
- package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
- package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
- package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
- package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
- package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
- package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
- package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
- package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
- package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
- package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
- package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
- package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
- package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
- package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
- package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
- package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
- package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
- package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
- package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
- package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
- package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
- package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
- package/docs/ui/user/UIGuide_getLevels.md +47 -42
- package/package.json +1 -1
- package/src/Base/ClassId.ts +2 -0
- package/src/Jackpots/JackpotDetails.ts +14 -15
- package/src/Jackpots/JackpotPot.ts +10 -6
- package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
- package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
- package/src/Raffle/index.ts +3 -1
- package/src/SmarticoAPI.ts +14 -1
- package/src/SmarticoLib/index.ts +4 -0
- package/src/WSAPI/WSAPIAvatars.ts +267 -49
- package/src/WSAPI/WSAPIBonuses.ts +224 -10
- package/src/WSAPI/WSAPIGamePick.ts +538 -253
- package/src/WSAPI/WSAPIGeneral.ts +156 -14
- package/src/WSAPI/WSAPIInbox.ts +545 -56
- package/src/WSAPI/WSAPIJackpots.ts +297 -61
- package/src/WSAPI/WSAPILeaderBoard.ts +127 -13
- package/src/WSAPI/WSAPIMiniGames.ts +465 -49
- package/src/WSAPI/WSAPIRaffles.ts +592 -64
- package/src/WSAPI/WSAPITournaments.ts +3 -3
- package/src/WSAPI/WSAPITypes.ts +243 -132
- package/src/WSAPI/WSAPIUser.ts +193 -43
- package/tsconfig.json +9 -1
|
@@ -3,96 +3,234 @@
|
|
|
3
3
|
|
|
4
4
|
### getMiniGames()
|
|
5
5
|
|
|
6
|
-
> **getMiniGames**(`
|
|
6
|
+
> **getMiniGames**(`params?`): `Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
|
|
7
7
|
|
|
8
|
-
Returns
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Example in the Visitor mode**:
|
|
20
|
-
```
|
|
21
|
-
_smartico.vapi('EN').getMiniGames().then((result) => {
|
|
22
|
-
console.log(result);
|
|
23
|
-
});
|
|
24
|
-
```
|
|
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).
|
|
25
20
|
|
|
26
21
|
#### Parameters
|
|
27
22
|
|
|
28
|
-
#####
|
|
23
|
+
##### params?
|
|
24
|
+
|
|
25
|
+
Optional. Omit to fetch without subscribing.
|
|
29
26
|
|
|
30
27
|
###### onUpdate?
|
|
31
28
|
|
|
32
29
|
(`data`) => `void`
|
|
33
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
|
+
|
|
34
36
|
#### Returns
|
|
35
37
|
|
|
36
38
|
`Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
|
|
37
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
|
+
|
|
38
117
|
***
|
|
39
118
|
|
|
40
119
|
### getMiniGamesHistory()
|
|
41
120
|
|
|
42
|
-
> **getMiniGamesHistory**(`
|
|
121
|
+
> **getMiniGamesHistory**(`params`): `Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
|
|
43
122
|
|
|
44
|
-
Returns
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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`.
|
|
48
129
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Visitor mode: not supported**
|
|
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)).
|
|
57
134
|
|
|
58
135
|
#### Parameters
|
|
59
136
|
|
|
60
|
-
#####
|
|
137
|
+
##### params
|
|
138
|
+
|
|
139
|
+
Optional pagination + filter bag.
|
|
61
140
|
|
|
62
141
|
###### limit?
|
|
63
142
|
|
|
64
143
|
`number`
|
|
65
144
|
|
|
145
|
+
Page size. Defaults to 20.
|
|
146
|
+
|
|
66
147
|
###### offset?
|
|
67
148
|
|
|
68
149
|
`number`
|
|
69
150
|
|
|
151
|
+
Number of rows to skip. Defaults to 0.
|
|
152
|
+
|
|
70
153
|
###### saw_template_id?
|
|
71
154
|
|
|
72
155
|
`number`
|
|
73
156
|
|
|
157
|
+
When set, scopes the history to
|
|
158
|
+
a single template's spins.
|
|
159
|
+
|
|
74
160
|
#### Returns
|
|
75
161
|
|
|
76
162
|
`Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
|
|
77
163
|
|
|
78
|
-
|
|
164
|
+
Promise resolving to `TSawHistory[]` in newest-first
|
|
165
|
+
order. Empty when the user has no history.
|
|
79
166
|
|
|
80
|
-
|
|
167
|
+
#### Remarks
|
|
81
168
|
|
|
82
|
-
|
|
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.
|
|
83
174
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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`.
|
|
87
179
|
|
|
88
|
-
**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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');
|
|
93
214
|
```
|
|
94
215
|
|
|
95
|
-
|
|
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.
|
|
96
234
|
|
|
97
235
|
#### Parameters
|
|
98
236
|
|
|
@@ -100,7 +238,13 @@ _smartico.api.playMiniGame(55).then((result) => {
|
|
|
100
238
|
|
|
101
239
|
`number`
|
|
102
240
|
|
|
103
|
-
|
|
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.
|
|
104
248
|
|
|
105
249
|
###### onUpdate?
|
|
106
250
|
|
|
@@ -110,19 +254,161 @@ _smartico.api.playMiniGame(55).then((result) => {
|
|
|
110
254
|
|
|
111
255
|
`Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
|
|
112
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
|
+
|
|
113
401
|
***
|
|
114
402
|
|
|
115
403
|
### miniGameWinAcknowledgeRequest()
|
|
116
404
|
|
|
117
405
|
> **miniGameWinAcknowledgeRequest**(`request_id`): `Promise`\<[`SAWDoAknowledgeResponse`](../interfaces/SAWDoAknowledgeResponse.md)\>
|
|
118
406
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
```
|
|
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.
|
|
126
412
|
|
|
127
413
|
#### Parameters
|
|
128
414
|
|
|
@@ -130,27 +416,80 @@ _smartico.api.miniGameWinAcknowledgeRequest('2a189322-31bb-4119-b943-bx7868ff8dc
|
|
|
130
416
|
|
|
131
417
|
`string`
|
|
132
418
|
|
|
419
|
+
The `client_request_id` from a `TSawHistory`
|
|
420
|
+
row returned by [getMiniGamesHistory](#getminigameshistory).
|
|
421
|
+
|
|
133
422
|
#### Returns
|
|
134
423
|
|
|
135
424
|
`Promise`\<[`SAWDoAknowledgeResponse`](../interfaces/SAWDoAknowledgeResponse.md)\>
|
|
136
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
|
+
|
|
137
478
|
***
|
|
138
479
|
|
|
139
480
|
### playMiniGameBatch()
|
|
140
481
|
|
|
141
|
-
> **playMiniGameBatch**(`template_id`, `spin_count`, `
|
|
482
|
+
> **playMiniGameBatch**(`template_id`, `spin_count`, `params?`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
|
|
142
483
|
|
|
143
|
-
Plays
|
|
144
|
-
|
|
145
|
-
|
|
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.
|
|
146
488
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
**Visitor mode: not supported**
|
|
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.
|
|
154
493
|
|
|
155
494
|
#### Parameters
|
|
156
495
|
|
|
@@ -158,11 +497,21 @@ _smartico.api.playMiniGameBatch(55, 10).then((result) => {
|
|
|
158
497
|
|
|
159
498
|
`number`
|
|
160
499
|
|
|
500
|
+
The mini-game template ID.
|
|
501
|
+
|
|
161
502
|
##### spin\_count
|
|
162
503
|
|
|
163
504
|
`number`
|
|
164
505
|
|
|
165
|
-
|
|
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.
|
|
166
515
|
|
|
167
516
|
###### onUpdate?
|
|
168
517
|
|
|
@@ -172,4 +521,92 @@ _smartico.api.playMiniGameBatch(55, 10).then((result) => {
|
|
|
172
521
|
|
|
173
522
|
`Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
|
|
174
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
|
+
|
|
175
612
|
***
|