@smartico/public-api 0.0.397 → 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 +79 -29
- package/dist/index.js +98 -39
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +82 -29
- 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 +81 -29
package/dist/index.modern.mjs
CHANGED
|
@@ -6851,10 +6851,12 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6851
6851
|
/**
|
|
6852
6852
|
* Plays one round of a mini-game template — runs the server's
|
|
6853
6853
|
* randomised prize selection, deducts the buy-in cost (if any),
|
|
6854
|
-
* and returns the won `prize_id`.
|
|
6855
|
-
*
|
|
6856
|
-
*
|
|
6857
|
-
*
|
|
6854
|
+
* credits the won prize, and returns the won `prize_id`. By default
|
|
6855
|
+
* (`acknowledge: true`) the SDK then sends a server-side
|
|
6856
|
+
* acknowledgement and AWAITS it before resolving, so the win is
|
|
6857
|
+
* marked delivered by the time the promise settles. Pass
|
|
6858
|
+
* `acknowledge: false` to skip that step and finalise the win
|
|
6859
|
+
* yourself later (see the `acknowledge` parameter).
|
|
6858
6860
|
*
|
|
6859
6861
|
* Works for all `SAWGameType` values EXCEPT:
|
|
6860
6862
|
* - `PrizeDrop` — prizes arrive server-pushed; do NOT call
|
|
@@ -6918,17 +6920,36 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6918
6920
|
* corresponding domain methods.
|
|
6919
6921
|
* - `'manual'` — operator delivers offline.
|
|
6920
6922
|
*
|
|
6921
|
-
* **
|
|
6922
|
-
*
|
|
6923
|
-
*
|
|
6924
|
-
*
|
|
6925
|
-
*
|
|
6926
|
-
*
|
|
6927
|
-
*
|
|
6928
|
-
*
|
|
6929
|
-
*
|
|
6930
|
-
*
|
|
6931
|
-
*
|
|
6923
|
+
* **Acknowledge** (the `acknowledge` parameter, default `true`)
|
|
6924
|
+
* Every spin is finalised by a follow-up acknowledge step that
|
|
6925
|
+
* marks the win delivered. By default the SDK sends that
|
|
6926
|
+
* acknowledge and AWAITS it, so `playMiniGame` resolves only after
|
|
6927
|
+
* the win is finalised server-side. Keep the default unless you
|
|
6928
|
+
* have a specific reason not to.
|
|
6929
|
+
*
|
|
6930
|
+
* Pass `acknowledge: false` to skip that automatic step.
|
|
6931
|
+
* `playMiniGame` then resolves as soon as the spin result is known,
|
|
6932
|
+
* without waiting for the win to be marked delivered. You finalise
|
|
6933
|
+
* it later by calling {@link miniGameWinAcknowledgeRequest}. The
|
|
6934
|
+
* result does NOT carry the spin's request id — obtain it as the
|
|
6935
|
+
* `client_request_id` of the matching {@link getMiniGamesHistory}
|
|
6936
|
+
* row (the spin appears there with `is_claimed: false`).
|
|
6937
|
+
*
|
|
6938
|
+
* What `acknowledge: false` does and does NOT defer:
|
|
6939
|
+
* - For STANDARD prizes the value is credited at spin time
|
|
6940
|
+
* regardless, so opting out does NOT delay the balance change —
|
|
6941
|
+
* it only defers the "delivered" bookkeeping and the `is_claimed`
|
|
6942
|
+
* flag flipping in {@link getMiniGamesHistory}.
|
|
6943
|
+
* - For operator-configured "explicit claim" prizes the credit IS
|
|
6944
|
+
* deferred until the spin is acknowledged, so those require an
|
|
6945
|
+
* explicit acknowledge to finalise.
|
|
6946
|
+
*
|
|
6947
|
+
* A server-side fallback auto-acknowledges ordinary un-acknowledged
|
|
6948
|
+
* spins after a short delay (about 1–3 minutes), so an ordinary
|
|
6949
|
+
* prize is never lost even without consumer action. "Explicit
|
|
6950
|
+
* claim" prizes are excluded from that fallback — if you use
|
|
6951
|
+
* `acknowledge: false` for one, you MUST acknowledge it explicitly
|
|
6952
|
+
* or its prize is never credited.
|
|
6932
6953
|
*
|
|
6933
6954
|
* **Idempotency**: NOT idempotent. A double-click sends two
|
|
6934
6955
|
* spins and deducts the buy-in twice. The SDK does NOT guard
|
|
@@ -6947,25 +6968,33 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6947
6968
|
* refreshed array.
|
|
6948
6969
|
*
|
|
6949
6970
|
* **Side effects** (on `err_code === 0`)
|
|
6950
|
-
* - Buy-in deducted
|
|
6951
|
-
*
|
|
6952
|
-
* Balance updates flow via the
|
|
6953
|
-
* (
|
|
6954
|
-
*
|
|
6955
|
-
*
|
|
6956
|
-
*
|
|
6957
|
-
* -
|
|
6958
|
-
* the result status.
|
|
6971
|
+
* - Buy-in deducted at spin time (points / gems / diamonds / spin
|
|
6972
|
+
* tickets — depending on `saw_buyin_type`), already applied by the
|
|
6973
|
+
* time the call resolves. Balance updates flow via the
|
|
6974
|
+
* user-properties channel (observe via {@link getUserProfile}).
|
|
6975
|
+
* - Prize value credited per the prize's type (see "Prize handling"
|
|
6976
|
+
* above). Standard prizes are credited at spin time; "explicit
|
|
6977
|
+
* claim" prizes are credited when the spin is acknowledged.
|
|
6978
|
+
* - The play is recorded server-side for analytics / reporting.
|
|
6959
6979
|
*
|
|
6960
6980
|
* **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
|
|
6961
6981
|
*
|
|
6962
6982
|
* **Visitor mode**: not supported. Visitor sessions trying to
|
|
6963
6983
|
* spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
|
|
6964
6984
|
*
|
|
6965
|
-
* @param template_id
|
|
6966
|
-
*
|
|
6967
|
-
* @param params
|
|
6968
|
-
*
|
|
6985
|
+
* @param template_id The mini-game template ID (from
|
|
6986
|
+
* `TMiniGameTemplate.id`).
|
|
6987
|
+
* @param params Optional options bag.
|
|
6988
|
+
* @param params.onUpdate Pass a callback to subscribe to
|
|
6989
|
+
* subsequent template refreshes (same
|
|
6990
|
+
* channel as {@link getMiniGames}).
|
|
6991
|
+
* @param params.acknowledge Whether the SDK automatically sends and
|
|
6992
|
+
* awaits the win acknowledge after the
|
|
6993
|
+
* spin. Defaults to `true` (recommended).
|
|
6994
|
+
* Set `false` to finalise the win yourself
|
|
6995
|
+
* via {@link miniGameWinAcknowledgeRequest}
|
|
6996
|
+
* — see "Acknowledge" above for the
|
|
6997
|
+
* request-id caveat.
|
|
6969
6998
|
* @returns `{ err_code, err_message, prize_id }` — success when
|
|
6970
6999
|
* `err_code === 0`. `prize_id` is always populated; look
|
|
6971
7000
|
* it up in `template.prizes` to interpret the prize.
|
|
@@ -7007,14 +7036,38 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7007
7036
|
* console.error('[smartico] play failed — show generic error with this message:', r.err_message);
|
|
7008
7037
|
* }
|
|
7009
7038
|
* ```
|
|
7039
|
+
*
|
|
7040
|
+
* @example
|
|
7041
|
+
* Manual finalisation (`acknowledge: false`) — e.g. an explicit
|
|
7042
|
+
* "Claim" CTA, or finalising on your own schedule:
|
|
7043
|
+
* ```ts
|
|
7044
|
+
* const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
|
|
7045
|
+
* if (r.err_code === 0) {
|
|
7046
|
+
* // Spin resolved but not yet acknowledged. For standard prizes the
|
|
7047
|
+
* // balance already changed server-side; "explicit claim" prizes
|
|
7048
|
+
* // are credited only by the acknowledge below.
|
|
7049
|
+
* console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
|
|
7050
|
+
*
|
|
7051
|
+
* // The result has no request id — read it from history as client_request_id.
|
|
7052
|
+
* const [row] = await window._smartico.api.getMiniGamesHistory({ saw_template_id: game.id, limit: 1 });
|
|
7053
|
+
* if (row && !row.is_claimed) {
|
|
7054
|
+
* await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
|
|
7055
|
+
* console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
|
|
7056
|
+
* }
|
|
7057
|
+
* }
|
|
7058
|
+
* ```
|
|
7010
7059
|
*/
|
|
7011
7060
|
async playMiniGame(template_id, {
|
|
7012
|
-
onUpdate
|
|
7061
|
+
onUpdate,
|
|
7062
|
+
acknowledge = true
|
|
7013
7063
|
} = {}) {
|
|
7014
7064
|
if (typeof onUpdate === 'function') {
|
|
7015
7065
|
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
7016
7066
|
}
|
|
7017
7067
|
const r = await this.api.sawSpinRequest(this.userExtId, template_id);
|
|
7068
|
+
if (acknowledge) {
|
|
7069
|
+
await this.api.doAcknowledgeRequest(this.userExtId, r.request_id);
|
|
7070
|
+
}
|
|
7018
7071
|
const o = {
|
|
7019
7072
|
err_code: r.errCode,
|
|
7020
7073
|
err_message: r.errMsg,
|