@smartico/public-api 0.0.409 → 0.0.411

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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/MiniGames/SAWDoAknowledgeRequest.d.ts +2 -0
  3. package/dist/MiniGames/SAWPrize.d.ts +18 -0
  4. package/dist/MiniGames/SAWPrizeUI.d.ts +1 -0
  5. package/dist/MiniGames/SAWTemplate.d.ts +24 -0
  6. package/dist/SmarticoAPI.d.ts +1 -1
  7. package/dist/SmarticoLib/index.d.ts +1 -1
  8. package/dist/WSAPI/WSAPIJackpots.d.ts +11 -2
  9. package/dist/WSAPI/WSAPIMiniGames.d.ts +92 -23
  10. package/dist/WSAPI/WSAPITypes.d.ts +45 -44
  11. package/dist/index.js +112 -31
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.modern.mjs +109 -28
  14. package/dist/index.modern.mjs.map +1 -1
  15. package/docs/api/classes/WSAPIJackpots.md +11 -2
  16. package/docs/api/classes/WSAPIMiniGames.md +92 -23
  17. package/docs/api/interfaces/SAWDoAknowledgeRequest.md +8 -0
  18. package/docs/api/interfaces/SAWPrize.md +36 -0
  19. package/docs/api/interfaces/SAWPrizeUI.md +2 -0
  20. package/docs/api/interfaces/SAWTemplate.md +48 -0
  21. package/docs/api/interfaces/TMiniGamePrize.md +51 -27
  22. package/docs/api/interfaces/TMiniGameTemplate.md +15 -16
  23. package/docs/capabilities/getJackpotEligibleGames.md +11 -2
  24. package/docs/capabilities/getMiniGames.md +63 -39
  25. package/docs/capabilities/miniGameWinAcknowledgeRequest.md +36 -7
  26. package/docs/capabilities/playMiniGame.md +27 -14
  27. package/docs/native/PROTOCOL.md +7 -0
  28. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +8 -0
  29. package/docs/ui/minigames/UIGuide_getMiniGames.md +46 -0
  30. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +1 -1
  31. package/docs/ui/minigames/UIGuide_miniGameWinAcknowledgeRequest.md +90 -0
  32. package/docs/ui/minigames/UIGuide_playMiniGame.md +38 -2
  33. package/package.json +1 -1
  34. package/src/MiniGames/SAWDoAknowledgeRequest.ts +2 -0
  35. package/src/MiniGames/SAWGetTemplatesResponse.ts +1 -0
  36. package/src/MiniGames/SAWPrize.ts +18 -0
  37. package/src/MiniGames/SAWPrizeUI.ts +2 -1
  38. package/src/MiniGames/SAWTemplate.ts +27 -4
  39. package/src/SmarticoAPI.ts +7 -1
  40. package/src/SmarticoLib/index.ts +1 -1
  41. package/src/WSAPI/WSAPIJackpots.ts +11 -2
  42. package/src/WSAPI/WSAPIMiniGames.ts +91 -24
  43. package/src/WSAPI/WSAPITypes.ts +47 -46
@@ -1,16 +1,17 @@
1
1
  # miniGameWinAcknowledgeRequest — API
2
2
 
3
- > Manually acknowledges a mini-game spin — marks the win delivered server-side.
3
+ > Manually acknowledges a mini-game spin — marks the win delivered server-side, or (with `lose: true`) finalises it as lost and returns the prize to the pool.
4
4
  > Import: `import { /* types */ } from '@smartico/public-api'`
5
5
  > Search terms: miniGameWinAcknowledgeRequest, minigames, doSAWAcknowledge, SAWAcknowledge, acknowledge, SAWAcknowledgeType, request_id, errCode, errMsg, cid, ts, uuid, payload, duration
6
6
 
7
7
  ## Signature
8
8
  ```ts
9
- _smartico.api.miniGameWinAcknowledgeRequest(request_id: string): void
9
+ _smartico.api.miniGameWinAcknowledgeRequest(request_id: string, { lose }: { lose?: boolean } = {}): void
10
10
  ```
11
11
 
12
12
  ## Parameters
13
13
  - `request_id` — Correlation id of the spin to finalise: the `request_id` from a `playMiniGame` result (played with `acknowledge: false`), or the `client_request_id` of a `getMiniGamesHistory` row.
14
+ - `options.lose` — Optional. When `true`, finalises the spin as lost — the prize is not credited and returns to the prize pool (see "Finalising as lost"). Omit (or pass `false`) to deliver the win.
14
15
 
15
16
  ## Returns
16
17
  _No return value._
@@ -34,6 +35,27 @@ The `request_id` on a `playMiniGame` result and the
34
35
  `client_request_id` on a `getMiniGamesHistory` row are the
35
36
  same correlation id — this method accepts either.
36
37
 
