@smartico/public-api 0.0.398 → 0.0.399
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/dist/Level/Level.d.ts +1 -0
- package/dist/WSAPI/WSAPIMiniGames.d.ts +77 -28
- package/dist/index.js +77 -28
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +77 -28
- package/dist/index.modern.mjs.map +1 -1
- package/docs/ui/minigames/UIGuide_playMiniGame.md +13 -8
- package/package.json +1 -1
- package/src/Level/Level.ts +1 -0
- package/src/WSAPI/WSAPIMiniGames.ts +77 -28
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
- Action-focused mutation. User clicks "Play" / "Spin" on a mini-
|
|
5
5
|
game card; the server runs the prize selection and returns the
|
|
6
6
|
won prize.
|
|
7
|
-
- Auto-acknowledges on success (
|
|
8
|
-
don't need to handle acknowledge
|
|
7
|
+
- Auto-acknowledges on success by default (`acknowledge: true`, the
|
|
8
|
+
SDK awaits it) — most consumers don't need to handle acknowledge
|
|
9
|
+
manually. Pass `acknowledge: false` to finalise the win yourself
|
|
10
|
+
(see "Prize reveal modals").
|
|
9
11
|
- The SDK does NOT prevent double-clicks at the public API level;
|
|
10
12
|
guard the call site.
|
|
11
13
|
|
|
@@ -80,12 +82,15 @@ UI behavior per `err_code`:
|
|
|
80
82
|
| `FullMessage` (3) | Full-screen modal; user dismisses; auto-acknowledge fires. |
|
|
81
83
|
| `ExplicitAcknowledge` (4) | Modal with explicit "Claim" CTA; acknowledge sends only on tap. Use this for high-value or lootbox-style rewards. |
|
|
82
84
|
|
|
83
|
-
For `ExplicitAcknowledge`,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
For `ExplicitAcknowledge`, gate the acknowledge on the user's Claim
|
|
86
|
+
tap: call `playMiniGame(template_id, { acknowledge: false })` so the
|
|
87
|
+
SDK does NOT auto-finalise, then call
|
|
88
|
+
[`miniGameWinAcknowledgeRequest`](../../api/classes/WSAPIMiniGames.md#minigamewinacknowledgerequest)
|
|
89
|
+
when the user taps Claim. Pass the spin's `client_request_id`, read
|
|
90
|
+
from the matching [`getMiniGamesHistory`](../../api/classes/WSAPIMiniGames.md#getminigameshistory)
|
|
91
|
+
row (it appears with `is_claimed: false`). Note: "explicit claim"
|
|
92
|
+
prizes are NOT covered by the server-side auto-acknowledge fallback,
|
|
93
|
+
so for these you MUST acknowledge or the prize is never credited.
|
|
89
94
|
|
|
90
95
|
Modal contents per prize:
|
|
91
96
|
|
package/package.json
CHANGED
package/src/Level/Level.ts
CHANGED
|
@@ -208,10 +208,12 @@ export class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
208
208
|
/**
|
|
209
209
|
* Plays one round of a mini-game template — runs the server's
|
|
210
210
|
* randomised prize selection, deducts the buy-in cost (if any),
|
|
211
|
-
* and returns the won `prize_id`.
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
211
|
+
* credits the won prize, and returns the won `prize_id`. By default
|
|
212
|
+
* (`acknowledge: true`) the SDK then sends a server-side
|
|
213
|
+
* acknowledgement and AWAITS it before resolving, so the win is
|
|
214
|
+
* marked delivered by the time the promise settles. Pass
|
|
215
|
+
* `acknowledge: false` to skip that step and finalise the win
|
|
216
|
+
* yourself later (see the `acknowledge` parameter).
|
|
215
217
|
*
|
|
216
218
|
* Works for all `SAWGameType` values EXCEPT:
|
|
217
219
|
* - `PrizeDrop` — prizes arrive server-pushed; do NOT call
|
|
@@ -275,17 +277,36 @@ export class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
275
277
|
* corresponding domain methods.
|
|
276
278
|
* - `'manual'` — operator delivers offline.
|
|
277
279
|
*
|
|
278
|
-
* **
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
280
|
+
* **Acknowledge** (the `acknowledge` parameter, default `true`)
|
|
281
|
+
* Every spin is finalised by a follow-up acknowledge step that
|
|
282
|
+
* marks the win delivered. By default the SDK sends that
|
|
283
|
+
* acknowledge and AWAITS it, so `playMiniGame` resolves only after
|
|
284
|
+
* the win is finalised server-side. Keep the default unless you
|
|
285
|
+
* have a specific reason not to.
|
|
286
|
+
*
|
|
287
|
+
* Pass `acknowledge: false` to skip that automatic step.
|
|
288
|
+
* `playMiniGame` then resolves as soon as the spin result is known,
|
|
289
|
+
* without waiting for the win to be marked delivered. You finalise
|
|
290
|
+
* it later by calling {@link miniGameWinAcknowledgeRequest}. The
|
|
291
|
+
* result does NOT carry the spin's request id — obtain it as the
|
|
292
|
+
* `client_request_id` of the matching {@link getMiniGamesHistory}
|
|
293
|
+
* row (the spin appears there with `is_claimed: false`).
|
|
294
|
+
*
|
|
295
|
+
* What `acknowledge: false` does and does NOT defer:
|
|
296
|
+
* - For STANDARD prizes the value is credited at spin time
|
|
297
|
+
* regardless, so opting out does NOT delay the balance change —
|
|
298
|
+
* it only defers the "delivered" bookkeeping and the `is_claimed`
|
|
299
|
+
* flag flipping in {@link getMiniGamesHistory}.
|
|
300
|
+
* - For operator-configured "explicit claim" prizes the credit IS
|
|
301
|
+
* deferred until the spin is acknowledged, so those require an
|
|
302
|
+
* explicit acknowledge to finalise.
|
|
303
|
+
*
|
|
304
|
+
* A server-side fallback auto-acknowledges ordinary un-acknowledged
|
|
305
|
+
* spins after a short delay (about 1–3 minutes), so an ordinary
|
|
306
|
+
* prize is never lost even without consumer action. "Explicit
|
|
307
|
+
* claim" prizes are excluded from that fallback — if you use
|
|
308
|
+
* `acknowledge: false` for one, you MUST acknowledge it explicitly
|
|
309
|
+
* or its prize is never credited.
|
|
289
310
|
*
|
|
290
311
|
* **Idempotency**: NOT idempotent. A double-click sends two
|
|
291
312
|
* spins and deducts the buy-in twice. The SDK does NOT guard
|
|
@@ -304,25 +325,33 @@ export class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
304
325
|
* refreshed array.
|
|
305
326
|
*
|
|
306
327
|
* **Side effects** (on `err_code === 0`)
|
|
307
|
-
* - Buy-in deducted
|
|
308
|
-
*
|
|
309
|
-
* Balance updates flow via the
|
|
310
|
-
* (
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
* -
|
|
315
|
-
* the result status.
|
|
328
|
+
* - Buy-in deducted at spin time (points / gems / diamonds / spin
|
|
329
|
+
* tickets — depending on `saw_buyin_type`), already applied by the
|
|
330
|
+
* time the call resolves. Balance updates flow via the
|
|
331
|
+
* user-properties channel (observe via {@link getUserProfile}).
|
|
332
|
+
* - Prize value credited per the prize's type (see "Prize handling"
|
|
333
|
+
* above). Standard prizes are credited at spin time; "explicit
|
|
334
|
+
* claim" prizes are credited when the spin is acknowledged.
|
|
335
|
+
* - The play is recorded server-side for analytics / reporting.
|
|
316
336
|
*
|
|
317
337
|
* **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
|
|
318
338
|
*
|
|
319
339
|
* **Visitor mode**: not supported. Visitor sessions trying to
|
|
320
340
|
* spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
|
|
321
341
|
*
|
|
322
|
-
* @param template_id
|
|
323
|
-
*
|
|
324
|
-
* @param params
|
|
325
|
-
*
|
|
342
|
+
* @param template_id The mini-game template ID (from
|
|
343
|
+
* `TMiniGameTemplate.id`).
|
|
344
|
+
* @param params Optional options bag.
|
|
345
|
+
* @param params.onUpdate Pass a callback to subscribe to
|
|
346
|
+
* subsequent template refreshes (same
|
|
347
|
+
* channel as {@link getMiniGames}).
|
|
348
|
+
* @param params.acknowledge Whether the SDK automatically sends and
|
|
349
|
+
* awaits the win acknowledge after the
|
|
350
|
+
* spin. Defaults to `true` (recommended).
|
|
351
|
+
* Set `false` to finalise the win yourself
|
|
352
|
+
* via {@link miniGameWinAcknowledgeRequest}
|
|
353
|
+
* — see "Acknowledge" above for the
|
|
354
|
+
* request-id caveat.
|
|
326
355
|
* @returns `{ err_code, err_message, prize_id }` — success when
|
|
327
356
|
* `err_code === 0`. `prize_id` is always populated; look
|
|
328
357
|
* it up in `template.prizes` to interpret the prize.
|
|
@@ -364,6 +393,26 @@ export class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
364
393
|
* console.error('[smartico] play failed — show generic error with this message:', r.err_message);
|
|
365
394
|
* }
|
|
366
395
|
* ```
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* Manual finalisation (`acknowledge: false`) — e.g. an explicit
|
|
399
|
+
* "Claim" CTA, or finalising on your own schedule:
|
|
400
|
+
* ```ts
|
|
401
|
+
* const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
|
|
402
|
+
* if (r.err_code === 0) {
|
|
403
|
+
* // Spin resolved but not yet acknowledged. For standard prizes the
|
|
404
|
+
* // balance already changed server-side; "explicit claim" prizes
|
|
405
|
+
* // are credited only by the acknowledge below.
|
|
406
|
+
* console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
|
|
407
|
+
*
|
|
408
|
+
* // The result has no request id — read it from history as client_request_id.
|
|
409
|
+
* const [row] = await window._smartico.api.getMiniGamesHistory({ saw_template_id: game.id, limit: 1 });
|
|
410
|
+
* if (row && !row.is_claimed) {
|
|
411
|
+
* await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
|
|
412
|
+
* console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
|
|
413
|
+
* }
|
|
414
|
+
* }
|
|
415
|
+
* ```
|
|
367
416
|
*/
|
|
368
417
|
public async playMiniGame(
|
|
369
418
|
template_id: number,
|