38
+ **Finalising as lost (`lose: true`)**
39
+ Pass `{ lose: true }` to finalise the spin as LOST instead of won:
40
+ the prize is NOT credited and is returned to the game's prize pool
41
+ (available again for other players), and the spin fires the
42
+ mini-game "lose" engagement event instead of the win one. On the
43
+ next `getMiniGamesHistory` fetch the row shows `is_claimed:
44
+ true` with no prize attached. Use this for game mechanics where the
45
+ player can decline or forfeit the drawn prize — e.g. a
46
+ gamble/discard step, or a client-driven game where the user's final
47
+ action decides whether the pre-drawn prize is actually won (the
48
+ default Smartico UI does this for the Voyager game: failing the
49
+ star-collection run finalises the spin as lost). When configured,
50
+ the prize's `aknowledge_message_lose` is the operator's result copy
51
+ for this case — show it instead of `aknowledge_message`. It only
52
+ works on a spin that is not yet finalised, so it requires playing
53
+ with `acknowledge: false` and calling promptly — once the automatic
54
+ acknowledge or the server-side fallback (below) has finalised the
55
+ spin, `lose: true` is a no-op and the prize stays credited.
56
+ ("Explicit claim" prizes are exempt from the fallback, so for them
57
+ there is no time pressure.)
58
+
37
59
  **Idempotency**: safe. Acknowledging a spin that is already
38
60
  finalised — by you, by the automatic acknowledge, or by the
39
61
  fallback — is a no-op with no double credit. Acknowledging a
@@ -48,13 +70,16 @@ exception — excluded from the fallback, they require an explicit
48
70
  call here.
49
71
 
50
72
  **Side effects** (first successful call for an un-acknowledged spin)
51
- - For "explicit claim" prizes, the prize value is credited on this
52
- call. For standard prizes the value was already credited at spin
53
- time (see `playMiniGame` "Prize handling"); this call only
54
- marks the win delivered.
55
- - The spin's `is_claimed` flips to `true` on the next
73
+ - Default (win): the prize value is credited on this call — this is
74
+ the finalisation step that credits standard and "explicit claim"
75
+ prizes alike (see `playMiniGame` "Prize handling").
76
+ - With `lose: true`: no credit; the prize returns to the prize pool
77
+ and the "lose" engagement event fires.
78
+ - Either way the spin's `is_claimed` flips to `true` on the next
56
79
  `getMiniGamesHistory` fetch.
57
80
 
81
+ **UI guidance**: see [UI Guide — `miniGameWinAcknowledgeRequest`](../../docs/ui/minigames/UIGuide_miniGameWinAcknowledgeRequest.md).
82
+
58
83
  **Visitor mode**: not supported.
59
84
 
60
85
  ## Example
@@ -66,6 +91,10 @@ if (r.err_code === 0) {
66
91
  await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
67
92
  }
68
93
 
94
+ // Decline / forfeit — finalise the same spin as lost instead:
95
+ // the prize is not credited and goes back to the prize pool.
96
+ await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
97
+
69
98
  // Recovery — re-acknowledge any spins a batch acknowledge missed.
70
99
  const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
71
100
  for (const row of history.filter(h => !h.is_claimed)) {
@@ -67,14 +67,19 @@ without waiting for the win to be marked delivered. You finalise
67
67
  it later by calling `miniGameWinAcknowledgeRequest` with the
68
68
  `request_id` returned on this result.
69
69
 
70
- What `acknowledge: false` does and does NOT defer:
71
- - For STANDARD prizes the value is credited at spin time
72
- regardless, so opting out does NOT delay the balance change —
73
- it only defers the "delivered" bookkeeping and the `is_claimed`
74
- flag flipping in `getMiniGamesHistory`.
75
- - For operator-configured "explicit claim" prizes the credit IS
76
- deferred until the spin is acknowledged, so those require an
77
- explicit acknowledge to finalise.
70
+ What `acknowledge: false` defers:
71
+ - For STANDARD prizes the value is credited when the spin is
72
+ finalised — by your later acknowledge or, failing that, by the
73
+ server-side fallback below — so opting out delays the balance
74
+ change by at most that fallback window. The `is_claimed` flag in
75
+ `getMiniGamesHistory` flips on the same finalisation.
76
+ - For operator-configured "explicit claim" prizes the credit is
77
+ deferred until your explicit acknowledge — the fallback does not
78
+ cover them.
79
+
80
+ While the spin is un-finalised it can also be finalised as LOST —
81
+ prize discarded back to the pool — via
82
+ `miniGameWinAcknowledgeRequest` with `{ lose: true }`.
78
83
 
79
84
  A server-side fallback auto-acknowledges ordinary un-acknowledged
80
85
  spins after a short delay (about 1–3 minutes), so an ordinary
@@ -105,8 +110,10 @@ refreshed array.
105
110
  time the call resolves. Balance updates flow via the
106
111
  user-properties channel (observe via `getUserProfile`).
107
112
  - Prize value credited per the prize's type (see "Prize handling"
108
- above). Standard prizes are credited at spin time; "explicit
109
- claim" prizes are credited when the spin is acknowledged.
113
+ above) when the spin is finalised — with the default
114
+ auto-acknowledge that happens before the call resolves;
115
+ "explicit claim" prizes are credited only by an explicit
116
+ acknowledge.
110
117
  - The play is recorded server-side for analytics / reporting.
111
118
 
112
119
  **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
@@ -153,18 +160,24 @@ if (r.err_code === 0) {
153
160
  ```
154
161
 
155
162
  Manual finalisation (`acknowledge: false`) — e.g. an explicit
156
- "Claim" CTA, or finalising on your own schedule:
163
+ "Claim" CTA, a decline/forfeit flow, or finalising on your own
164
+ schedule:
157
165
  ```ts
158
166
  const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
159
167
  if (r.err_code === 0) {
160
- // Spin resolved but not yet acknowledged. For standard prizes the
161
- // balance already changed server-side; "explicit claim" prizes
162
- // are credited only by the acknowledge below.
168
+ // Spin resolved but not yet finalised — the prize is not credited
169
+ // yet. Your acknowledge below credits it (for standard prizes the
170
+ // server-side fallback would eventually do the same).
163
171
  console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
164
172
 
165
173
  // On the user's Claim click, finalise with the request_id from the result.
166
174
  await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
167
175
  console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
176
+
177
+ // Or, if the game flow ends in the player declining / losing the
178
+ // drawn prize, finalise the spin as lost instead — the prize is
179
+ // not credited and returns to the prize pool:
180
+ // await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
168
181
  }
169
182
  ```
170
183
 
@@ -1329,6 +1329,8 @@ No method-specific fields. Send only the common fields (see [Common Message Fiel
1329
1329
  |-------|------|-------------|
1330
1330
  | `templates` | [`SAWTemplate[]`](../api/interfaces/SAWTemplate.md) | Array of mini-game templates |
1331
1331
 
1332
+ Note: per-prize stock statistics (`pool`, `wins_count`, `weekdays`, `active_from_ts` / `active_till_ts`) are present on each template's `prizes` only when the template's `expose_game_stat_on_api` is enabled; otherwise the server strips them (`pool` is kept for MatchX / Quiz game types).
1333
+
1332
1334
  ---
1333
1335
 
1334
1336
  ### playMiniGame
@@ -1434,6 +1436,8 @@ Each item in `results`:
1434
1436
 
1435
1437
  Acknowledge a mini-game win. Should be called after displaying the win result to the user.
1436
1438
 
1439
+ Optionally finalises the spin as **lost** instead: with `lose: true` the prize is not credited, it is returned to the game's prize pool, and the mini-game "lose" engagement event fires instead of the win one. Only possible while the spin is not yet acknowledged — once the automatic server-side acknowledge fallback has finalised it, `lose: true` is a no-op and the prize stays credited.
1440
+
1437
1441
  #### Request
1438
1442
 
1439
1443
  **ClassId:** `704` (SAW_AKNOWLEDGE_REQUEST)
@@ -1441,6 +1445,7 @@ Acknowledge a mini-game win. Should be called after displaying the win result to
1441
1445
  | Field | Type | Description |
1442
1446
  |-------|------|-------------|
1443
1447
  | `request_id` | `string` | Request ID from the spin response |
1448
+ | `lose` | `boolean` | Optional. `true` finalises the spin as lost: prize not credited, returned to the prize pool. Omit or `false` to deliver the win |
1444
1449
 
1445
1450
  #### Response
1446
1451
 
@@ -1506,6 +1511,8 @@ Acknowledge a mini-game spin push. Sent after handling `SAW_SHOW_SPIN_PUSH` (707
1506
1511
 
1507
1512
  Acknowledge multiple mini-game wins at once. Used after `playMiniGameBatch`.
1508
1513
 
1514
+ The batch acknowledge always finalises spins as **won** — `lose` is not supported here. To finalise a spin as lost, send a single [miniGameWinAcknowledge](#minigamewinacknowledge) (704) with `lose: true`.
1515
+
1509
1516
  #### Request
1510
1517
 
1511
1518
  **ClassId:** `714`
@@ -61,6 +61,14 @@ manually if needed.
61
61
  - For long sessions, re-call when reopening the tab past the 30 s
62
62
  window.
63
63
 
64
+ ## Visitor mode
65
+
66
+ Supported via `_smartico.vapi(lang).getJackpotEligibleGames(...)`. The
67
+ eligible-games list is template-level (which games contribute to the
68
+ pot) and carries no per-user fields, so a visitor session sees the same
69
+ list an identified user would. The `lang` passed to `_smartico.vapi(lang)`
70
+ drives the translation of game names.
71
+
64
72
  ## Mobile vs desktop
65
73
 
66
74
  - **Mobile**: 2- or 3-column tile grid.
@@ -75,6 +75,28 @@ keyed on `saw_game_type`. For custom UIs, render the matching
75
75
  component per game type — they share the same `playMiniGame`
76
76
  trigger (except `PrizeDrop`, `MatchX`, `Quiz` as noted).
77
77
 
78
+ ## Prize-field usage per game type
79
+
80
+ Several `prizes[]` fields only matter for specific renderers:
81
+
82
+ | Prize field | Used by | How |
83
+ |---|---|---|
84
+ | `sectors` | Spin-a-Wheel | Wheel sector indices the prize occupies — place the prize label/icon on those sectors. |
85
+ | `position` | Scratch Card | Sort prizes ascending by `position` to lay out the scratch grid. |
86
+ | `font_size` / `font_size_mobile` | Wheel, Scratch | Px size for the prize label on the game surface; mobile falls back to desktop. |
87
+ | `prize_modifiers` | Treasure Hunt, Voyager | Modifier tiles (2x…/10, 0, reset) applied to the running revealed total — presentation only; the award is still `prize_value`. |
88
+ | `allow_split_decimal` | Treasure Hunt, Voyager | Whether per-step revealed amounts may be fractional. |
89
+ | `requirements_to_get_prize` | Lootboxes | Text shown when the prize isn't yet available to the user. |
90
+ | `out_of_stock_message` | All (with stock) | Shown when the prize's pool is depleted. |
91
+ | `icon`, `name` | All | Prize strip, game surface, win modal. `name` arrives with the live jackpot value inlined. |
92
+ | `acknowledge_*`, `second_btn*`, `aknowledge_message(_lose)` | All | Win-modal contents — see [UI Guide — `playMiniGame`](UIGuide_playMiniGame.md) "Prize reveal modals". |
93
+
94
+ Template-side companions: `game_layout` picks the Lootbox grid
95
+ variant, `steps_to_finish_game` sizes step games, and
96
+ `expose_user_spin_id` asks the win view to display the player's
97
+ external user id (`'userId'`) or the spin's transaction id
98
+ (`'spinId'`) for transparency/audit.
99
+
78
100
  ## Action button decision matrix
79
101
 
80
102
  CTA on the card / detail view (evaluate in priority order):
@@ -99,6 +121,30 @@ error.
99
121
  | `promo_image` | ~2:1 wide, 500×240 px | Featured / hero artwork |
100
122
  | `prizes[].icon` | 1:1 (square) | Per-prize icon |
101
123
 
124
+ ## Prize stock / scarcity UI (`expose_game_stat_on_api`)
125
+
126
+ When the operator enables "expose game statistics" on a template
127
+ (`template.expose_game_stat_on_api === true`), each prize carries
128
+ live stock statistics you can build scarcity affordances from:
129
+
130
+ - `pool` — remaining stock → "Only 3 left!" badges; pair with
131
+ `pool_initial` for a depletion bar (`pool / pool_initial`).
132
+ - `wins_count` — total wins across all players → social proof
133
+ ("won 120 times").
134
+ - `weekdays` (ISO 1–7) and `active_from_ts` / `active_till_ts` —
135
+ the prize's availability schedule → grey out prizes not winnable
136
+ today, or show "available Mon–Fri" hints. Evaluate against
137
+ `relative_period_timezone` (minutes, JS `getTimezoneOffset`
138
+ convention), not the device timezone.
139
+
140
+ The values refresh after every play, so re-render stock badges
141
+ from the `onUpdate` callback. When the setting is disabled (the
142
+ default) these fields are absent — build the prize strip from the
143
+ definition fields only and don't reserve empty space for stock
144
+ badges. Exception: `pool` is always present for MatchX / Quiz
145
+ templates. A prize with `is_surcharge: true` never runs out —
146
+ skip stock badges for it.
147
+
102
148
  ## Status-specific visual treatments
103
149
 
104
150
  - **Playable**: full-color card; Play CTA enabled.
@@ -24,7 +24,7 @@ Fields rendered per row:
24
24
  | Field | Source | Notes |
25
25
  |---|---|---|
26
26
  | Template icon | `template.thumbnail` (or similar) | 1:1 |
27
- | Prize name | Look up `template.prizes[i]` by `saw_prize_id` | Display the prize's `name`. |
27
+ | Prize name | Look up `template.prizes[i]` by `saw_prize_id` | Display the prize's `name`. A spin finalised as lost (`miniGameWinAcknowledgeRequest` with `lose: true`) has no prize attached — render it as a loss. |
28
28
  | Prize amount | `template.prizes[i].prize_value` or `prize_amount` | E.g. "100 points" |
29
29
  | Spin date | `create_date_ts` | Format as user-local relative time ("2h ago") or short date |
30
30
  | Claim status | `is_claimed` | Show check-mark when true; "Pending claim" CTA when false |
@@ -0,0 +1,90 @@
1
+ # UI Guide — `miniGameWinAcknowledgeRequest`
2
+
3
+ Action-focused method — no list/card rendering of its own. It finalises
4
+ a spin played with `acknowledge: false`: as **won** (default) or as
5
+ **lost** (`{ lose: true }`). The UI patterns below cover the three
6
+ call sites: an explicit Claim CTA, a decline/forfeit outcome, and
7
+ history-row recovery.
8
+
9
+ ## When the UI calls this
10
+
11
+ | Flow | Trigger | Call |
12
+ |---|---|---|
13
+ | Explicit claim | User taps "Claim" in the prize modal (`acknowledge_type === 'ExplicitAcknowledge'`) after `playMiniGame(id, { acknowledge: false })` | `miniGameWinAcknowledgeRequest(r.request_id)` |
14
+ | Decline / forfeit | Game outcome or user choice says the drawn prize is NOT won (skill games like Voyager, gamble/discard steps) | `miniGameWinAcknowledgeRequest(r.request_id, { lose: true })` |
15
+ | History recovery | User taps "Claim" on a `getMiniGamesHistory` row with `is_claimed === false` | `miniGameWinAcknowledgeRequest(row.client_request_id)` |
16
+
17
+ ## Action button decision matrix
18
+
19
+ - **Win path (Claim CTA)**: enable the button as soon as the play
20
+ result is shown; disable it (with a spinner) while the request is
21
+ in flight; on resolve, show the prize's `aknowledge_message` modal
22
+ copy and refresh balance widgets (`getUserProfile`) and
23
+ `getMiniGames`.
24
+ - **Lose path**: no user-facing "lose the prize" button in most
25
+ designs — the game flow decides. The default Smartico UI sends
26
+ `lose: true` when the Voyager run fails (not all stars collected),
27
+ then shows the prize's `aknowledge_message_lose` copy (fall back to
28
+ a generic "Better luck next time" treatment when the operator
29
+ didn't configure it).
30
+ - **If you DO offer an explicit decline choice** (keep-or-gamble
31
+ UIs): render "Claim" and "Decline" side by side, disable both on
32
+ first tap, and treat the two calls as mutually exclusive — the
33
+ first one to reach the server wins; the other becomes a no-op.
34
+ - **History recovery rows**: see
35
+ [UI Guide — `getMiniGamesHistory`](UIGuide_getMiniGamesHistory.md)
36
+ for the row-level Claim CTA.
37
+
38
+ ## Timing constraints (drive the UX)
39
+
40
+ - Standard prizes are auto-finalised as WON by a server-side fallback
41
+ after ~1–3 minutes. A decline/forfeit decision must therefore be
42
+ sent promptly after the spin — don't park the choice behind an
43
+ unbounded modal. After the fallback fires, `lose: true` is a no-op
44
+ and the prize stays credited.
45
+ - "Explicit claim" prizes are exempt from the fallback: the Claim CTA
46
+ can wait indefinitely, and an unclaimed prize is simply never
47
+ credited. Surface unclaimed spins via the history view.
48
+
49
+ ## Idempotency guard
50
+
51
+ The call is idempotent server-side (no double credit), so a
52
+ double-tap is harmless — but still disable the button in flight to
53
+ avoid duplicate requests and modal flicker.
54
+
55
+ ## Result handling
56
+
57
+ ```ts
58
+ const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
59
+ if (r.err_code === 0) {
60
+ const prize = game.prizes.find(p => p.id === r.prize_id);
61
+ // ... run the game / show the Claim UI ...
62
+
63
+ if (playerWon) {
64
+ await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
65
+ console.log('[smartico] win finalised — show', prize?.aknowledge_message,
66
+ 'and refresh getUserProfile / getMiniGames');
67
+ } else {
68
+ await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
69
+ console.log('[smartico] spin finalised as lost — show',
70
+ prize?.aknowledge_message_lose ?? 'a generic "Better luck next time" message');
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## Empty / loading / error states
76
+
77
+ - In flight: spinner on the CTA, inputs locked.
78
+ - On network failure: re-enable the CTA and let the user retry — the
79
+ operation is safe to repeat. For standard prizes the server-side
80
+ fallback will eventually deliver the win even if every retry fails
81
+ (a pending decline, however, is lost once the fallback fires).
82
+ - No dedicated error codes: a non-zero `err_code` is a generic server
83
+ error — show a generic error toast.
84
+
85
+ ## Related guides
86
+
87
+ - [UI Guide — `playMiniGame`](UIGuide_playMiniGame.md) — prize reveal
88
+ modals, `acknowledge_type` matrix, decline/forfeit flow.
89
+ - [UI Guide — `getMiniGamesHistory`](UIGuide_getMiniGamesHistory.md) —
90
+ unclaimed-row recovery.
@@ -91,20 +91,56 @@ with the `request_id` from that play result when the user taps Claim.
91
91
  [`getMiniGamesHistory`](../../api/classes/WSAPIMiniGames.md#getminigameshistory)
92
92
  row if you need to recover it later.) Note: "explicit claim" prizes
93
93
  are NOT covered by the server-side auto-acknowledge fallback, so for
94
- these you MUST acknowledge or the prize is never credited.
94
+ these you MUST acknowledge or the prize is never credited. To let
95
+ the user decline the prize instead of claiming it, see "Decline /
96
+ forfeit" below.
95
97
 
96
98
  Modal contents per prize:
97
99
 
98
100
  - Icon: `prize.icon` (1:1)
99
101
  - Title: `prize.name`
100
102
  - Message: `prize.aknowledge_message` (note the typo in the field
101
- name — `aknowledge` not `acknowledge`)
103
+ name — `aknowledge` not `acknowledge`). When the spin is finalised
104
+ as lost (see "Decline / forfeit" below), show
105
+ `prize.aknowledge_message_lose` instead, falling back to a generic
106
+ "Better luck next time" when not configured.
102
107
  - CTA: `prize.acknowledge_action_title` with action
103
108
  `prize.acknowledge_dp` (pass through `_smartico.dp()` for safe
104
109
  execution)
105
110
  - Optional additional CTA: `prize.acknowledge_action_title_additional`
106
111
  + `prize.acknowledge_dp_additional`
107
112
 
113
+ ## Decline / forfeit ("lose") flows
114
+
115
+ Some game mechanics let the player decline or forfeit the drawn
116
+ prize — a gamble/discard step, a "keep it or risk it" offer, or a
117
+ game where the player's final action decides whether the pre-drawn
118
+ prize is actually won (the default Smartico UI does this for the
119
+ Voyager game: failing the star-collection run forfeits the drawn
120
+ prize). Implement these with manual finalisation:
121
+
122
+ 1. Play with `acknowledge: false` so the SDK does not auto-finalise.
123
+ 2. Run the game / choice UI.
124
+ 3. Finalise per the outcome:
125
+ - Keep / win →
126
+ `miniGameWinAcknowledgeRequest(request_id)` — prize credited.
127
+ - Decline / lose →
128
+ `miniGameWinAcknowledgeRequest(request_id, { lose: true })` —
129
+ prize NOT credited, returned to the prize pool for other
130
+ players. Show `prize.aknowledge_message_lose` when configured,
131
+ else the same "Better luck next time" treatment as a
132
+ `no-prize` slot (below).
133
+
134
+ Timing: standard prizes are auto-finalised as WON by the
135
+ server-side fallback after ~1–3 minutes, so send the lose decision
136
+ promptly — after the fallback fires, `lose: true` is a no-op and
137
+ the prize stays credited. "Explicit claim" prizes are exempt from
138
+ the fallback, so those have no time pressure. Once a spin is
139
+ finalised either way, further acknowledge calls are no-ops.
140
+
141
+ Full CTA / retry / timing patterns: see
142
+ [UI Guide — `miniGameWinAcknowledgeRequest`](UIGuide_miniGameWinAcknowledgeRequest.md).
143
+
108
144
  ## "No prize" handling
109
145
 
110
146
  When the won prize has `prize_type === 'no-prize'`, the user has
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.409",
3
+ "version": "0.0.411",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,4 +2,6 @@ import { ProtocolMessage } from '.././Base/ProtocolMessage';
2
2
 
3
3
  export interface SAWDoAknowledgeRequest extends ProtocolMessage {
4
4
  request_id: string; // guid
5
+ /** When true, finalises the spin as lost: the prize is not credited and is returned to the prize pool. */
6
+ lose?: boolean;
5
7
  }
@@ -73,6 +73,7 @@ export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[]
73
73
  sectors: p.saw_prize_ui_definition.sectors,
74
74
  acknowledge_type: SAWAcknowledgeTypeNamed(p.saw_prize_ui_definition.acknowledge_type),
75
75
  aknowledge_message: p.saw_prize_ui_definition.aknowledge_message,
76
+ aknowledge_message_lose: p.saw_prize_ui_definition.aknowledge_message_lose,
76
77
  acknowledge_dp: p.saw_prize_ui_definition.acknowledge_dp,
77
78
  acknowledge_action_title: p.saw_prize_ui_definition.acknowledge_action_title,
78
79
  acknowledge_dp_additional: p.saw_prize_ui_definition.acknowledge_dp_additional,
@@ -3,22 +3,40 @@ import { SAWPrizeType } from './SAWPrizeType';
3
3
  import { SAWPrizeUI } from './SAWPrizeUI';
4
4
 
5
5
  export interface SAWPrize {
6
+ /** ID of the prize */
6
7
  saw_prize_id: number;
8
+ /** Visual definition of the prize (name, icon, win-modal buttons, per-game rendering hints) */
7
9
  saw_prize_ui_definition: SAWPrizeUI;
10
+ /** Numeric value for 'points' / 'spin' prize types (e.g. 100 for "100 points"); not relevant for other types */
8
11
  prize_value?: number;
12
+ /** The type of the prize — see {@link SAWPrizeType} */
9
13
  prize_type_id: SAWPrizeType;
14
+ /** Competition games (MatchX / Quiz): first finishing place this prize applies to */
10
15
  place_from?: number;
16
+ /** Competition games (MatchX / Quiz): last finishing place this prize applies to; equals `place_from` for a single-place prize */
11
17
  place_to?: number;
18
+ /** Client-side only — unique id of a win instance generated by the default Smartico UI to dedupe render effects; never sent by the server */
12
19
  sawUniqueWinId?: string;
20
+ /** Remaining stock. Present only when the template's `expose_game_stat_on_api` is enabled; always present for MatchX / Quiz games */
13
21
  pool?: number;
22
+ /** Initial (configured) stock. Present regardless of `expose_game_stat_on_api` */
14
23
  pool_initial?: number;
24
+ /** Times the prize has been won, across all players. Present only when `expose_game_stat_on_api` is enabled */
15
25
  wins_count?: number;
26
+ /** ISO weekday numbers (1 = Monday … 7 = Sunday) the prize can be won on; absent = any day. Present only when `expose_game_stat_on_api` is enabled */
16
27
  weekdays?: number[];
28
+ /** Prize availability window start (epoch ms), evaluated against `relative_period_timezone`. Present only when `expose_game_stat_on_api` is enabled */
17
29
  active_from_ts?: number;
30
+ /** Prize availability window end (epoch ms), evaluated against `relative_period_timezone`. Present only when `expose_game_stat_on_api` is enabled */
18
31
  active_till_ts?: number;
32
+ /** Timezone offset in minutes for `weekdays` / active-window evaluation (UTC minus local, as in JS `Date.getTimezoneOffset()`) */
19
33
  relative_period_timezone?: number;
34
+ /** When true, the prize stays winnable at `pool` 0 (unlimited stock) */
20
35
  is_surcharge?: boolean;
36
+ /** Always `false` in API responses — deleted prizes are excluded server-side */
21
37
  is_deleted?: boolean;
38
+ /** Type-specific prize details — e.g. `gems` / `_gems_diamonds_type` for gems-and-diamonds prizes, `tickets_count` for raffle-ticket prizes */
22
39
  prize_details_json?: {[key: string]: any};
40
+ /** Period basis for the prize availability restriction — see {@link AttemptPeriodType} */
23
41
  max_give_period_type_id?: AttemptPeriodType;
24
42
  }
@@ -8,7 +8,8 @@ export interface SAWPrizeUI {
8
8
  name_original?: string; // keeps original name, how it came from the servers. This is needed for the Jackpot value replacemenet
9
9
  hide_prize_popup: boolean; // if true, prize popup on Prize Drop will not be shown
10
10
  aknowledge_message?: string;
11
- aknowledge_message_lose?: string; // voyager specific
11
+ /** Message shown instead of `aknowledge_message` when the spin is finalised as lost (`lose: true` acknowledge — games with a client-decided outcome, e.g. Voyager) */
12
+ aknowledge_message_lose?: string;
12
13
  sectors?: number[];
13
14
  acknowledge_type?: SAWAcknowledgeType;
14
15
  acknowledge_dp?: string;
@@ -4,31 +4,49 @@ import { SAWPrize } from './SAWPrize';
4
4
  import { SAWTemplateUI } from './SAWTemplateUI';
5
5
 
6
6
  export interface SAWTemplate {
7
+ /** ID of the mini-game template */
7
8
  saw_template_id: number;
9
+ /** The type of the game — see {@link SAWGameType} */
8
10
  saw_game_type_id: SAWGameType;
11
+ /** Full UI definition of the mini-game (name, description, skin, colors, per-game visual settings) */
9
12
  saw_template_ui_definition: SAWTemplateUI;
10
13
 
14
+ /** How the user is charged per attempt — see {@link SAWBuyInType} */
11
15
  saw_buyin_type_id: SAWBuyInType;
16
+ /** Cost per attempt in the buy-in currency (points, gems or diamonds per `saw_buyin_type_id`) */
12
17
  buyin_cost_points?: number;
18
+ /** Operator hint: show the game only while the user can actually play it (has attempts / sufficient balance) */
13
19
  visibile_when_can_spin: boolean;
14
20
 
15
- spin_count?: number; // inital count, after that server will push SAWSpinsCountPush
21
+ /** Number of spin attempts the user currently has (initial value; later changes arrive as spin-count pushes) */
22
+ spin_count?: number;
16
23
 
24
+ /** Prizes configured for this game — see {@link SAWPrize} */
17
25
  prizes: SAWPrize[];
18
26
 
27
+ /** Operator visibility flag for the template */
19
28
  is_visible: boolean;
20
29
 
30
+ /** Time from which the template becomes available (epoch ms); absent when not restricted */
21
31
  activeFromDate?: number;
32
+ /** Time until which the template stays available (epoch ms); absent when not restricted */
22
33
  activeTillDate?: number;
23
34
 
35
+ /** Amount added to the jackpot on every play (abstract contribution — nothing is deducted from the player) */
24
36
  jackpot_add_on_attempt: number;
37
+ /** Current jackpot accumulator value */
25
38
  jackpot_current: number;
39
+ /** Seed value of the jackpot — the accumulator starts at (and resets to) this amount after a jackpot win */
26
40
  jackpot_guaranteed: number;
27
41
 
42
+ /** Maximum number of unspent spin attempts a user can accumulate */
28
43
  maxActiveSpinsAllowed: number;
44
+ /** Maximum number of attempts a user can make during `maxSpinsPediodMs` */
29
45
  maxSpinsCount: number;
46
+ /** Length of the attempt-limit period in ms (note the field-name spelling) */
30
47
  maxSpinsPediodMs: number;
31
48
 
49
+ /** Epoch-ms time when the next attempt becomes available; populated only when the operator enabled the "show time to the next available spin" setting and max attempts per period is 1 */
32
50
  next_available_spin_ts?: number;
33
51
 
34
52
  /** Soonest-expiring spin's expiration time for this user (epoch ms); `null`/absent when no expirable spins. */
@@ -36,7 +54,9 @@ export interface SAWTemplate {
36
54
  /** Latest-expiring spin's expiration time for this user (epoch ms); `null`/absent when no expirable spins. */
37
55
  latest_expiration_dt?: number | null;
38
56
 
57
+ /** Key of the visual skin the operator selected for the game */
39
58
  saw_skin_key: string;
59
+ /** Skin assets of the game: `skin_folder` is the base URL for the skin's images, `skin_css` custom CSS overrides, plus optional popup/animation tweaks */
40
60
  saw_skin_ui_definition: {
41
61
  skin_folder: string;
42
62
  skin_css: string;
@@ -44,11 +64,14 @@ export interface SAWTemplate {
44
64
  lottie_animation_speed?: number;
45
65
  };
46
66
 
67
+ /** Operator template setting. When enabled, the per-prize stock statistics (`pool`, `wins_count`, `weekdays`, `active_from_ts` / `active_till_ts`) are populated on `prizes`; when disabled (default) the server strips them from the response (`pool` is kept for MatchX / Quiz games). */
47
68
  expose_game_stat_on_api?: boolean;
48
69
 
49
- // AA: releavnt only in the context of the SAWPrizeDropWinPush
70
+ /** Prize Drop only: when true, the pushed prize requires an explicit claim by the user before it is credited */
50
71
  requires_prize_claim?: boolean;
51
-
72
+
73
+ /** Timezone offset in minutes used to evaluate the template's period-based rules (UTC minus local, as in JS `Date.getTimezoneOffset()`) */
52
74
  relative_period_timezone?: number;
53
- show_prize_history?:boolean;
75
+ /** Operator setting: show a prize-history entry point (icon / button) on this game's view */
76
+ show_prize_history?: boolean;
54
77
  }
@@ -668,6 +668,11 @@ class SmarticoAPI {
668
668
  '{{jackpot}}',
669
669
  jackpotValue,
670
670
  );
671
+ p.saw_prize_ui_definition.aknowledge_message_lose = IntUtils.replaceAll(
672
+ p.saw_prize_ui_definition.aknowledge_message_lose,
673
+ '{{jackpot}}',
674
+ jackpotValue,
675
+ );
671
676
  });
672
677
  }
673
678
  });
@@ -680,12 +685,13 @@ class SmarticoAPI {
680
685
  return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
681
686
  }
682
687
 
683
- public async doAcknowledgeRequest(user_ext_id: string, request_id: string): Promise<SAWDoAknowledgeResponse> {
688
+ public async doAcknowledgeRequest(user_ext_id: string, request_id: string, lose?: boolean): Promise<SAWDoAknowledgeResponse> {
684
689
  const message = this.buildMessage<SAWDoAknowledgeRequest, SAWDoAknowledgeResponse>(
685
690
  user_ext_id,
686
691
  ClassId.SAW_AKNOWLEDGE_REQUEST,
687
692
  {
688
693
  request_id,
694
+ lose,
689
695
  },
690
696
  );
691
697
 
@@ -2021,7 +2021,7 @@ declare class SmarticoAPI {
2021
2021
  coreCheckSegments(user_ext_id: string, segment_id: number[]): Promise<TSegmentCheckResult[]>;
2022
2022
  sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode?: boolean): Promise<SAWGetTemplatesResponse>;
2023
2023
  sawGetTemplatesT(user_ext_id: string): Promise<TMiniGameTemplate[]>;
2024
- doAcknowledgeRequest(user_ext_id: string, request_id: string): Promise<SAWDoAknowledgeResponse>;
2024
+ doAcknowledgeRequest(user_ext_id: string, request_id: string, lose?: boolean): Promise<SAWDoAknowledgeResponse>;
2025
2025
  sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse>;
2026
2026
  missionOptIn(user_ext_id: string, mission_id: number): Promise<AchievementOptinResponse>;
2027
2027
  missionClaimPrize(user_ext_id: string, mission_id: number, ach_completed_id: number): Promise<AchClaimPrizeResponse>;