@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
package/dist/index.js
CHANGED
|
@@ -153,6 +153,8 @@ exports.ClassId = void 0;
|
|
|
153
153
|
ClassId[ClassId["RAF_CLAIM_PRIZE_RESPONSE"] = 909] = "RAF_CLAIM_PRIZE_RESPONSE";
|
|
154
154
|
ClassId[ClassId["RAF_OPTIN_REQUEST"] = 916] = "RAF_OPTIN_REQUEST";
|
|
155
155
|
ClassId[ClassId["RAF_OPTIN_RESPONSE"] = 917] = "RAF_OPTIN_RESPONSE";
|
|
156
|
+
ClassId[ClassId["RAF_GET_WON_PRIZES_REQUEST"] = 920] = "RAF_GET_WON_PRIZES_REQUEST";
|
|
157
|
+
ClassId[ClassId["RAF_GET_WON_PRIZES_RESPONSE"] = 921] = "RAF_GET_WON_PRIZES_RESPONSE";
|
|
156
158
|
/*
|
|
157
159
|
RAF_GET_TICKETS_REQUEST = 902,
|
|
158
160
|
RAF_GET_TICKETS_RESPONSE = 903,
|
|
@@ -2476,7 +2478,7 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
|
|
|
2476
2478
|
*
|
|
2477
2479
|
* **Inbox unread count** — `core_inbox_unread_count` on this profile
|
|
2478
2480
|
* is push-updated in real time (under 1 second). For an inbox badge,
|
|
2479
|
-
* prefer this field over
|
|
2481
|
+
* prefer this field over `getInboxUnreadCount` (which is cached
|
|
2480
2482
|
* for 30 s) — same value, fresher signal.
|
|
2481
2483
|
*
|
|
2482
2484
|
* **Language**: `core_user_language` reflects the server's stored
|
|
@@ -2546,15 +2548,75 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
|
|
|
2546
2548
|
throw new Error('Tracker is not initialized, cannot getUserProfile');
|
|
2547
2549
|
}
|
|
2548
2550
|
}
|
|
2549
|
-
/**
|
|
2550
|
-
*
|
|
2551
|
-
*
|
|
2552
|
-
*
|
|
2553
|
-
*
|
|
2551
|
+
/**
|
|
2552
|
+
* Checks whether the current user matches a single segment, returning
|
|
2553
|
+
* `true` / `false` directly. Use this as a decision primitive to gate
|
|
2554
|
+
* UI surfaces (e.g. show a "VIP lounge" tab only when the user is in
|
|
2555
|
+
* the VIP segment), or to drive segment-specific CTA copy.
|
|
2556
|
+
*
|
|
2557
|
+
* Every call is a server round-trip — there is no SDK-side cache. For
|
|
2558
|
+
* checking multiple segments in one round-trip, use
|
|
2559
|
+
* {@link checkSegmentListMatch} instead.
|
|
2560
|
+
*
|
|
2561
|
+
* @remarks
|
|
2562
|
+
* **Refresh model**
|
|
2563
|
+
* - **No client cache.** Every call sends a request; the SDK does not
|
|
2564
|
+
* memoize results.
|
|
2565
|
+
* - **No push event** notifies the consumer when segment membership
|
|
2566
|
+
* flips (the user crosses a qualification threshold, or the
|
|
2567
|
+
* operator changes the segment definition). Membership changes
|
|
2568
|
+
* become visible only on the next `checkSegmentMatch` call.
|
|
2569
|
+
* - **Behavioral segments (configured against BigQuery) have batch
|
|
2570
|
+
* lag** — even if the user's activity has changed (deposit, wager,
|
|
2571
|
+
* etc.), the segment-membership result may not reflect that change
|
|
2572
|
+
* until the next batch evaluation run (typically up to several
|
|
2573
|
+
* hours).
|
|
2574
|
+
*
|
|
2575
|
+
* **Rate limit** (important)
|
|
2576
|
+
* The server caps `checkSegment*` calls at **10 requests per
|
|
2577
|
+
* 60-second window**, with a minimum gap of **~5 seconds between
|
|
2578
|
+
* consecutive calls**. Avoid calling on every render — cache the
|
|
2579
|
+
* result client-side for the session, or until you have a reason to
|
|
2580
|
+
* believe the user's state changed (e.g. after a deposit completes,
|
|
2581
|
+
* a level changes via {@link getUserProfile}'s `props_change`, or a
|
|
2582
|
+
* specific custom event fires).
|
|
2583
|
+
*
|
|
2584
|
+
* **`is_matching: false` is ambiguous on the server** — both "the
|
|
2585
|
+
* segment doesn't exist for this label" and "the user doesn't
|
|
2586
|
+
* qualify" return `false` with no distinguishing signal. Pass IDs
|
|
2587
|
+
* you've verified are valid for your label.
|
|
2588
|
+
*
|
|
2589
|
+
* **Idempotency**: safe. Read-only. No side effects (no analytics
|
|
2590
|
+
* events, no DB writes).
|
|
2591
|
+
*
|
|
2592
|
+
* **Visitor mode**: not supported.
|
|
2593
|
+
*
|
|
2594
|
+
* @param segment_id The segment ID. Segment IDs are label-scoped;
|
|
2595
|
+
* the same numeric ID can refer to different
|
|
2596
|
+
* segments under different labels. Use the IDs
|
|
2597
|
+
* configured for your label.
|
|
2598
|
+
* @returns `true` if the user currently matches the
|
|
2599
|
+
* segment, `false` otherwise. `false` also covers
|
|
2600
|
+
* the "segment doesn't exist for this label"
|
|
2601
|
+
* case — these are not distinguishable.
|
|
2602
|
+
*
|
|
2603
|
+
* @example
|
|
2604
|
+
* ```ts
|
|
2605
|
+
* const isVip = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
2606
|
+
* if (isVip) {
|
|
2607
|
+
* console.log('[smartico] user is in VIP segment — render the VIP-only widget surface');
|
|
2608
|
+
* } else {
|
|
2609
|
+
* console.log('[smartico] user not in VIP segment (or segment id misconfigured) — hide the VIP surface');
|
|
2610
|
+
* }
|
|
2611
|
+
*
|
|
2612
|
+
* // Cache the result for the session; re-check after material user-state changes.
|
|
2613
|
+
* window._smartico.on('props_change', async (changed) => {
|
|
2614
|
+
* if ('ach_points_ever' in changed || 'ach_level_current_id' in changed) {
|
|
2615
|
+
* const fresh = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
2616
|
+
* console.log('[smartico] user state changed — VIP membership now:', fresh);
|
|
2617
|
+
* }
|
|
2554
2618
|
* });
|
|
2555
2619
|
* ```
|
|
2556
|
-
*
|
|
2557
|
-
* **Visitor mode: not supported**
|
|
2558
2620
|
*/;
|
|
2559
2621
|
_proto.checkSegmentMatch = function checkSegmentMatch(segment_id) {
|
|
2560
2622
|
try {
|
|
@@ -2572,14 +2634,67 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
|
|
|
2572
2634
|
return Promise.reject(e);
|
|
2573
2635
|
}
|
|
2574
2636
|
}
|
|
2575
|
-
/**
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2637
|
+
/**
|
|
2638
|
+
* Checks the current user's membership in multiple segments in a
|
|
2639
|
+
* single server round-trip — returns a `TSegmentCheckResult[]` with
|
|
2640
|
+
* one entry per *unique* segment ID. Use this instead of looping
|
|
2641
|
+
* {@link checkSegmentMatch} when you need to evaluate several
|
|
2642
|
+
* segments at once (e.g. multi-segment composite gating, A/B-style
|
|
2643
|
+
* cohort detection).
|
|
2644
|
+
*
|
|
2645
|
+
* @remarks
|
|
2646
|
+
* **Response order is NOT guaranteed**
|
|
2647
|
+
* The server returns results in an unspecified order — different
|
|
2648
|
+
* from the input array. Always correlate by the `segment_id` field on
|
|
2649
|
+
* each `TSegmentCheckResult` rather than by array position. The
|
|
2650
|
+
* returned array length may also be smaller than the input array
|
|
2651
|
+
* (duplicate IDs are silently de-duplicated server-side).
|
|
2652
|
+
*
|
|
2653
|
+
* **Single round-trip**
|
|
2654
|
+
* The entire `segment_ids` array is sent in one request. Two segments
|
|
2655
|
+
* cost the same as one in terms of network latency and rate-limit
|
|
2656
|
+
* consumption (one call = one rate-limit slot, regardless of how many
|
|
2657
|
+
* segments).
|
|
2658
|
+
*
|
|
2659
|
+
* **Shared semantics with `checkSegmentMatch`**
|
|
2660
|
+
* Both methods wrap the same underlying server endpoint and share
|
|
2661
|
+
* the same caching, refresh, rate-limit, and ambiguity behavior. See
|
|
2662
|
+
* {@link checkSegmentMatch} for: no client cache · no push event for
|
|
2663
|
+
* membership changes · behavioral segments have batch lag · rate
|
|
2664
|
+
* limit (10 requests / 60 s, ~5 s minimum gap between calls) ·
|
|
2665
|
+
* `is_matching: false` doesn't distinguish "not in segment" from
|
|
2666
|
+
* "segment doesn't exist for this label".
|
|
2667
|
+
*
|
|
2668
|
+
* **Idempotency**: safe. Read-only. No side effects.
|
|
2669
|
+
*
|
|
2670
|
+
* **Visitor mode**: not supported.
|
|
2671
|
+
*
|
|
2672
|
+
* @param segment_ids Array of segment IDs to check. Duplicates are
|
|
2673
|
+
* silently de-duplicated server-side. Segment IDs
|
|
2674
|
+
* are label-scoped — use the IDs configured for
|
|
2675
|
+
* your label.
|
|
2676
|
+
* @returns Array of `{ segment_id, is_matching }` results.
|
|
2677
|
+
* Order is NOT guaranteed; correlate by
|
|
2678
|
+
* `segment_id`. Length may be less than the input
|
|
2679
|
+
* when duplicate IDs were sent.
|
|
2680
|
+
*
|
|
2681
|
+
* @example
|
|
2682
|
+
* ```ts
|
|
2683
|
+
* const segmentIds = [vipSegmentId, newPlayerSegmentId, freeRollSegmentId];
|
|
2684
|
+
* const results = await window._smartico.api.checkSegmentListMatch(segmentIds);
|
|
2685
|
+
*
|
|
2686
|
+
* // Always correlate by segment_id — the response order is unspecified.
|
|
2687
|
+
* const byId = new Map(results.map(r => [r.segment_id, r.is_matching]));
|
|
2688
|
+
*
|
|
2689
|
+
* if (byId.get(vipSegmentId)) {
|
|
2690
|
+
* console.log('[smartico] user is in VIP segment — render VIP surface');
|
|
2691
|
+
* }
|
|
2692
|
+
* if (byId.get(newPlayerSegmentId) && byId.get(freeRollSegmentId)) {
|
|
2693
|
+
* console.log('[smartico] new player AND eligible for free roll — show the welcome promo');
|
|
2694
|
+
* }
|
|
2695
|
+
*
|
|
2696
|
+
* // Cache the result map for the session; refresh on material state changes.
|
|
2581
2697
|
* ```
|
|
2582
|
-
* **Visitor mode: not supported**
|
|
2583
2698
|
*/
|
|
2584
2699
|
;
|
|
2585
2700
|
_proto.checkSegmentListMatch = function checkSegmentListMatch(segment_ids) {
|
|
@@ -2759,7 +2874,7 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
|
|
|
2759
2874
|
* The SDK exposes raw numeric values; the meaning of each counter
|
|
2760
2875
|
* (deposit amount, wager amount, lifetime spend, etc.) is fully
|
|
2761
2876
|
* operator-defined per label. Resolve labels for display via
|
|
2762
|
-
*
|
|
2877
|
+
* `getTranslations` — the operator's display strings are
|
|
2763
2878
|
* stored under the translation keys `levelsCounter1Name` and
|
|
2764
2879
|
* `levelsCounter2Name`.
|
|
2765
2880
|
*
|
|
@@ -2825,36 +2940,68 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
|
|
|
2825
2940
|
}
|
|
2826
2941
|
}
|
|
2827
2942
|
/**
|
|
2828
|
-
* Returns the
|
|
2829
|
-
*
|
|
2830
|
-
*
|
|
2831
|
-
*
|
|
2832
|
-
* You can pass the onUpdate callback as a parameter, it will be called every time the activity log is updated and will provide the updated list of activity logs for the last 10 minutes.
|
|
2943
|
+
* Returns the user's unified balance-change history — every points, gems, and
|
|
2944
|
+
* diamonds transaction within the requested time window, ordered newest-first.
|
|
2945
|
+
* Use to power an "Activity" / "History" tab showing wins, claims, purchases,
|
|
2946
|
+
* level-up rewards, and operator adjustments.
|
|
2833
2947
|
*
|
|
2834
|
-
*
|
|
2835
|
-
*
|
|
2836
|
-
*
|
|
2837
|
-
*
|
|
2838
|
-
*
|
|
2839
|
-
* _smartico.api.getActivityLog({
|
|
2840
|
-
* startTimeSeconds: startTime,
|
|
2841
|
-
* endTimeSeconds: endTime,
|
|
2842
|
-
* from: 0,
|
|
2843
|
-
* to: 50,
|
|
2844
|
-
* onUpdate: (data) => console.log('Updated:', data)
|
|
2845
|
-
* }).then((result) => {
|
|
2846
|
-
* console.log(result);
|
|
2847
|
-
* });
|
|
2848
|
-
* ```
|
|
2948
|
+
* The returned shape is the same regardless of currency type — `type` (see
|
|
2949
|
+
* {@link UserBalanceType}) distinguishes points / gems / diamonds and
|
|
2950
|
+
* `source_type_id` (see {@link PointChangeSourceType}) names the originating
|
|
2951
|
+
* event.
|
|
2849
2952
|
*
|
|
2850
|
-
*
|
|
2953
|
+
* @remarks
|
|
2954
|
+
* **Preconditions**
|
|
2955
|
+
* - User must be authenticated. Visitor mode is not guarded at the SDK level
|
|
2956
|
+
* but is not meaningful — activity is per-user.
|
|
2957
|
+
*
|
|
2958
|
+
* **Pagination — `from` / `to` are offset + ceiling, not timestamps**
|
|
2959
|
+
* The SDK derives `offset = from`, `limit = min(to - from, 50)` — the server
|
|
2960
|
+
* hard-caps a single response at 50 entries. For infinite scroll, advance
|
|
2961
|
+
* `from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
|
|
2962
|
+
* are epoch seconds bounding the window the server scans.
|
|
2963
|
+
*
|
|
2964
|
+
* **Subscription model (`onUpdate`)**
|
|
2965
|
+
* The callback fires when the user's `ach_points_balance`,
|
|
2966
|
+
* `ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
|
|
2967
|
+
* wallet event lands). The pushed payload is a FIXED re-fetch of the
|
|
2968
|
+
* **last 10 minutes / first 50 entries** — it does NOT honor the original
|
|
2969
|
+
* call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to`. Consumers
|
|
2970
|
+
* maintaining a long historical view must re-call `getActivityLog` with
|
|
2971
|
+
* their own params after receiving an `onUpdate` notification.
|
|
2972
|
+
*
|
|
2973
|
+
* **Refresh**
|
|
2974
|
+
* - The SDK caches results for 30 seconds.
|
|
2975
|
+
* - Push triggers fire only on balance changes; transactions that don't
|
|
2976
|
+
* alter a balance (theoretical zero-amount entries) won't refresh.
|
|
2977
|
+
*
|
|
2978
|
+
* **Visitor mode**: not meaningful (no per-user history available).
|
|
2979
|
+
*
|
|
2980
|
+
* **UI guidance**: see [UI Guide — `getActivityLog`](../../docs/ui/user/UIGuide_getActivityLog.md).
|
|
2851
2981
|
*
|
|
2852
|
-
* @
|
|
2853
|
-
*
|
|
2854
|
-
* @
|
|
2855
|
-
*
|
|
2856
|
-
*
|
|
2857
|
-
*
|
|
2982
|
+
* @returns Array of {@link TActivityLog} ordered newest-first.
|
|
2983
|
+
*
|
|
2984
|
+
* @example
|
|
2985
|
+
* ```ts
|
|
2986
|
+
* const now = Math.floor(Date.now() / 1000);
|
|
2987
|
+
* const start = now - 86400 * 30; // 30 days
|
|
2988
|
+
*
|
|
2989
|
+
* const log = await window._smartico.api.getActivityLog({
|
|
2990
|
+
* startTimeSeconds: start,
|
|
2991
|
+
* endTimeSeconds: now,
|
|
2992
|
+
* from: 0,
|
|
2993
|
+
* to: 50,
|
|
2994
|
+
* onUpdate: (refreshed) => {
|
|
2995
|
+
* console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
|
|
2996
|
+
* // If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
|
|
2997
|
+
* },
|
|
2998
|
+
* });
|
|
2999
|
+
*
|
|
3000
|
+
* for (const row of log) {
|
|
3001
|
+
* const sign = row.amount >= 0 ? '+' : '';
|
|
3002
|
+
* console.log('[smartico] activity row — render with', row.type === 0 ? 'points' : row.type === 1 ? 'gems' : 'diamonds', 'icon, color by sign:', sign + row.amount, 'balance after:', row.balance, 'source:', row.source_type_id);
|
|
3003
|
+
* }
|
|
3004
|
+
* ```
|
|
2858
3005
|
*/
|
|
2859
3006
|
;
|
|
2860
3007
|
_proto.getActivityLog = function getActivityLog(_ref) {
|
|
@@ -2897,6 +3044,57 @@ var WSAPIGeneral = /*#__PURE__*/function (_WSAPIUser) {
|
|
|
2897
3044
|
}
|
|
2898
3045
|
_inheritsLoose(WSAPIGeneral, _WSAPIUser);
|
|
2899
3046
|
var _proto = WSAPIGeneral.prototype;
|
|
3047
|
+
/**
|
|
3048
|
+
* Returns the operator-configured "custom sections" the current user is eligible
|
|
3049
|
+
* to see. Custom sections are nav-level entries the operator builds in the BO —
|
|
3050
|
+
* HTML pages, themed mission grids, store / raffle / tournament category pages,
|
|
3051
|
+
* lootbox calendars, redirect links, and Liquid-templated dashboards — each
|
|
3052
|
+
* surfaced with its own icon and label.
|
|
3053
|
+
*
|
|
3054
|
+
* Use the response to build the side menu / bottom-bar / nav grid of a
|
|
3055
|
+
* gamification widget. Each section's `section_type_id` (see
|
|
3056
|
+
* {@link AchCustomSectionType}) tells the consumer which page component to mount
|
|
3057
|
+
* when the user opens the section.
|
|
3058
|
+
*
|
|
3059
|
+
* @remarks
|
|
3060
|
+
* **Preconditions**
|
|
3061
|
+
* - No prerequisite calls. Typically fetched once at app boot to build the
|
|
3062
|
+
* navigation skeleton.
|
|
3063
|
+
*
|
|
3064
|
+
* **Server-side eligibility filtering**
|
|
3065
|
+
* Sections are filtered server-side by the user's segments / level / brand and
|
|
3066
|
+
* the section's `active_from_date` / `active_till_date` window. Sections the
|
|
3067
|
+
* user is ineligible for are omitted from the response entirely — there is no
|
|
3068
|
+
* "locked" state to render.
|
|
3069
|
+
*
|
|
3070
|
+
* **Ordering**
|
|
3071
|
+
* Response is server-ordered. Render in the order received; do NOT re-sort
|
|
3072
|
+
* client-side (the operator's order is the intended nav order).
|
|
3073
|
+
*
|
|
3074
|
+
* **Refresh**
|
|
3075
|
+
* - The SDK caches results for 30 seconds.
|
|
3076
|
+
* - No push subscription. Re-call after a segment / level change might
|
|
3077
|
+
* make new sections eligible, or just rely on the 30 s cache turnover.
|
|
3078
|
+
*
|
|
3079
|
+
* **Visitor mode**: supported.
|
|
3080
|
+
*
|
|
3081
|
+
* **UI guidance**: see [UI Guide — `getCustomSections`](../../docs/ui/general/UIGuide_getCustomSections.md).
|
|
3082
|
+
*
|
|
3083
|
+
* @returns Array of {@link TUICustomSection} — empty if the label has no
|
|
3084
|
+
* active custom sections or the user is ineligible for all of them.
|
|
3085
|
+
*
|
|
3086
|
+
* @example
|
|
3087
|
+
* ```ts
|
|
3088
|
+
* const sections = await window._smartico.api.getCustomSections();
|
|
3089
|
+
*
|
|
3090
|
+
* for (const s of sections) {
|
|
3091
|
+
* console.log('[smartico] nav entry', s.menu_name, 'type', s.section_type_id, '→ mount the matching page component');
|
|
3092
|
+
* // Render s.menu_img (64x64) as the nav icon and s.menu_name as the label.
|
|
3093
|
+
* // For section_type_id === AchCustomSectionType.REDIRECT_LINK, do NOT mount a page —
|
|
3094
|
+
* // resolve s.url_or_dp on click (DP string or external URL).
|
|
3095
|
+
* }
|
|
3096
|
+
* ```
|
|
3097
|
+
*/
|
|
2900
3098
|
_proto.getCustomSections = function getCustomSections() {
|
|
2901
3099
|
try {
|
|
2902
3100
|
var _this = this;
|
|
@@ -2908,7 +3106,59 @@ var WSAPIGeneral = /*#__PURE__*/function (_WSAPIUser) {
|
|
|
2908
3106
|
}
|
|
2909
3107
|
}
|
|
2910
3108
|
/**
|
|
2911
|
-
*
|
|
3109
|
+
* Returns the full set of operator-defined translation key/value pairs for the
|
|
3110
|
+
* label, merged across the requested language and the English baseline.
|
|
3111
|
+
*
|
|
3112
|
+
* Translation keys are free-form strings defined by the operator in the BO. The
|
|
3113
|
+
* SDK consumer treats the result as a flat dictionary: `translations[key]`. If
|
|
3114
|
+
* the key is missing entirely, do NOT trust `undefined` semantics — defensively
|
|
3115
|
+
* fall back to the key string itself or a hardcoded literal.
|
|
3116
|
+
*
|
|
3117
|
+
* @remarks
|
|
3118
|
+
* **Preconditions**
|
|
3119
|
+
* - No prerequisite calls.
|
|
3120
|
+
* - `lang_code` is the ISO language code the operator uses in the BO
|
|
3121
|
+
* (e.g. `"EN"`, `"FR"`, `"ES"`). Case is not normalised — match what the
|
|
3122
|
+
* operator configured.
|
|
3123
|
+
*
|
|
3124
|
+
* **EN fallback**
|
|
3125
|
+
* The SDK issues an English-baseline fetch first, then overlays the
|
|
3126
|
+
* `lang_code` translations on top. Any key the operator has only defined in
|
|
3127
|
+
* English (i.e. missing in the requested language) is returned with the
|
|
3128
|
+
* English value. Keys missing in both are absent from the map — the consumer
|
|
3129
|
+
* must handle missing keys (the default Smartico UI returns the key string
|
|
3130
|
+
* itself as the fallback text).
|
|
3131
|
+
*
|
|
3132
|
+
* **What's included**
|
|
3133
|
+
* The SDK passes an empty `areas` filter to the server, which returns ALL
|
|
3134
|
+
* translation namespaces configured for the label (Gamification, Casino,
|
|
3135
|
+
* Trading, Affiliation, etc. — whichever are populated). For a Gamification-
|
|
3136
|
+
* only widget, the consumer can ignore unused namespaces — keys are flat
|
|
3137
|
+
* strings, not nested.
|
|
3138
|
+
*
|
|
3139
|
+
* **Refresh**
|
|
3140
|
+
* - Cached internally per `(lang_code, label, brand)` for ~30 seconds.
|
|
3141
|
+
* - No push subscription. Operators editing translations in the BO will see
|
|
3142
|
+
* the change after the cache window expires.
|
|
3143
|
+
*
|
|
3144
|
+
* **Visitor mode**: supported. Translations are label-scoped, not user-
|
|
3145
|
+
* scoped — `lang_code` is the sole language selector and is independent of
|
|
3146
|
+
* the `vapi(lang)` argument used elsewhere.
|
|
3147
|
+
*
|
|
3148
|
+
* @param lang_code ISO language code (e.g. `"EN"`, `"FR"`). Defaults to
|
|
3149
|
+
* `"EN"` server-side if empty.
|
|
3150
|
+
* @returns {@link TGetTranslations} — `{ translations: { [key]: string } }`.
|
|
3151
|
+
*
|
|
3152
|
+
* @example
|
|
3153
|
+
* ```ts
|
|
3154
|
+
* const r = await window._smartico.api.getTranslations('FR');
|
|
3155
|
+
*
|
|
3156
|
+
* // Defensive lookup: fall back to the key itself if the operator hasn't
|
|
3157
|
+
* // defined the string.
|
|
3158
|
+
* const t = (k: string) => r.translations[k] ?? k;
|
|
3159
|
+
*
|
|
3160
|
+
* console.log('[smartico] localized label "missions_title" →', t('missions_title'));
|
|
3161
|
+
* ```
|
|
2912
3162
|
*/
|
|
2913
3163
|
;
|
|
2914
3164
|
_proto.getTranslations = function getTranslations(lang_code) {
|
|
@@ -2924,21 +3174,60 @@ var WSAPIGeneral = /*#__PURE__*/function (_WSAPIUser) {
|
|
|
2924
3174
|
}
|
|
2925
3175
|
}
|
|
2926
3176
|
/**
|
|
2927
|
-
* Returns
|
|
2928
|
-
*
|
|
3177
|
+
* Returns the missions and tournaments associated with a casino / sportsbook
|
|
3178
|
+
* game in the operator's games catalog — the reverse of "given this mission,
|
|
3179
|
+
* which games count for it" — so you can surface "play this game to progress
|
|
3180
|
+
* mission X" / "tournament Y features this game" badges on game tiles or
|
|
3181
|
+
* detail screens.
|
|
2929
3182
|
*
|
|
2930
|
-
*
|
|
2931
|
-
*
|
|
2932
|
-
* _smartico.api.getRelatedItemsForGame('gold-slot2').then((result) => {
|
|
2933
|
-
* console.log(result);
|
|
2934
|
-
* });
|
|
2935
|
-
* ```
|
|
3183
|
+
* The shape mirrors `getMissions` (`UserAchievement[]`) and `getTournamentsList`
|
|
3184
|
+
* (`Tournament[]`) — same wire types, no reduced subset.
|
|
2936
3185
|
*
|
|
2937
|
-
*
|
|
2938
|
-
*
|
|
2939
|
-
*
|
|
2940
|
-
*
|
|
2941
|
-
* })
|
|
3186
|
+
* @remarks
|
|
3187
|
+
* **Preconditions**
|
|
3188
|
+
* - `related_game_id` must be a Games Catalog ID (the same external string the
|
|
3189
|
+
* operator uses in the catalog at
|
|
3190
|
+
* {@link https://help.smartico.ai/welcome/technical-guides/games-catalog-api}).
|
|
3191
|
+
*
|
|
3192
|
+
* **Server-side eligibility filtering**
|
|
3193
|
+
* Missions and tournaments are filtered by the user's segments / level / brand
|
|
3194
|
+
* before being returned. A user who is ineligible for a mission segment will
|
|
3195
|
+
* NOT see that mission in the result even if it lists the game. The same
|
|
3196
|
+
* filtering applies to tournaments. Treat the response as "what this user
|
|
3197
|
+
* should see" — no client-side eligibility pass needed.
|
|
3198
|
+
*
|
|
3199
|
+
* **No cache**
|
|
3200
|
+
* Every call is a live server round-trip. Missions/tournaments are operator-
|
|
3201
|
+
* mutated state (opt-in, completion, expiry) that changes during a session;
|
|
3202
|
+
* caching staler than the user's last action would mis-render eligibility.
|
|
3203
|
+
* Avoid building a consumer-side cache for UI-critical paths.
|
|
3204
|
+
*
|
|
3205
|
+
* **Refresh**
|
|
3206
|
+
* - Re-call when the user navigates to a new game tile / detail surface.
|
|
3207
|
+
* - Re-call after the user opts into / completes a related mission to refresh
|
|
3208
|
+
* the "play this game" badge.
|
|
3209
|
+
*
|
|
3210
|
+
* **Visitor mode**: supported via `_smartico.vapi(lang).getRelatedItemsForGame(...)`.
|
|
3211
|
+
*
|
|
3212
|
+
* **UI guidance**: see [UI Guide — `getRelatedItemsForGame`](../../docs/ui/general/UIGuide_getRelatedItemsForGame.md).
|
|
3213
|
+
*
|
|
3214
|
+
* @param related_game_id External Games Catalog ID of the game (e.g. `"gold-slot2"`).
|
|
3215
|
+
* @returns {@link GetRelatedAchTourResponse} — `{ achievements, tournaments? }`.
|
|
3216
|
+
* `tournaments` may be `undefined` (treat as empty); both arrays may be empty
|
|
3217
|
+
* when no eligible entities reference the game.
|
|
3218
|
+
*
|
|
3219
|
+
* @example
|
|
3220
|
+
* ```ts
|
|
3221
|
+
* const r = await window._smartico.api.getRelatedItemsForGame('gold-slot2');
|
|
3222
|
+
*
|
|
3223
|
+
* const missions = r.achievements ?? [];
|
|
3224
|
+
* const tournaments = r.tournaments ?? [];
|
|
3225
|
+
*
|
|
3226
|
+
* if (missions.length === 0 && tournaments.length === 0) {
|
|
3227
|
+
* console.log('[smartico] no related missions / tournaments — hide the related badge on the game tile');
|
|
3228
|
+
* } else {
|
|
3229
|
+
* console.log('[smartico] related entities:', missions.length, 'missions /', tournaments.length, 'tournaments — show a "X missions / Y tournaments" badge');
|
|
3230
|
+
* }
|
|
2942
3231
|
* ```
|
|
2943
3232
|
*/
|
|
2944
3233
|
;
|
|
@@ -3552,12 +3841,125 @@ var WSAPIBonuses = /*#__PURE__*/function (_WSAPIMissions) {
|
|
|
3552
3841
|
_inheritsLoose(WSAPIBonuses, _WSAPIMissions);
|
|
3553
3842
|
var _proto = WSAPIBonuses.prototype;
|
|
3554
3843
|
/**
|
|
3555
|
-
* Returns
|
|
3556
|
-
*
|
|
3557
|
-
*
|
|
3558
|
-
*
|
|
3844
|
+
* Returns the bonuses awarded to the current user — both pending
|
|
3845
|
+
* (player-claim required) and already-redeemed. Each bonus carries
|
|
3846
|
+
* a `bonus_status_id` ({@link BonusStatus}) describing its lifecycle
|
|
3847
|
+
* stage and an `is_redeemable` flag that signals whether the
|
|
3848
|
+
* consumer must trigger a manual {@link claimBonus} call.
|
|
3849
|
+
*
|
|
3850
|
+
* Bonuses originate from many sources (CRM rules, mission/tournament
|
|
3851
|
+
* rewards, store redemptions, mini-game prizes, manual operator
|
|
3852
|
+
* awards) and all surface through this single list. The consumer
|
|
3853
|
+
* cannot distinguish the source server-side without operator
|
|
3854
|
+
* coordination.
|
|
3559
3855
|
*
|
|
3560
|
-
*
|
|
3856
|
+
* @remarks
|
|
3857
|
+
* **Subscription model (`onUpdate`)**
|
|
3858
|
+
* The callback receives the FULL refreshed bonuses list (never a
|
|
3859
|
+
* diff/patch). Each subsequent call to `getBonuses({ onUpdate })`
|
|
3860
|
+
* REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
|
|
3861
|
+
* it) to keep the prior callback in place; the callback is never
|
|
3862
|
+
* auto-cleared.
|
|
3863
|
+
*
|
|
3864
|
+
* **Update triggers** — the callback fires after every
|
|
3865
|
+
* {@link claimBonus} call resolves on this connection (success OR
|
|
3866
|
+
* failure). This is the ONLY trigger.
|
|
3867
|
+
*
|
|
3868
|
+
* Does NOT fire when: a new bonus is awarded server-side
|
|
3869
|
+
* (CRM rule, mission completion, store purchase, etc.), a bonus
|
|
3870
|
+
* expires, or an operator manually issues / cancels a bonus. Those
|
|
3871
|
+
* changes surface only on the next cache miss (after the 30 s TTL).
|
|
3872
|
+
* Re-call `getBonuses()` manually if your UI needs near-live state
|
|
3873
|
+
* for server-driven awards.
|
|
3874
|
+
*
|
|
3875
|
+
* **Reading state from the returned bonus**
|
|
3876
|
+
* Drive UI bucketing from `bonus_status_id` (enum {@link BonusStatus}):
|
|
3877
|
+
*
|
|
3878
|
+
* - `COUPON_ISSUED` (2) — actionable; player must claim. Pair with
|
|
3879
|
+
* `is_redeemable === true` to gate the Claim button.
|
|
3880
|
+
* - `REDEEM_FAILED` (4) — also actionable; the previous claim
|
|
3881
|
+
* attempt failed but the bonus is still valid. Surface a retry CTA
|
|
3882
|
+
* — the default Smartico UI treats this identically to
|
|
3883
|
+
* `COUPON_ISSUED` from the player's perspective.
|
|
3884
|
+
* - `REDEEMED` (3) — historical; show in a "claimed" tab.
|
|
3885
|
+
* - `New` (1), `COUPON_ISSUE_FAILED` (5), `EXPIRED` (6) — these
|
|
3886
|
+
* should not normally reach the client and are typically filtered
|
|
3887
|
+
* out by operator-side widget configuration; if they do appear,
|
|
3888
|
+
* they have no player-actionable state.
|
|
3889
|
+
*
|
|
3890
|
+
* `is_redeemable` is the authoritative gate for showing the Claim
|
|
3891
|
+
* button — it's `true` only when the bonus is in a claimable status
|
|
3892
|
+
* AND the operator's integration uses a coupon model (where the
|
|
3893
|
+
* player must explicitly trigger delivery). Auto-redeemed bonuses
|
|
3894
|
+
* arrive already in `REDEEMED` state with `is_redeemable: false`.
|
|
3895
|
+
*
|
|
3896
|
+
* **Field hierarchy — display amount**
|
|
3897
|
+
* Bonuses carry both template-level (`label_bonus_template_meta_map.description`)
|
|
3898
|
+
* and instance-level (`bonus_meta_map.uiAmount`) display strings.
|
|
3899
|
+
* Prefer `bonus_meta_map.uiAmount` when present — it's the dynamic
|
|
3900
|
+
* amount computed at issuance time (e.g. from a dynamic-bonus
|
|
3901
|
+
* formula). Fall back to `label_bonus_template_meta_map.description`
|
|
3902
|
+
* (which can include HTML; sanitize before injecting).
|
|
3903
|
+
*
|
|
3904
|
+
* **Date format**
|
|
3905
|
+
* `create_date` and `redeem_date` are ISO 8601 UTC strings WITHOUT
|
|
3906
|
+
* a timezone suffix (`"YYYY-MM-DDTHH:MM:SS"`). Parse as UTC and
|
|
3907
|
+
* display in the user's local timezone. `redeem_date` is absent
|
|
3908
|
+
* until the bonus reaches `REDEEMED` status.
|
|
3909
|
+
*
|
|
3910
|
+
* **Cache TTL**: the SDK caches the response for 30 seconds. Cache
|
|
3911
|
+
* is fully cleared on login / logout.
|
|
3912
|
+
*
|
|
3913
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
3914
|
+
*
|
|
3915
|
+
* **UI guidance**: see [UI Guide — `getBonuses`](../../docs/ui/bonuses/UIGuide_getBonuses.md).
|
|
3916
|
+
*
|
|
3917
|
+
* **Visitor mode**: not supported.
|
|
3918
|
+
*
|
|
3919
|
+
* @param params Optional. Omit to fetch without subscribing.
|
|
3920
|
+
* @param params.onUpdate Callback invoked with the full refreshed
|
|
3921
|
+
* bonuses list after every
|
|
3922
|
+
* {@link claimBonus} resolves. Each call
|
|
3923
|
+
* to `getBonuses` overwrites the prior
|
|
3924
|
+
* callback.
|
|
3925
|
+
* @returns Promise resolving to the bonuses list.
|
|
3926
|
+
* Empty array if no bonuses are visible.
|
|
3927
|
+
*
|
|
3928
|
+
* @example
|
|
3929
|
+
* ```ts
|
|
3930
|
+
* const bonuses = await window._smartico.api.getBonuses({
|
|
3931
|
+
* onUpdate: (refreshed) => {
|
|
3932
|
+
* console.log('[smartico] bonuses refreshed (after claimBonus) — re-render the bonuses UI from this array:', refreshed);
|
|
3933
|
+
* },
|
|
3934
|
+
* });
|
|
3935
|
+
*
|
|
3936
|
+
* // Bucket into pending vs redeemed tabs. The default Smartico UI groups
|
|
3937
|
+
* // COUPON_ISSUED + REDEEM_FAILED into the same "Pending" tab.
|
|
3938
|
+
* const pending = bonuses.filter(b =>
|
|
3939
|
+
* b.bonus_status_id === 2 || b.bonus_status_id === 4 // COUPON_ISSUED or REDEEM_FAILED
|
|
3940
|
+
* );
|
|
3941
|
+
* const redeemed = bonuses.filter(b => b.bonus_status_id === 3); // REDEEMED
|
|
3942
|
+
*
|
|
3943
|
+
* console.log('[smartico] render bonus tabs: pending=', pending.length, 'redeemed=', redeemed.length);
|
|
3944
|
+
*
|
|
3945
|
+
* // Render each pending bonus card; show Claim button only when redeemable.
|
|
3946
|
+
* for (const b of pending) {
|
|
3947
|
+
* const amount = b.bonus_meta_map?.uiAmount || b.label_bonus_template_meta_map?.description;
|
|
3948
|
+
* if (b.is_redeemable) {
|
|
3949
|
+
* console.log('[smartico] render Claim button for bonus', b.bonus_id, '— amount:', amount);
|
|
3950
|
+
* } else {
|
|
3951
|
+
* console.log('[smartico] render bonus as informational (no Claim button) — amount:', amount);
|
|
3952
|
+
* }
|
|
3953
|
+
* }
|
|
3954
|
+
*
|
|
3955
|
+
* // Server-awarded bonuses (e.g. from a CRM campaign) do NOT push;
|
|
3956
|
+
* // poll if you need near-live awareness.
|
|
3957
|
+
* setInterval(async () => {
|
|
3958
|
+
* const fresh = await window._smartico.api.getBonuses();
|
|
3959
|
+
* const newCount = fresh.filter(b => b.bonus_status_id === 2 || b.bonus_status_id === 4).length;
|
|
3960
|
+
* console.log('[smartico] poll tick — pending bonuses now:', newCount);
|
|
3961
|
+
* }, 30_000);
|
|
3962
|
+
* ```
|
|
3561
3963
|
*/
|
|
3562
3964
|
_proto.getBonuses = function getBonuses(_temp) {
|
|
3563
3965
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
@@ -3575,12 +3977,113 @@ var WSAPIBonuses = /*#__PURE__*/function (_WSAPIMissions) {
|
|
|
3575
3977
|
}
|
|
3576
3978
|
}
|
|
3577
3979
|
/**
|
|
3578
|
-
*
|
|
3579
|
-
*
|
|
3580
|
-
*
|
|
3581
|
-
*
|
|
3980
|
+
* Triggers manual redemption of a coupon-model bonus the user has
|
|
3981
|
+
* been awarded. For bonuses with `is_redeemable === true` returned
|
|
3982
|
+
* by {@link getBonuses}, this is the call that asks the operator's
|
|
3983
|
+
* integration to actually credit the bonus to the player's account.
|
|
3984
|
+
* Bonuses on integrations that auto-redeem arrive already in
|
|
3985
|
+
* `REDEEMED` state and do not require this call.
|
|
3582
3986
|
*
|
|
3583
|
-
*
|
|
3987
|
+
* Use this for `bonus_status_id` of `COUPON_ISSUED` (2) as the
|
|
3988
|
+
* first-time claim, and for `REDEEM_FAILED` (4) as a retry after a
|
|
3989
|
+
* prior unsuccessful attempt.
|
|
3990
|
+
*
|
|
3991
|
+
* @remarks
|
|
3992
|
+
* **Preconditions**
|
|
3993
|
+
* Read the candidate bonus from {@link getBonuses} and gate the
|
|
3994
|
+
* call on `is_redeemable === true`. The SDK forwards the request
|
|
3995
|
+
* unconditionally — calling on a non-claimable bonus returns
|
|
3996
|
+
* `err_code = -1`.
|
|
3997
|
+
*
|
|
3998
|
+
* **Error codes** (in `err_code`)
|
|
3999
|
+
*
|
|
4000
|
+
* The SDK currently types `err_code` as {@link SAWSpinErrorCode} for
|
|
4001
|
+
* historical reasons, but the values returned by this method come
|
|
4002
|
+
* from the server's general error space and are NOT mini-game codes.
|
|
4003
|
+
* Branch on the numeric values:
|
|
4004
|
+
*
|
|
4005
|
+
* - `0` — success; the bonus has been redeemed and the operator's
|
|
4006
|
+
* integration has credited the player's account.
|
|
4007
|
+
* - `-1` — bonus not claimable: not found, already claimed by
|
|
4008
|
+
* another session, or its status is no longer `COUPON_ISSUED` /
|
|
4009
|
+
* `REDEEM_FAILED`. Treat as idempotent — refresh
|
|
4010
|
+
* {@link getBonuses} and reconcile.
|
|
4011
|
+
* - `1` — generic server error. Transient; allow retry after a brief
|
|
4012
|
+
* delay.
|
|
4013
|
+
* - `9999` — uncaught server exception. Treat as a transient failure;
|
|
4014
|
+
* surface a generic error and allow retry.
|
|
4015
|
+
* - other non-zero — generic server error. Surface `err_message` if
|
|
4016
|
+
* any.
|
|
4017
|
+
*
|
|
4018
|
+
* **`success` field is unreliable**: the wire response does not
|
|
4019
|
+
* carry a `success` boolean — the field on `TClaimBonusResult` will
|
|
4020
|
+
* be `undefined` in practice. Always branch on `err_code === 0`
|
|
4021
|
+
* for the success check.
|
|
4022
|
+
*
|
|
4023
|
+
* **Refresh after success (and after failure)**
|
|
4024
|
+
* The SDK automatically refreshes the bonuses cache on every
|
|
4025
|
+
* response (success OR failure) and fires any `onUpdate` callback
|
|
4026
|
+
* registered via {@link getBonuses}'s `onUpdate`. After
|
|
4027
|
+
* `err_code === 0`, the redeemed bonus shifts from
|
|
4028
|
+
* `COUPON_ISSUED` / `REDEEM_FAILED` to `REDEEMED` on the refreshed
|
|
4029
|
+
* array, with `redeem_date` populated. After a failure, the bonus
|
|
4030
|
+
* typically lands in `REDEEM_FAILED` and remains claimable for a
|
|
4031
|
+
* retry.
|
|
4032
|
+
*
|
|
4033
|
+
* **Idempotency**: NOT idempotent at the SDK level. A second call
|
|
4034
|
+
* returns `err_code = -1` once the first has succeeded — treat that
|
|
4035
|
+
* as success in the UI rather than as a real error. Guard the call
|
|
4036
|
+
* site against double-clicks (set a local "claiming" flag on click,
|
|
4037
|
+
* clear it on response).
|
|
4038
|
+
*
|
|
4039
|
+
* **Side effects** (on `err_code === 0`)
|
|
4040
|
+
* - Bonus status transitions to `REDEEMED`; `redeem_date` is set.
|
|
4041
|
+
* - The operator's integration credits the player's account
|
|
4042
|
+
* externally. The SDK does not observe that credit directly —
|
|
4043
|
+
* balance updates flow over the user-properties channel from the
|
|
4044
|
+
* operator's side, not from this response.
|
|
4045
|
+
* - Server-side analytics events fire downstream (not directly
|
|
4046
|
+
* observable from the SDK).
|
|
4047
|
+
*
|
|
4048
|
+
* **UI guidance**: see [UI Guide — `claimBonus`](../../docs/ui/bonuses/UIGuide_claimBonus.md).
|
|
4049
|
+
*
|
|
4050
|
+
* **Visitor mode**: not supported.
|
|
4051
|
+
*
|
|
4052
|
+
* @param bonus_id The `bonus_id` from a `TBonus` returned by
|
|
4053
|
+
* {@link getBonuses}.
|
|
4054
|
+
* @returns `{ err_code, err_message, success? }`; success when
|
|
4055
|
+
* `err_code === 0` (or `err_code === -1` when treated as
|
|
4056
|
+
* idempotent no-op). The `success` field is unreliable —
|
|
4057
|
+
* ignore it.
|
|
4058
|
+
*
|
|
4059
|
+
* @example
|
|
4060
|
+
* ```ts
|
|
4061
|
+
* const bonuses = await window._smartico.api.getBonuses({
|
|
4062
|
+
* onUpdate: (refreshed) => console.log('[smartico] bonuses refreshed — re-render from this array', refreshed),
|
|
4063
|
+
* });
|
|
4064
|
+
* const bonus = bonuses.find(b => b.bonus_id === bonusId);
|
|
4065
|
+
*
|
|
4066
|
+
* if (!bonus) {
|
|
4067
|
+
* console.log('[smartico] bonus no longer visible — refresh list and hide CTA');
|
|
4068
|
+
* return;
|
|
4069
|
+
* }
|
|
4070
|
+
* if (!bonus.is_redeemable) {
|
|
4071
|
+
* console.log('[smartico] bonus is not claimable (auto-redeemed or already finalised) — keep CTA hidden');
|
|
4072
|
+
* return;
|
|
4073
|
+
* }
|
|
4074
|
+
*
|
|
4075
|
+
* console.log('[smartico] claim starting — set in-flight flag, show loading dots on the Claim button, keep the modal open');
|
|
4076
|
+
* const r = await window._smartico.api.claimBonus(bonus.bonus_id);
|
|
4077
|
+
* console.log('[smartico] claim response received — clear in-flight flag');
|
|
4078
|
+
*
|
|
4079
|
+
* if (r.err_code === 0 || r.err_code === -1) {
|
|
4080
|
+
* console.log('[smartico] claim succeeded (or was already done) — show a success toast; the getBonuses onUpdate above will fire with the refreshed list');
|
|
4081
|
+
* } else if (r.err_code === 9999) {
|
|
4082
|
+
* console.error('[smartico] uncaught server exception — show a generic error toast and allow retry');
|
|
4083
|
+
* } else {
|
|
4084
|
+
* console.error('[smartico] claim failed — surface this error message to the user; the bonus will move to REDEEM_FAILED state and remain claimable for a retry:', r.err_message);
|
|
4085
|
+
* }
|
|
4086
|
+
* ```
|
|
3584
4087
|
*/
|
|
3585
4088
|
;
|
|
3586
4089
|
_proto.claimBonus = function claimBonus(bonus_id) {
|
|
@@ -4747,7 +5250,7 @@ var WSAPITournaments = /*#__PURE__*/function (_WSAPIStore) {
|
|
|
4747
5250
|
*
|
|
4748
5251
|
* For clan tournaments (`is_clan_based === true`), the user must
|
|
4749
5252
|
* already belong to a clan before calling. If they don't, prompt them
|
|
4750
|
-
* to pick a clan first via
|
|
5253
|
+
* to pick a clan first via `joinClan`, then call
|
|
4751
5254
|
* `registerInTournament` after the clan-join resolves. See "Error
|
|
4752
5255
|
* codes" `1010` below for the server-side safety net.
|
|
4753
5256
|
*
|
|
@@ -4756,8 +5259,8 @@ var WSAPITournaments = /*#__PURE__*/function (_WSAPIStore) {
|
|
|
4756
5259
|
* tournament lobby refresh fires.
|
|
4757
5260
|
* - `1010` — `TOURNAMENT_USER_CANNOT_JOIN_WITHOUT_CLAN`: clan-based
|
|
4758
5261
|
* tournament and the user has no clan. Surface the clan-pick flow
|
|
4759
|
-
* (e.g. open a clan-pick modal driven by
|
|
4760
|
-
*
|
|
5262
|
+
* (e.g. open a clan-pick modal driven by `getClans` +
|
|
5263
|
+
* `joinClan`), then retry registration.
|
|
4761
5264
|
* - `30001` — `TOURNAMENT_INSTANCE_NOT_FOUND`: instance ID is invalid
|
|
4762
5265
|
* or the tournament was deleted. Refresh the lobby via
|
|
4763
5266
|
* `getTournamentsList()` and hide the entry from the UI.
|
|
@@ -5372,23 +5875,81 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
|
|
|
5372
5875
|
return Promise.reject(e);
|
|
5373
5876
|
}
|
|
5374
5877
|
}
|
|
5375
|
-
/**
|
|
5376
|
-
*
|
|
5377
|
-
*
|
|
5378
|
-
*
|
|
5878
|
+
/**
|
|
5879
|
+
* Returns the user-eligible jackpots active for the label, fused with their live
|
|
5880
|
+
* pot values. Each entry carries the static template (name, description, opt-in
|
|
5881
|
+
* state, eligible games, currency) plus a freshly-fetched `pot` snapshot.
|
|
5379
5882
|
*
|
|
5380
|
-
*
|
|
5381
|
-
*
|
|
5382
|
-
*
|
|
5383
|
-
*
|
|
5384
|
-
* });
|
|
5385
|
-
* ```
|
|
5883
|
+
* Designed to be polled at high frequency (every 1 second is fine) — the SDK
|
|
5884
|
+
* splits the response into a 30-second template cache and a 1-second pot-value
|
|
5885
|
+
* cache so consumers can render a live-counting pot amount without hammering
|
|
5886
|
+
* the server for the static template data.
|
|
5386
5887
|
*
|
|
5387
|
-
*
|
|
5388
|
-
*
|
|
5389
|
-
*
|
|
5390
|
-
*
|
|
5391
|
-
*
|
|
5888
|
+
* @remarks
|
|
5889
|
+
* **Preconditions**
|
|
5890
|
+
* - No prerequisite calls.
|
|
5891
|
+
* - Visitor mode supported via `_smartico.vapi(lang).jackpotGet(...)`.
|
|
5892
|
+
*
|
|
5893
|
+
* **Server-side eligibility filtering**
|
|
5894
|
+
* Jackpots are filtered server-side by the user's segments before being
|
|
5895
|
+
* returned. Templates the user is ineligible for never appear in this
|
|
5896
|
+
* response — there is no "locked" state to render. An empty result for a
|
|
5897
|
+
* known-good user typically means none of the configured templates match
|
|
5898
|
+
* the user's segments / level / brand.
|
|
5899
|
+
*
|
|
5900
|
+
* **Filter behavior**
|
|
5901
|
+
* Passing `related_game_id` returns only jackpots linked to that game (from
|
|
5902
|
+
* the operator's games catalog). Passing `jp_template_id` returns just that
|
|
5903
|
+
* single template. With no filter, all active templates the user is
|
|
5904
|
+
* eligible for are returned. Changing the filter between calls flushes both
|
|
5905
|
+
* the template cache and the pot cache.
|
|
5906
|
+
*
|
|
5907
|
+
* **Two-tier cache**
|
|
5908
|
+
* - Template definitions: 30 s cache. Re-fetched on filter change or when
|
|
5909
|
+
* opt-in / opt-out / a jackpot-win push lands.
|
|
5910
|
+
* - Pot values: 1 s cache. Re-fetched on every call past the 1-second
|
|
5911
|
+
* window so a 1 Hz poll renders a smoothly counting pot.
|
|
5912
|
+
*
|
|
5913
|
+
* **`jp_public_meta.custom_data`**
|
|
5914
|
+
* Server returns this as a JSON-encoded string; the SDK parses it inline so
|
|
5915
|
+
* consumers always receive either a parsed object or the raw string.
|
|
5916
|
+
*
|
|
5917
|
+
* **Personal vs MultiUser jackpots** (see {@link JackpotType})
|
|
5918
|
+
* - `MultiUser` (1) — shared pot; `registration_count` reflects real opted-in
|
|
5919
|
+
* user count; temperature transitions fire push events.
|
|
5920
|
+
* - `Personal` (2) — independent per-user pot; `registration_count` is
|
|
5921
|
+
* always 1; temperature push events are suppressed.
|
|
5922
|
+
*
|
|
5923
|
+
* **Refresh**
|
|
5924
|
+
* - `jp_status_id`, segment changes, and operator template edits surface
|
|
5925
|
+
* after the 30 s template cache TTL.
|
|
5926
|
+
* - Opt-in / opt-out / jackpot-win push events all clear the template and
|
|
5927
|
+
* pot caches — the next call re-fetches.
|
|
5928
|
+
*
|
|
5929
|
+
* **Visitor mode**: supported.
|
|
5930
|
+
*
|
|
5931
|
+
* **UI guidance**: see [UI Guide — `jackpotGet`](../../docs/ui/jackpots/UIGuide_jackpotGet.md).
|
|
5932
|
+
*
|
|
5933
|
+
* @param filter Optional filter narrowing the result set.
|
|
5934
|
+
* @param filter.related_game_id Limit to jackpots linked to this game ID
|
|
5935
|
+
* (from the operator's games catalog).
|
|
5936
|
+
* @param filter.jp_template_id Limit to a single template.
|
|
5937
|
+
* @returns Array of {@link JackpotDetails} — empty if the user is eligible
|
|
5938
|
+
* for no active jackpots.
|
|
5939
|
+
*
|
|
5940
|
+
* @example
|
|
5941
|
+
* ```ts
|
|
5942
|
+
* // Poll every second for live pot counter
|
|
5943
|
+
* setInterval(async () => {
|
|
5944
|
+
* const jackpots = await window._smartico.api.jackpotGet();
|
|
5945
|
+
* for (const jp of jackpots) {
|
|
5946
|
+
* console.log('[smartico] update pot widget for', jp.jp_public_meta.name, '— amount:', jp.pot.current_pot_amount_user_currency, jp.user_currency, '— temperature:', jp.pot.current_pot_temperature);
|
|
5947
|
+
* }
|
|
5948
|
+
* }, 1000);
|
|
5949
|
+
*
|
|
5950
|
+
* // Filtered fetch for a specific game tile
|
|
5951
|
+
* const linked = await window._smartico.api.jackpotGet({ related_game_id: 'gold-slot2' });
|
|
5952
|
+
* console.log('[smartico] linked jackpots for game:', linked.length);
|
|
5392
5953
|
* ```
|
|
5393
5954
|
*/
|
|
5394
5955
|
;
|
|
@@ -5456,18 +6017,68 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
|
|
|
5456
6017
|
}
|
|
5457
6018
|
}
|
|
5458
6019
|
/**
|
|
5459
|
-
*
|
|
5460
|
-
*
|
|
6020
|
+
* Opts the authenticated user into a jackpot. From this point on, the user
|
|
6021
|
+
* contributes to the pot (per the template's `contribution_type` and
|
|
6022
|
+
* `contribution_value`) and is eligible to win when the pot explodes.
|
|
5461
6023
|
*
|
|
5462
|
-
*
|
|
5463
|
-
*
|
|
5464
|
-
*
|
|
5465
|
-
* console.log('Opted in to the jackpot');
|
|
5466
|
-
* });
|
|
5467
|
-
* ```
|
|
6024
|
+
* On success the SDK clears the jackpot caches — the next
|
|
6025
|
+
* {@link jackpotGet} call returns the updated `is_opted_in: true` and an
|
|
6026
|
+
* incremented `registration_count`.
|
|
5468
6027
|
*
|
|
5469
|
-
*
|
|
6028
|
+
* @remarks
|
|
6029
|
+
* **Preconditions**
|
|
6030
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
6031
|
+
* - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
|
|
6032
|
+
* - The jackpot must currently be active and the user must be in its
|
|
6033
|
+
* eligibility segment. Ineligible jackpots are filtered out of
|
|
6034
|
+
* {@link jackpotGet} entirely, so a card the user sees is opt-in-able.
|
|
6035
|
+
*
|
|
6036
|
+
* **Error handling**
|
|
6037
|
+
* The server returns a non-zero `errCode` with a human-readable `errMsg`
|
|
6038
|
+
* for any failure. Common causes:
|
|
6039
|
+
* - User is in a control group.
|
|
6040
|
+
* - Jackpot template is not active (status changed since the user opened
|
|
6041
|
+
* the card).
|
|
6042
|
+
* - User is already opted in (the SDK has no client-side guard against a
|
|
6043
|
+
* double-tap; the server enforces).
|
|
6044
|
+
* - DB race / generic server error.
|
|
6045
|
+
*
|
|
6046
|
+
* The SDK does NOT enumerate distinct numeric codes for each cause — branch
|
|
6047
|
+
* on `errCode === 0` for success and surface `errMsg` as-is for failures.
|
|
6048
|
+
*
|
|
6049
|
+
* **Idempotency / re-opt-in semantics**
|
|
6050
|
+
* - **Already opted in** → returns non-zero `errCode` ("User already opted in").
|
|
6051
|
+
* - **Previously opted in then opted out** → succeeds silently; the server
|
|
6052
|
+
* re-activates the registration. This is not an error path — a user can
|
|
6053
|
+
* freely cycle opt-in / opt-out.
|
|
6054
|
+
*
|
|
6055
|
+
* **Refresh after success**
|
|
6056
|
+
* - The SDK clears the template, pot, and winners caches.
|
|
6057
|
+
* - The next {@link jackpotGet} call returns `is_opted_in: true` for this
|
|
6058
|
+
* template.
|
|
6059
|
+
*
|
|
6060
|
+
* **Side effects**
|
|
6061
|
+
* Fires a `JACKPOT_OPT_IN` engagement event (visible to operator-side
|
|
6062
|
+
* automation rules). Does NOT immediately move points / gems — contributions
|
|
6063
|
+
* happen per-bet via the user's gameplay, not on opt-in.
|
|
6064
|
+
*
|
|
6065
|
+
* **Visitor mode**: not supported.
|
|
6066
|
+
*
|
|
6067
|
+
* **UI guidance**: see [UI Guide — `jackpotOptIn`](../../docs/ui/jackpots/UIGuide_jackpotOptIn.md).
|
|
5470
6068
|
*
|
|
6069
|
+
* @param filter.jp_template_id ID of the jackpot template to join.
|
|
6070
|
+
* @returns {@link JackpotsOptinResponse} — `errCode === 0` on success.
|
|
6071
|
+
*
|
|
6072
|
+
* @example
|
|
6073
|
+
* ```ts
|
|
6074
|
+
* const r = await window._smartico.api.jackpotOptIn({ jp_template_id: 42 });
|
|
6075
|
+
*
|
|
6076
|
+
* if (r.errCode === 0) {
|
|
6077
|
+
* console.log('[smartico] opted in — refresh jackpot card to show opt-out CTA');
|
|
6078
|
+
* } else {
|
|
6079
|
+
* console.error('[smartico] opt-in failed — show this message in an error toast:', r.errMsg);
|
|
6080
|
+
* }
|
|
6081
|
+
* ```
|
|
5471
6082
|
*/
|
|
5472
6083
|
;
|
|
5473
6084
|
_proto.jackpotOptIn = function jackpotOptIn(filter) {
|
|
@@ -5482,18 +6093,63 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
|
|
|
5482
6093
|
}
|
|
5483
6094
|
}
|
|
5484
6095
|
/**
|
|
5485
|
-
*
|
|
5486
|
-
*
|
|
6096
|
+
* Opts the authenticated user out of a jackpot. From this point on the user
|
|
6097
|
+
* no longer contributes to the pot and is not eligible to win.
|
|
5487
6098
|
*
|
|
5488
|
-
*
|
|
5489
|
-
*
|
|
5490
|
-
* _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
|
|
5491
|
-
* console.log('Opted out from the jackpot');
|
|
5492
|
-
* });
|
|
5493
|
-
* ```
|
|
6099
|
+
* The user can re-join later via {@link jackpotOptIn} — opt-out is not
|
|
6100
|
+
* permanent.
|
|
5494
6101
|
*
|
|
5495
|
-
*
|
|
6102
|
+
* @remarks
|
|
6103
|
+
* **Preconditions**
|
|
6104
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
6105
|
+
* - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
|
|
6106
|
+
*
|
|
6107
|
+
* **Error handling**
|
|
6108
|
+
* The server returns a non-zero `errCode` with a human-readable `errMsg` for
|
|
6109
|
+
* any failure. Common causes:
|
|
6110
|
+
* - User has never opted in OR is already opted out — server returns
|
|
6111
|
+
* non-zero `errCode` for the "already opted out" case. Calling opt-out
|
|
6112
|
+
* on a jackpot the user has never registered for typically returns
|
|
6113
|
+
* success (the server finds no registration row to update).
|
|
6114
|
+
* - DB race / generic server error.
|
|
6115
|
+
*
|
|
6116
|
+
* Unlike {@link jackpotOptIn}, opt-out does NOT check the template's status
|
|
6117
|
+
* — the user can opt out of a jackpot that has been deactivated by the
|
|
6118
|
+
* operator.
|
|
6119
|
+
*
|
|
6120
|
+
* **Idempotency**
|
|
6121
|
+
* - First opt-out → success.
|
|
6122
|
+
* - Second opt-out → non-zero `errCode` ("Already opted out").
|
|
6123
|
+
* - Opt-out of a never-joined jackpot → typically succeeds silently
|
|
6124
|
+
* (no registration row to act on).
|
|
6125
|
+
*
|
|
6126
|
+
* **Refresh after success**
|
|
6127
|
+
* - The SDK clears the template, pot, and winners caches.
|
|
6128
|
+
* - The next {@link jackpotGet} call returns `is_opted_in: false` for this
|
|
6129
|
+
* template and a decremented `registration_count`.
|
|
5496
6130
|
*
|
|
6131
|
+
* **Side effects**
|
|
6132
|
+
* Fires a `JACKPOT_OPT_OUT` engagement event for operator-side automation
|
|
6133
|
+
* rules. The user's existing contributions to the current pot remain in
|
|
6134
|
+
* place — opt-out stops future contributions but does not refund past ones.
|
|
6135
|
+
*
|
|
6136
|
+
* **Visitor mode**: not supported.
|
|
6137
|
+
*
|
|
6138
|
+
* **UI guidance**: see [UI Guide — `jackpotOptOut`](../../docs/ui/jackpots/UIGuide_jackpotOptOut.md).
|
|
6139
|
+
*
|
|
6140
|
+
* @param filter.jp_template_id ID of the jackpot template to leave.
|
|
6141
|
+
* @returns {@link JackpotsOptoutResponse} — `errCode === 0` on success.
|
|
6142
|
+
*
|
|
6143
|
+
* @example
|
|
6144
|
+
* ```ts
|
|
6145
|
+
* const r = await window._smartico.api.jackpotOptOut({ jp_template_id: 42 });
|
|
6146
|
+
*
|
|
6147
|
+
* if (r.errCode === 0) {
|
|
6148
|
+
* console.log('[smartico] opted out — refresh jackpot card to show join CTA');
|
|
6149
|
+
* } else {
|
|
6150
|
+
* console.error('[smartico] opt-out failed — show this message in an error toast:', r.errMsg);
|
|
6151
|
+
* }
|
|
6152
|
+
* ```
|
|
5497
6153
|
*/
|
|
5498
6154
|
;
|
|
5499
6155
|
_proto.jackpotOptOut = function jackpotOptOut(filter) {
|
|
@@ -5508,25 +6164,64 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
|
|
|
5508
6164
|
}
|
|
5509
6165
|
}
|
|
5510
6166
|
/**
|
|
5511
|
-
* Returns
|
|
5512
|
-
*
|
|
5513
|
-
* The full protocol response also includes `has_more`; this method returns only the `winners` array.
|
|
6167
|
+
* Returns past winners of a specific jackpot template, paginated. Use to
|
|
6168
|
+
* power a "Recent winners" panel inside the jackpot detail modal.
|
|
5514
6169
|
*
|
|
5515
|
-
* **
|
|
5516
|
-
*
|
|
5517
|
-
*
|
|
5518
|
-
*
|
|
5519
|
-
* }).then((result) => {
|
|
5520
|
-
* console.log(result);
|
|
5521
|
-
* });
|
|
5522
|
-
* ```
|
|
6170
|
+
* **Important**: respect the `expose_winners_over_api` flag on the jackpot's
|
|
6171
|
+
* {@link JackpotDetails} before calling this method. The server-side handler
|
|
6172
|
+
* does NOT enforce that flag — it is a UI-only gate. Custom UIs that ignore
|
|
6173
|
+
* the flag will display winners the operator intended to keep private.
|
|
5523
6174
|
*
|
|
5524
|
-
*
|
|
6175
|
+
* @remarks
|
|
6176
|
+
* **Preconditions**
|
|
6177
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
6178
|
+
* - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
|
|
6179
|
+
* - The consumer SHOULD check
|
|
6180
|
+
* {@link JackpotDetails.expose_winners_over_api} before calling, since
|
|
6181
|
+
* the server does not enforce it.
|
|
6182
|
+
*
|
|
6183
|
+
* **Pagination**
|
|
6184
|
+
* Server default page size is 20. Pass `limit` and `offset` to paginate
|
|
6185
|
+
* (e.g. infinite-scroll). The wire response carries a `has_more` flag, but
|
|
6186
|
+
* this SDK method returns only the `winners` array — detect end-of-list by
|
|
6187
|
+
* a returned array shorter than `limit`.
|
|
6188
|
+
*
|
|
6189
|
+
* **Currency caveat**
|
|
6190
|
+
* Winner amounts in the response (`winner.winning_amount_jp_currency`) are
|
|
6191
|
+
* in the jackpot's NATIVE currency, NOT the user's wallet currency. If a
|
|
6192
|
+
* user-currency display is needed, the consumer must convert client-side.
|
|
6193
|
+
*
|
|
6194
|
+
* **Refresh**
|
|
6195
|
+
* - The SDK caches per `jp_template_id` for 30 seconds.
|
|
6196
|
+
* - Caches clear on jackpot-win push events and on opt-in / opt-out.
|
|
6197
|
+
*
|
|
6198
|
+
* **Error handling**
|
|
6199
|
+
* Non-zero `errCode` on control-group users or generic server errors. The
|
|
6200
|
+
* SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
|
|
6201
|
+
* surface `errMsg` on failure.
|
|
6202
|
+
*
|
|
6203
|
+
* **Visitor mode**: not supported.
|
|
6204
|
+
*
|
|
6205
|
+
* **UI guidance**: see [UI Guide — `getJackpotWinners`](../../docs/ui/jackpots/UIGuide_getJackpotWinners.md).
|
|
6206
|
+
*
|
|
6207
|
+
* @returns Array of {@link JackpotWinnerHistory} entries newest-first.
|
|
6208
|
+
*
|
|
6209
|
+
* @example
|
|
6210
|
+
* ```ts
|
|
6211
|
+
* const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
|
|
6212
|
+
*
|
|
6213
|
+
* if (!jp || !jp.expose_winners_over_api) {
|
|
6214
|
+
* console.log('[smartico] winners hidden by operator config — hide the winners tab');
|
|
6215
|
+
* return;
|
|
6216
|
+
* }
|
|
5525
6217
|
*
|
|
5526
|
-
*
|
|
5527
|
-
*
|
|
5528
|
-
*
|
|
5529
|
-
*
|
|
6218
|
+
* const winners = await window._smartico.api.getJackpotWinners({
|
|
6219
|
+
* jp_template_id: 42,
|
|
6220
|
+
* limit: 20,
|
|
6221
|
+
* offset: 0,
|
|
6222
|
+
* });
|
|
6223
|
+
* console.log('[smartico] render', winners.length, 'recent winner rows (amounts in', jp.jp_currency + ')');
|
|
6224
|
+
* ```
|
|
5530
6225
|
*/
|
|
5531
6226
|
;
|
|
5532
6227
|
_proto.getJackpotWinners = function getJackpotWinners(_ref) {
|
|
@@ -5543,29 +6238,67 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
|
|
|
5543
6238
|
}
|
|
5544
6239
|
}
|
|
5545
6240
|
/**
|
|
5546
|
-
* Returns the
|
|
6241
|
+
* Returns the casino games eligible to contribute to a specific jackpot —
|
|
6242
|
+
* the catalog the user must play to grow the pot. Use to power an
|
|
6243
|
+
* "Eligible games" carousel inside the jackpot detail modal.
|
|
5547
6244
|
*
|
|
5548
|
-
* **
|
|
5549
|
-
*
|
|
5550
|
-
*
|
|
5551
|
-
*
|
|
5552
|
-
*
|
|
5553
|
-
* ```
|
|
6245
|
+
* **Shortcut**: when the jackpot's
|
|
6246
|
+
* {@link JackpotDetails.ach_related_game_allow_all} flag is `true`, every
|
|
6247
|
+
* game in the operator catalog contributes — there's no point calling this
|
|
6248
|
+
* method (the result would be the full catalog). The default Smartico UI
|
|
6249
|
+
* hides the Eligible Games tab entirely in that case.
|
|
5554
6250
|
*
|
|
5555
|
-
*
|
|
6251
|
+
* @remarks
|
|
6252
|
+
* **Preconditions**
|
|
6253
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
6254
|
+
* - `jp_template_id` is mandatory.
|
|
5556
6255
|
*
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
6256
|
+
* **`onUpdate` caveat**
|
|
6257
|
+
* The `onUpdate` callback is accepted to match the SDK's subscription
|
|
6258
|
+
* contract but is NOT auto-invoked by any current server push. It will only
|
|
6259
|
+
* fire if a consumer (or a future SDK version) explicitly pushes an update.
|
|
6260
|
+
* Treat it as a no-op for now.
|
|
6261
|
+
*
|
|
6262
|
+
* **Refresh**
|
|
6263
|
+
* - The SDK caches per `jp_template_id` for 30 seconds.
|
|
6264
|
+
* - Cache does NOT clear on opt-in / opt-out / jackpot-win — eligible-game
|
|
6265
|
+
* lists rarely change during a session. Wait for the 30 s TTL.
|
|
6266
|
+
*
|
|
6267
|
+
* **Error handling**
|
|
6268
|
+
* Non-zero `errCode` on control-group users or generic server errors.
|
|
6269
|
+
* Branch on `errCode === 0` and surface `errMsg` on failure.
|
|
6270
|
+
*
|
|
6271
|
+
* **Visitor mode**: not supported.
|
|
6272
|
+
*
|
|
6273
|
+
* **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
|
|
6274
|
+
*
|
|
6275
|
+
* @returns {@link TGetJackpotEligibleGamesResponse} —
|
|
6276
|
+
* `{ eligible_games: JackpotEligibleGame[] }`.
|
|
6277
|
+
*
|
|
6278
|
+
* @example
|
|
6279
|
+
* ```ts
|
|
6280
|
+
* const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
|
|
6281
|
+
*
|
|
6282
|
+
* if (jp?.ach_related_game_allow_all) {
|
|
6283
|
+
* console.log('[smartico] all games eligible — hide the eligible-games tab');
|
|
6284
|
+
* return;
|
|
6285
|
+
* }
|
|
6286
|
+
*
|
|
6287
|
+
* const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
|
|
6288
|
+
* console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
|
|
6289
|
+
* ```
|
|
6290
|
+
*/
|
|
6291
|
+
;
|
|
6292
|
+
_proto.getJackpotEligibleGames = function getJackpotEligibleGames(_ref2) {
|
|
6293
|
+
var jp_template_id = _ref2.jp_template_id,
|
|
6294
|
+
onUpdate = _ref2.onUpdate;
|
|
6295
|
+
try {
|
|
6296
|
+
var _this6 = this;
|
|
6297
|
+
if (onUpdate) {
|
|
6298
|
+
_this6.onUpdateCallback.set(onUpdateContextKey.JackpotEligibleGames, onUpdate);
|
|
6299
|
+
}
|
|
6300
|
+
return Promise.resolve(OCache.use(onUpdateContextKey.JackpotEligibleGames + jp_template_id, exports.ECacheContext.WSAPI, function () {
|
|
6301
|
+
return _this6.api.getJackpotEligibleGamesT(_this6.userExtId, {
|
|
5569
6302
|
jp_template_id: jp_template_id
|
|
5570
6303
|
});
|
|
5571
6304
|
}, JACKPOT_ELIGIBLE_GAMES_CACHE_SEC));
|
|
@@ -5594,26 +6327,112 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5594
6327
|
}
|
|
5595
6328
|
}
|
|
5596
6329
|
/**
|
|
5597
|
-
* Returns
|
|
5598
|
-
*
|
|
5599
|
-
*
|
|
6330
|
+
* Returns all raffles visible to the current user, each carrying an
|
|
6331
|
+
* embedded `draws[]` array with per-draw state (current state, ticket
|
|
6332
|
+
* counts, opt-in status, prize structure). Use this to power a
|
|
6333
|
+
* raffles lobby screen and to drive per-draw CTAs (opt-in, view
|
|
6334
|
+
* winners, claim).
|
|
6335
|
+
*
|
|
6336
|
+
* The embedded `draws[i]` objects are sufficient for rendering all
|
|
6337
|
+
* draw cards — winner details with usernames / avatars require a
|
|
6338
|
+
* follow-up {@link getRaffleDrawRun} call (the embedded form carries
|
|
6339
|
+
* only `winners_total` / `winners_limit` / `winners_offset` metadata,
|
|
6340
|
+
* not individual winner rows).
|
|
5600
6341
|
*
|
|
5601
|
-
*
|
|
6342
|
+
* @remarks
|
|
6343
|
+
* **Subscription model (`onUpdate`)**
|
|
6344
|
+
* The callback receives the FULL refreshed raffle list (never a
|
|
6345
|
+
* diff/patch). Each subsequent call to `getRaffles({ onUpdate })`
|
|
6346
|
+
* REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
|
|
6347
|
+
* it) to keep the prior callback in place; the callback is never
|
|
6348
|
+
* auto-cleared.
|
|
5602
6349
|
*
|
|
5603
|
-
*
|
|
5604
|
-
* _smartico.api.getRaffles().then((result) => {
|
|
5605
|
-
* console.log(result);
|
|
5606
|
-
* });
|
|
5607
|
-
* ```
|
|
6350
|
+
* **Update triggers** — the callback fires when:
|
|
5608
6351
|
*
|
|
5609
|
-
*
|
|
6352
|
+
* 1. {@link claimRafflePrize} resolves on this connection (any
|
|
6353
|
+
* response code) — the refreshed list reflects the new
|
|
6354
|
+
* `has_unclaimed_prize` / `claimed_date` state.
|
|
6355
|
+
* 2. {@link requestRaffleOptin} resolves on this connection (any
|
|
6356
|
+
* response code) — the refreshed list reflects the new
|
|
6357
|
+
* `user_opted_in` state on the affected draw.
|
|
6358
|
+
*
|
|
6359
|
+
* Does NOT fire for: server-side draw executions, ticket increments
|
|
6360
|
+
* (other users earning tickets), or operator-side raffle/draw config
|
|
6361
|
+
* changes. Those changes surface only on the next cache miss (after
|
|
6362
|
+
* the 30 s TTL) — poll manually if your UI needs sub-30s freshness
|
|
6363
|
+
* during an in-progress draw.
|
|
6364
|
+
*
|
|
6365
|
+
* **Reading state from the returned raffle**
|
|
6366
|
+
* - `current_tickets_count` vs `max_tickets_count` drives the
|
|
6367
|
+
* `ticket_cap_visualization` banner (enum
|
|
6368
|
+
* {@link RaffleTicketCapVisualization}: `Empty` = no banner,
|
|
6369
|
+
* `Counter` = show "X tickets remaining", `Message` = show
|
|
6370
|
+
* sold-out message).
|
|
6371
|
+
* - Within each draw, `current_state`
|
|
6372
|
+
* ({@link RaffleDrawInstanceState}) buckets the draw into Open
|
|
6373
|
+
* (accepting tickets), WinnerSelection (currently drawing), or
|
|
6374
|
+
* Executed (winners selected).
|
|
6375
|
+
* - `execution_type` ({@link RaffleDrawTypeExecution}) distinguishes
|
|
6376
|
+
* one-shot (`ExecDate`), repeating (`Recurring`), or special
|
|
6377
|
+
* one-shot (`Grand`) draws. Recurring draws share a stable
|
|
6378
|
+
* `draws[i].id` (the schedule definition) across runs — `run_id`
|
|
6379
|
+
* is the per-execution instance.
|
|
5610
6380
|
*
|
|
5611
|
-
*
|
|
5612
|
-
*
|
|
5613
|
-
*
|
|
6381
|
+
* **Cache TTL**: the SDK caches the response for 30 seconds. Cache
|
|
6382
|
+
* is fully cleared on login / logout. The server also invalidates
|
|
6383
|
+
* the SDK cache when a draw executes on the server side.
|
|
6384
|
+
*
|
|
6385
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
6386
|
+
*
|
|
6387
|
+
* **UI guidance**: see [UI Guide — `getRaffles`](../../docs/ui/raffles/UIGuide_getRaffles.md).
|
|
6388
|
+
*
|
|
6389
|
+
* **Visitor mode**: supported. The same shape is returned, scoped
|
|
6390
|
+
* to the brand's public raffles. Per-user fields (`my_tickets_count`,
|
|
6391
|
+
* `my_last_tickets`, `user_opted_in`) are not meaningful for
|
|
6392
|
+
* visitors. The `onUpdate` callback is accepted but never fires
|
|
6393
|
+
* because the mutation methods that trigger it
|
|
6394
|
+
* ({@link claimRafflePrize}, {@link requestRaffleOptin}) are not
|
|
6395
|
+
* available / not effective in visitor mode.
|
|
6396
|
+
*
|
|
6397
|
+
* @param params Optional. Omit to fetch without subscribing.
|
|
6398
|
+
* @param params.onUpdate Callback invoked with the full refreshed
|
|
6399
|
+
* raffles list after every
|
|
6400
|
+
* {@link claimRafflePrize} or
|
|
6401
|
+
* {@link requestRaffleOptin} round-trip
|
|
6402
|
+
* on this connection.
|
|
6403
|
+
* @returns Promise resolving to the raffles list.
|
|
6404
|
+
*
|
|
6405
|
+
* @example
|
|
6406
|
+
* ```ts
|
|
6407
|
+
* const raffles = await window._smartico.api.getRaffles({
|
|
6408
|
+
* onUpdate: (refreshed) => {
|
|
6409
|
+
* console.log('[smartico] raffles refreshed (after claim/optin) — re-render from this array:', refreshed);
|
|
6410
|
+
* },
|
|
5614
6411
|
* });
|
|
5615
|
-
* ```
|
|
5616
6412
|
*
|
|
6413
|
+
* for (const raffle of raffles) {
|
|
6414
|
+
* console.log('[smartico] render raffle', raffle.id, '—', raffle.name, ':', raffle.draws.length, 'draws');
|
|
6415
|
+
*
|
|
6416
|
+
* // Bucket draws: active/upcoming first (sorted by execution_ts ASC), then executed last.
|
|
6417
|
+
* const sorted = [...raffle.draws].sort((a, b) => {
|
|
6418
|
+
* const aDone = a.current_state === 3; // Executed
|
|
6419
|
+
* const bDone = b.current_state === 3;
|
|
6420
|
+
* if (aDone !== bDone) return aDone ? 1 : -1; // executed sink to the bottom
|
|
6421
|
+
* return a.execution_ts - b.execution_ts;
|
|
6422
|
+
* });
|
|
6423
|
+
*
|
|
6424
|
+
* for (const d of sorted) {
|
|
6425
|
+
* if (d.requires_optin && !d.user_opted_in && d.is_active && d.current_state !== 3) {
|
|
6426
|
+
* console.log('[smartico] draw', d.run_id, '— show OPT IN CTA (requires_optin + not yet opted in + still active)');
|
|
6427
|
+
* }
|
|
6428
|
+
* if (d.current_state === 3) {
|
|
6429
|
+
* console.log('[smartico] draw', d.run_id, 'executed — fetch winner details via getRaffleDrawRun');
|
|
6430
|
+
* }
|
|
6431
|
+
* }
|
|
6432
|
+
* }
|
|
6433
|
+
*
|
|
6434
|
+
* // For winner detail on an executed draw, call getRaffleDrawRun separately.
|
|
6435
|
+
* ```
|
|
5617
6436
|
*/
|
|
5618
6437
|
;
|
|
5619
6438
|
_proto.getRaffles = function getRaffles(_temp) {
|
|
@@ -5632,27 +6451,106 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5632
6451
|
}
|
|
5633
6452
|
}
|
|
5634
6453
|
/**
|
|
5635
|
-
* Returns draw run
|
|
5636
|
-
*
|
|
6454
|
+
* Returns the full detail of a single raffle draw run — same shape
|
|
6455
|
+
* as the embedded `TRaffleDraw` in {@link getRaffles}, but populated
|
|
6456
|
+
* with paginated `prizes[].winners[]` rows including usernames and
|
|
6457
|
+
* avatars. Use this to render a draw detail / winners screen, or to
|
|
6458
|
+
* page through the winner list of an executed draw.
|
|
5637
6459
|
*
|
|
6460
|
+
* Each call is a fresh server round-trip — there is no client cache.
|
|
6461
|
+
* Re-call to refresh.
|
|
5638
6462
|
*
|
|
5639
|
-
*
|
|
6463
|
+
* @remarks
|
|
6464
|
+
* **Preconditions**
|
|
6465
|
+
* Pass `raffle_id` (the parent raffle's `id`) and `run_id` (the
|
|
6466
|
+
* specific run instance — `TRaffleDraw.run_id` from
|
|
6467
|
+
* {@link getRaffles}'s embedded draws). Note that
|
|
6468
|
+
* `TRaffleDraw.id` is the *schedule_id* (stable across runs of a
|
|
6469
|
+
* recurring draw) — that's NOT what this method takes; it takes the
|
|
6470
|
+
* per-instance `run_id`.
|
|
5640
6471
|
*
|
|
5641
|
-
*
|
|
5642
|
-
*
|
|
5643
|
-
*
|
|
5644
|
-
*
|
|
5645
|
-
*
|
|
6472
|
+
* **Refresh model**
|
|
6473
|
+
* - **No subscription.** One-shot promise.
|
|
6474
|
+
* - **No client cache.** Every call sends a network request.
|
|
6475
|
+
* - **No push event** refreshes the response. Live winner-list
|
|
6476
|
+
* updates require a fresh call.
|
|
6477
|
+
* - The default Smartico UI polls this method on a variable cadence
|
|
6478
|
+
* while a draw is in flight: every 3 s during `WinnerSelection`,
|
|
6479
|
+
* every 10 s when the countdown is under 5 minutes, every 30 s
|
|
6480
|
+
* otherwise.
|
|
6481
|
+
*
|
|
6482
|
+
* **Winner pagination**
|
|
6483
|
+
* `winners_from` / `winners_to` define a half-open range of winner
|
|
6484
|
+
* indices. The default window is `0–20` (20 winners). The server
|
|
6485
|
+
* caps the window at 50 rows per call — passing a larger range
|
|
6486
|
+
* silently truncates. For "load more" pagination, advance
|
|
6487
|
+
* `winners_from` by the prior page size and pass the same
|
|
6488
|
+
* `winners_to` offset. `winners_total` on the returned
|
|
6489
|
+
* `TRaffleDraw` is the authoritative total count for pagination.
|
|
6490
|
+
*
|
|
6491
|
+
* The current user's own winning rows (if any) are server-sorted
|
|
6492
|
+
* to the top of the result.
|
|
6493
|
+
*
|
|
6494
|
+
* **Throws**
|
|
6495
|
+
* Both `raffle_id` and `run_id` are required — the SDK throws
|
|
6496
|
+
* synchronously when either is missing or falsy.
|
|
6497
|
+
*
|
|
6498
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
6499
|
+
*
|
|
6500
|
+
* **UI guidance**: see [UI Guide — `getRaffleDrawRun`](../../docs/ui/raffles/UIGuide_getRaffleDrawRun.md).
|
|
6501
|
+
*
|
|
6502
|
+
* **Visitor mode**: supported.
|
|
6503
|
+
*
|
|
6504
|
+
* @param props.raffle_id The parent raffle's `id` (from `TRaffle.id`).
|
|
6505
|
+
* @param props.run_id The draw run instance ID (from
|
|
6506
|
+
* `TRaffleDraw.run_id`, not `TRaffleDraw.id`).
|
|
6507
|
+
* @param props.winners_from First winner index to return (0-based).
|
|
6508
|
+
* Defaults to `0`.
|
|
6509
|
+
* @param props.winners_to Last winner index (exclusive).
|
|
6510
|
+
* Defaults to `20`. Server caps the
|
|
6511
|
+
* window at 50 rows per call.
|
|
6512
|
+
* @returns Promise resolving to `TRaffleDraw`
|
|
6513
|
+
* with `prizes[].winners[]` populated
|
|
6514
|
+
* and `winners_total` set.
|
|
5646
6515
|
*
|
|
5647
|
-
*
|
|
6516
|
+
* @example
|
|
6517
|
+
* ```ts
|
|
6518
|
+
* const raffles = await window._smartico.api.getRaffles();
|
|
6519
|
+
* const raffle = raffles[0];
|
|
6520
|
+
* const draw = raffle.draws.find(d => d.current_state === 3); // Executed
|
|
5648
6521
|
*
|
|
6522
|
+
* if (!draw) {
|
|
6523
|
+
* console.log('[smartico] no executed draw — skip detail view');
|
|
6524
|
+
* return;
|
|
6525
|
+
* }
|
|
5649
6526
|
*
|
|
5650
|
-
*
|
|
5651
|
-
*
|
|
5652
|
-
*
|
|
6527
|
+
* // First page of winners.
|
|
6528
|
+
* const detail = await window._smartico.api.getRaffleDrawRun({
|
|
6529
|
+
* raffle_id: raffle.id,
|
|
6530
|
+
* run_id: draw.run_id, // NOTE: run_id, NOT draw.id
|
|
6531
|
+
* winners_from: 0,
|
|
6532
|
+
* winners_to: 20,
|
|
5653
6533
|
* });
|
|
5654
|
-
* ```
|
|
5655
6534
|
*
|
|
6535
|
+
* for (const prize of detail.prizes) {
|
|
6536
|
+
* console.log('[smartico] prize', prize.name, '— winners on this page:', prize.winners.length);
|
|
6537
|
+
* const myWin = prize.winners.find(w => w.username === currentUsername); // or another match
|
|
6538
|
+
* if (myWin) {
|
|
6539
|
+
* console.log('[smartico] current user won this prize — surface a Claim CTA if not yet claimed');
|
|
6540
|
+
* }
|
|
6541
|
+
* }
|
|
6542
|
+
*
|
|
6543
|
+
* // Load more — pagination via winners_from / winners_to.
|
|
6544
|
+
* if ((detail.winners_total ?? 0) > 20) {
|
|
6545
|
+
* const next = await window._smartico.api.getRaffleDrawRun({
|
|
6546
|
+
* raffle_id: raffle.id,
|
|
6547
|
+
* run_id: draw.run_id,
|
|
6548
|
+
* winners_from: 20,
|
|
6549
|
+
* winners_to: 40,
|
|
6550
|
+
* });
|
|
6551
|
+
* console.log('[smartico] page 2 loaded — append', next.prizes.flatMap(p => p.winners).length, 'winners');
|
|
6552
|
+
* }
|
|
6553
|
+
* ```
|
|
5656
6554
|
*/
|
|
5657
6555
|
;
|
|
5658
6556
|
_proto.getRaffleDrawRun = function getRaffleDrawRun(props) {
|
|
@@ -5667,25 +6565,76 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5667
6565
|
}
|
|
5668
6566
|
}
|
|
5669
6567
|
/**
|
|
5670
|
-
* Returns
|
|
6568
|
+
* Returns the history of past-executed draw runs for a raffle —
|
|
6569
|
+
* optionally scoped to a single recurring draw schedule. Each row
|
|
6570
|
+
* is a previously-executed run with its scheduled and
|
|
6571
|
+
* actual-execution timestamps, the user's win status, and an
|
|
6572
|
+
* unclaimed-prize flag for surfacing a Claim CTA on history rows.
|
|
6573
|
+
*
|
|
6574
|
+
* @remarks
|
|
6575
|
+
* **Preconditions**
|
|
6576
|
+
* `raffle_id` is required. `draw_id` is optional — when omitted,
|
|
6577
|
+
* the response includes history for ALL draws of the raffle; when
|
|
6578
|
+
* supplied, it scopes to that one draw's recurring history. The
|
|
6579
|
+
* `draw_id` to pass is `TRaffleDraw.id` (the schedule_id, stable
|
|
6580
|
+
* across runs), not `run_id`.
|
|
6581
|
+
*
|
|
6582
|
+
* **Server-side filtering**
|
|
6583
|
+
* Draws configured by the operator to hide their history are
|
|
6584
|
+
* excluded from the response automatically. Cancelled runs are
|
|
6585
|
+
* also excluded.
|
|
6586
|
+
*
|
|
6587
|
+
* **Sort order**
|
|
6588
|
+
* Server returns rows by scheduled `execution_ts` descending
|
|
6589
|
+
* (newest first). No client-side sort required.
|
|
6590
|
+
*
|
|
6591
|
+
* **Refresh model**
|
|
6592
|
+
* - **No subscription.** One-shot promise.
|
|
6593
|
+
* - **No client cache.** Every call hits the server.
|
|
6594
|
+
* - **No push event** refreshes the response. Re-call manually to
|
|
6595
|
+
* pick up newly-executed runs or `has_unclaimed_prize` flips
|
|
6596
|
+
* after a {@link claimRafflePrize} call.
|
|
6597
|
+
*
|
|
6598
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
6599
|
+
*
|
|
6600
|
+
* **UI guidance**: see [UI Guide — `getRaffleDrawRunsHistory`](../../docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md).
|
|
5671
6601
|
*
|
|
6602
|
+
* **Visitor mode**: supported. The same shape is returned with
|
|
6603
|
+
* `is_winner` and `has_unclaimed_prize` always `false` for visitors.
|
|
5672
6604
|
*
|
|
5673
|
-
*
|
|
6605
|
+
* @param props.raffle_id The parent raffle's `id` (from `TRaffle.id`).
|
|
6606
|
+
* Required.
|
|
6607
|
+
* @param props.draw_id Optional — the draw's schedule_id
|
|
6608
|
+
* (`TRaffleDraw.id`). When set, scopes the
|
|
6609
|
+
* history to that one draw's runs. When
|
|
6610
|
+
* omitted, includes all draws of the raffle.
|
|
6611
|
+
* @returns Promise resolving to a `TRaffleDrawRun[]`
|
|
6612
|
+
* ordered newest-first. Empty if no executed
|
|
6613
|
+
* runs exist.
|
|
5674
6614
|
*
|
|
5675
|
-
*
|
|
5676
|
-
*
|
|
5677
|
-
*
|
|
6615
|
+
* @example
|
|
6616
|
+
* ```ts
|
|
6617
|
+
* const raffles = await window._smartico.api.getRaffles();
|
|
6618
|
+
* const raffle = raffles[0];
|
|
6619
|
+
*
|
|
6620
|
+
* // History across all draws of the raffle.
|
|
6621
|
+
* const allHistory = await window._smartico.api.getRaffleDrawRunsHistory({
|
|
6622
|
+
* raffle_id: raffle.id,
|
|
5678
6623
|
* });
|
|
5679
|
-
* ```
|
|
5680
6624
|
*
|
|
5681
|
-
*
|
|
6625
|
+
* // Highlight rows where the user has an unclaimed prize.
|
|
6626
|
+
* const unclaimed = allHistory.filter(r => r.has_unclaimed_prize);
|
|
6627
|
+
* if (unclaimed.length > 0) {
|
|
6628
|
+
* console.log('[smartico] surface a "Claim" CTA on these', unclaimed.length, 'history rows:', unclaimed.map(r => r.run_id));
|
|
6629
|
+
* }
|
|
5682
6630
|
*
|
|
5683
|
-
*
|
|
5684
|
-
*
|
|
5685
|
-
*
|
|
6631
|
+
* // Scoped history of one recurring draw (use draw.id, the schedule_id).
|
|
6632
|
+
* const oneDrawHistory = await window._smartico.api.getRaffleDrawRunsHistory({
|
|
6633
|
+
* raffle_id: raffle.id,
|
|
6634
|
+
* draw_id: raffle.draws[0].id, // schedule_id (stable across recurring runs)
|
|
5686
6635
|
* });
|
|
6636
|
+
* console.log('[smartico] render history rows for the daily draw — newest first:', oneDrawHistory.length, 'rows');
|
|
5687
6637
|
* ```
|
|
5688
|
-
*
|
|
5689
6638
|
*/
|
|
5690
6639
|
;
|
|
5691
6640
|
_proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(props) {
|
|
@@ -5702,25 +6651,113 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5702
6651
|
}
|
|
5703
6652
|
}
|
|
5704
6653
|
/**
|
|
5705
|
-
*
|
|
6654
|
+
* Claims a raffle prize the user has won. Call this when the user
|
|
6655
|
+
* has a winning row with `should_claim === true` and an unclaimed
|
|
6656
|
+
* `won_id` (read from a `TRafflePrizeWinner` on a
|
|
6657
|
+
* {@link getRaffleDrawRun} result, or surfaced by `has_unclaimed_prize`
|
|
6658
|
+
* on a {@link getRaffleDrawRunsHistory} row that the consumer drills
|
|
6659
|
+
* into).
|
|
5706
6660
|
*
|
|
6661
|
+
* On success (`errorCode === 0`), the server records the claim and
|
|
6662
|
+
* triggers prize delivery through the operator's integration —
|
|
6663
|
+
* delivery is server-side, not part of this response.
|
|
5707
6664
|
*
|
|
5708
|
-
*
|
|
6665
|
+
* @remarks
|
|
6666
|
+
* **Result shape note**: this method returns
|
|
6667
|
+
* `TransformedRaffleClaimPrizeResponse` with `errorCode` /
|
|
6668
|
+
* `errorMessage` (camelCase full-word) — different from most other
|
|
6669
|
+
* SDK result types which use `err_code` / `err_message` (snake_case
|
|
6670
|
+
* short-word). Branch on the camelCase keys when reading this
|
|
6671
|
+
* method's result.
|
|
5709
6672
|
*
|
|
5710
|
-
*
|
|
5711
|
-
*
|
|
5712
|
-
*
|
|
5713
|
-
*
|
|
5714
|
-
*
|
|
6673
|
+
* **Preconditions**
|
|
6674
|
+
* Pass a `won_id` that identifies an unclaimed winning row for the
|
|
6675
|
+
* current user. The `won_id` comes from
|
|
6676
|
+
* `TRafflePrizeWinner.raf_won_id` returned by
|
|
6677
|
+
* {@link getRaffleDrawRun}.
|
|
6678
|
+
*
|
|
6679
|
+
* **Error codes** (in `errorCode`)
|
|
6680
|
+
* - `0` — success; the claim is recorded and prize delivery is
|
|
6681
|
+
* queued server-side.
|
|
6682
|
+
* - `1` — generic claim failure. The `errorMessage` distinguishes
|
|
6683
|
+
* the specific cause (the server uses one error code for several
|
|
6684
|
+
* distinct conditions): the prize has already been claimed, the
|
|
6685
|
+
* `won_id` doesn't match a winning row for this user, or the user
|
|
6686
|
+
* is in a control group for this raffle. Treat `1` as a retryable
|
|
6687
|
+
* error if the message suggests a transient condition; treat as
|
|
6688
|
+
* idempotent success if the message indicates already-claimed
|
|
6689
|
+
* (the underlying state is what the consumer wants either way —
|
|
6690
|
+
* the prize is claimed).
|
|
6691
|
+
* - other non-zero — generic server error. Surface `errorMessage`
|
|
6692
|
+
* if any.
|
|
6693
|
+
*
|
|
6694
|
+
* **Claim window**
|
|
6695
|
+
* There is no server-enforced claim deadline. Won prizes remain
|
|
6696
|
+
* claimable indefinitely until the operator archives them.
|
|
6697
|
+
*
|
|
6698
|
+
* **Idempotency**: NOT idempotent. A second call on the same
|
|
6699
|
+
* `won_id` returns `errorCode === 1` with `errorMessage` indicating
|
|
6700
|
+
* the prize has already been claimed. The SDK does NOT enforce an
|
|
6701
|
+
* in-flight lock. Guard the call site against double-clicks (set
|
|
6702
|
+
* a local "claiming" flag on click, clear it on response).
|
|
5715
6703
|
*
|
|
5716
|
-
* **
|
|
6704
|
+
* **Refresh after success (and after failure)**
|
|
6705
|
+
* The SDK automatically refreshes the raffles cache on every
|
|
6706
|
+
* response — both success and failure paths fire the `onUpdate`
|
|
6707
|
+
* callback registered via {@link getRaffles}. After `errorCode === 0`,
|
|
6708
|
+
* the affected `TRaffleDrawRun.has_unclaimed_prize` (in history)
|
|
6709
|
+
* and the winner row's `claimed_date` reflect the claim on the next
|
|
6710
|
+
* refresh.
|
|
6711
|
+
*
|
|
6712
|
+
* **Side effects** (on `errorCode === 0`)
|
|
6713
|
+
* - The winner row's `claimed_date` is set server-side.
|
|
6714
|
+
* - Prize delivery is queued for the operator's integration to
|
|
6715
|
+
* process. Balance / bonus / inbox updates that result from the
|
|
6716
|
+
* delivery arrive through their own channels — not in this
|
|
6717
|
+
* response.
|
|
6718
|
+
*
|
|
6719
|
+
* **Throws**
|
|
6720
|
+
* `won_id` is required — the SDK throws synchronously when missing
|
|
6721
|
+
* or falsy.
|
|
6722
|
+
*
|
|
6723
|
+
* **UI guidance**: see [UI Guide — `claimRafflePrize`](../../docs/ui/raffles/UIGuide_claimRafflePrize.md).
|
|
6724
|
+
*
|
|
6725
|
+
* **Visitor mode**: not meaningfully supported. The SDK does not
|
|
6726
|
+
* block the call, but visitor sessions have no win history and the
|
|
6727
|
+
* server will reject it.
|
|
6728
|
+
*
|
|
6729
|
+
* @param props.won_id The winning row's `raf_won_id` (from
|
|
6730
|
+
* `TRafflePrizeWinner` returned by
|
|
6731
|
+
* {@link getRaffleDrawRun}).
|
|
6732
|
+
* @returns `{ errorCode, errorMessage? }`; success when
|
|
6733
|
+
* `errorCode === 0`. Note camelCase keys (see "Result
|
|
6734
|
+
* shape note" above).
|
|
5717
6735
|
*
|
|
5718
|
-
*
|
|
5719
|
-
*
|
|
5720
|
-
*
|
|
6736
|
+
* @example
|
|
6737
|
+
* ```ts
|
|
6738
|
+
* const detail = await window._smartico.api.getRaffleDrawRun({
|
|
6739
|
+
* raffle_id: raffleId,
|
|
6740
|
+
* run_id: runId,
|
|
5721
6741
|
* });
|
|
5722
|
-
*
|
|
6742
|
+
* const myWin = detail.prizes.flatMap(p => p.winners).find(w => /* user match here *\/ true);
|
|
5723
6743
|
*
|
|
6744
|
+
* if (!myWin || !myWin.raf_won_id || myWin.claimed_date) {
|
|
6745
|
+
* console.log('[smartico] nothing to claim — keep CTA hidden');
|
|
6746
|
+
* return;
|
|
6747
|
+
* }
|
|
6748
|
+
*
|
|
6749
|
+
* console.log('[smartico] claim starting — set in-flight flag, show loading dots on the Claim button, keep the modal open');
|
|
6750
|
+
* const r = await window._smartico.api.claimRafflePrize({ won_id: myWin.raf_won_id });
|
|
6751
|
+
* console.log('[smartico] claim response received — clear in-flight flag');
|
|
6752
|
+
*
|
|
6753
|
+
* if (r.errorCode === 0) {
|
|
6754
|
+
* console.log('[smartico] claim succeeded — show a success toast; getRaffles onUpdate above will fire with refreshed state; prize delivery happens server-side');
|
|
6755
|
+
* } else if (r.errorCode === 1 && r.errorMessage?.toLowerCase().includes('already claimed')) {
|
|
6756
|
+
* console.log('[smartico] prize was already claimed (perhaps from another tab) — treat as success, hide the Claim CTA');
|
|
6757
|
+
* } else {
|
|
6758
|
+
* console.error('[smartico] claim failed — surface this error message to the user and allow retry:', r.errorMessage);
|
|
6759
|
+
* }
|
|
6760
|
+
* ```
|
|
5724
6761
|
*/
|
|
5725
6762
|
;
|
|
5726
6763
|
_proto.claimRafflePrize = function claimRafflePrize(props) {
|
|
@@ -5737,9 +6774,104 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5737
6774
|
}
|
|
5738
6775
|
}
|
|
5739
6776
|
/**
|
|
5740
|
-
*
|
|
6777
|
+
* Opts the current user into a specific raffle draw run. Required
|
|
6778
|
+
* for draws where `TRaffleDraw.requires_optin === true` — without
|
|
6779
|
+
* opt-in, the user's tickets do NOT participate in that run, even
|
|
6780
|
+
* if they hold tickets for the raffle.
|
|
5741
6781
|
*
|
|
5742
|
-
*
|
|
6782
|
+
* Opt-in is per-run: a recurring draw's next run requires a fresh
|
|
6783
|
+
* opt-in. The user's `TRaffleDraw.user_opted_in` flag reflects the
|
|
6784
|
+
* current state for the current run only.
|
|
6785
|
+
*
|
|
6786
|
+
* @remarks
|
|
6787
|
+
* **Preconditions**
|
|
6788
|
+
* Read the candidate draw from {@link getRaffles}'s embedded
|
|
6789
|
+
* `draws[]` and gate the call on
|
|
6790
|
+
* `requires_optin === true && !user_opted_in && is_active &&
|
|
6791
|
+
* current_state !== Executed`. Calling without these guards may
|
|
6792
|
+
* return a non-zero `err_code`.
|
|
6793
|
+
*
|
|
6794
|
+
* **Argument mapping** — the three IDs come from different fields:
|
|
6795
|
+
* - `raffle_id` — the parent raffle's `TRaffle.id`
|
|
6796
|
+
* - `draw_id` — `TRaffleDraw.id` (schedule_id, stable across runs)
|
|
6797
|
+
* - `raffle_run_id` — `TRaffleDraw.run_id` (instance ID for this
|
|
6798
|
+
* specific run)
|
|
6799
|
+
*
|
|
6800
|
+
* **Error codes** (in `err_code`)
|
|
6801
|
+
* - `0` — success; the user is opted into this run. Tickets
|
|
6802
|
+
* collected after the run's `ticket_start_ts` will participate.
|
|
6803
|
+
* - `1` — generic opt-in failure. The `err_message` distinguishes
|
|
6804
|
+
* the specific cause: the draw doesn't require opt-in
|
|
6805
|
+
* (`requires_optin === false`), `raffle_id` doesn't match the
|
|
6806
|
+
* `draw_id`, the user is already opted in (or the draw has
|
|
6807
|
+
* completed), or the user is in a control group for this raffle.
|
|
6808
|
+
* - other non-zero — generic server error. Surface `err_message`.
|
|
6809
|
+
*
|
|
6810
|
+
* **Idempotency**: NOT idempotent. A second call on the same
|
|
6811
|
+
* `raffle_run_id` returns `err_code === 1` with `err_message`
|
|
6812
|
+
* indicating the user is already opted in. Treat as success in
|
|
6813
|
+
* the UI — the underlying state is what the consumer wants.
|
|
6814
|
+
* Guard the call site against double-clicks.
|
|
6815
|
+
*
|
|
6816
|
+
* **Refresh after success (and after failure)**
|
|
6817
|
+
* The SDK automatically refreshes the raffles cache on every
|
|
6818
|
+
* response and fires the `onUpdate` callback registered via
|
|
6819
|
+
* {@link getRaffles}. After `err_code === 0`, the affected draw's
|
|
6820
|
+
* `user_opted_in` flips to `true` on the refreshed list.
|
|
6821
|
+
*
|
|
6822
|
+
* **Side effects** (on `err_code === 0`)
|
|
6823
|
+
* - The user is registered for this run. Tickets earned within
|
|
6824
|
+
* the run's eligibility window will participate in the draw.
|
|
6825
|
+
* - No balance change. No CRM-side rewards. Opt-in is a metadata
|
|
6826
|
+
* operation only.
|
|
6827
|
+
*
|
|
6828
|
+
* **Throws**
|
|
6829
|
+
* `raffle_id`, `draw_id`, and `raffle_run_id` are all required —
|
|
6830
|
+
* the SDK throws synchronously when any is missing or falsy.
|
|
6831
|
+
*
|
|
6832
|
+
* **UI guidance**: see [UI Guide — `requestRaffleOptin`](../../docs/ui/raffles/UIGuide_requestRaffleOptin.md).
|
|
6833
|
+
*
|
|
6834
|
+
* **Visitor mode**: not supported.
|
|
6835
|
+
*
|
|
6836
|
+
* @param props.raffle_id The parent raffle's `id`.
|
|
6837
|
+
* @param props.draw_id The draw's schedule_id (`TRaffleDraw.id`).
|
|
6838
|
+
* @param props.raffle_run_id The run instance ID (`TRaffleDraw.run_id`).
|
|
6839
|
+
* @returns `{ err_code, err_message? }`; success
|
|
6840
|
+
* when `err_code === 0` (treat
|
|
6841
|
+
* "already opted in" as idempotent
|
|
6842
|
+
* success).
|
|
6843
|
+
*
|
|
6844
|
+
* @example
|
|
6845
|
+
* ```ts
|
|
6846
|
+
* const raffles = await window._smartico.api.getRaffles({
|
|
6847
|
+
* onUpdate: (refreshed) => console.log('[smartico] raffles refreshed — re-render', refreshed),
|
|
6848
|
+
* });
|
|
6849
|
+
* const raffle = raffles[0];
|
|
6850
|
+
* const draw = raffle.draws.find(d =>
|
|
6851
|
+
* d.requires_optin && !d.user_opted_in && d.is_active && d.current_state !== 3
|
|
6852
|
+
* );
|
|
6853
|
+
*
|
|
6854
|
+
* if (!draw) {
|
|
6855
|
+
* console.log('[smartico] no opt-in-required draw available — keep CTA hidden');
|
|
6856
|
+
* return;
|
|
6857
|
+
* }
|
|
6858
|
+
*
|
|
6859
|
+
* console.log('[smartico] opt-in starting — set in-flight flag, show loading dots on the Opt-in button');
|
|
6860
|
+
* const r = await window._smartico.api.requestRaffleOptin({
|
|
6861
|
+
* raffle_id: raffle.id,
|
|
6862
|
+
* draw_id: draw.id, // schedule_id, NOT run_id
|
|
6863
|
+
* raffle_run_id: draw.run_id,
|
|
6864
|
+
* });
|
|
6865
|
+
* console.log('[smartico] opt-in response received — clear in-flight flag');
|
|
6866
|
+
*
|
|
6867
|
+
* if (r.err_code === 0) {
|
|
6868
|
+
* console.log('[smartico] opted in successfully — show "Fully opted in" state on the draw card; onUpdate above will fire with user_opted_in: true');
|
|
6869
|
+
* } else if (r.err_code === 1 && r.err_message?.toLowerCase().includes('already opted in')) {
|
|
6870
|
+
* console.log('[smartico] already opted in (perhaps from another tab) — treat as success, show "Fully opted in"');
|
|
6871
|
+
* } else {
|
|
6872
|
+
* console.error('[smartico] opt-in failed — surface this error to the user:', r.err_message);
|
|
6873
|
+
* }
|
|
6874
|
+
* ```
|
|
5743
6875
|
*/
|
|
5744
6876
|
;
|
|
5745
6877
|
_proto.requestRaffleOptin = function requestRaffleOptin(props) {
|
|
@@ -5763,6 +6895,142 @@ var WSAPIRaffles = /*#__PURE__*/function (_WSAPIJackpots) {
|
|
|
5763
6895
|
} catch (e) {
|
|
5764
6896
|
return Promise.reject(e);
|
|
5765
6897
|
}
|
|
6898
|
+
}
|
|
6899
|
+
/**
|
|
6900
|
+
* Returns every prize the current user has won within a single raffle —
|
|
6901
|
+
* across ALL of that raffle's draws, newest-won first — in one paginated
|
|
6902
|
+
* call. Use this to power a "my prizes" screen for a raffle (prize name,
|
|
6903
|
+
* prize image, the user's name/avatar) without walking
|
|
6904
|
+
* {@link getRaffleDrawRunsHistory} and then paging
|
|
6905
|
+
* {@link getRaffleDrawRun}'s per-draw winner lists.
|
|
6906
|
+
*
|
|
6907
|
+
* Each row carries its own `raf_won_id`, which IS the `won_id` to pass to
|
|
6908
|
+
* {@link claimRafflePrize}: a row with `requires_claim === true` and no
|
|
6909
|
+
* `claimed_date` is directly claimable.
|
|
6910
|
+
*
|
|
6911
|
+
* @remarks
|
|
6912
|
+
* **Authentication required**
|
|
6913
|
+
* Works only for an identified (logged-in) user. Visitor / anonymous
|
|
6914
|
+
* sessions are rejected — call this only after identify.
|
|
6915
|
+
*
|
|
6916
|
+
* **Preconditions**
|
|
6917
|
+
* `raffle_id` is required — the SDK throws synchronously when it is
|
|
6918
|
+
* missing or falsy.
|
|
6919
|
+
*
|
|
6920
|
+
* **Coverage & sort order**
|
|
6921
|
+
* Includes the user's wins from every draw of the raffle — recurring,
|
|
6922
|
+
* one-shot, and grand draws, across all historical runs. Rows are ordered
|
|
6923
|
+
* newest-win first; there is no "unclaimed first" ordering, so sort
|
|
6924
|
+
* client-side if you want claimable prizes at the top.
|
|
6925
|
+
*
|
|
6926
|
+
* **Pagination**
|
|
6927
|
+
* `offset` / `limit` page the `won_prizes[]` rows (the SDK defaults to
|
|
6928
|
+
* `0` / `20`). `total` is the authoritative full count of the user's wins
|
|
6929
|
+
* for this raffle across all draws — drive "load more" from it
|
|
6930
|
+
* (`offset + won_prizes.length < total`). An `offset` past the end returns
|
|
6931
|
+
* an empty `won_prizes[]` with the real `total` and `errCode 0` — not an
|
|
6932
|
+
* error. The server does NOT clamp `limit`, so always pass an explicit,
|
|
6933
|
+
* sane page size.
|
|
6934
|
+
*
|
|
6935
|
+
* **Rate limit**
|
|
6936
|
+
* The server caps this at roughly 30 calls per minute with a ~5-second
|
|
6937
|
+
* minimum gap between calls. Fetch on screen open and on explicit "load
|
|
6938
|
+
* more" — don't poll it on a timer.
|
|
6939
|
+
*
|
|
6940
|
+
* **Error codes** (in `errCode`)
|
|
6941
|
+
* - `0` — success. Also returned with an empty `won_prizes[]` and
|
|
6942
|
+
* `total 0` when the user has no wins, or is not eligible to see this
|
|
6943
|
+
* raffle.
|
|
6944
|
+
* - `1` — generic server error; surface `errMsg` if present.
|
|
6945
|
+
*
|
|
6946
|
+
* There are no granular codes — an unknown raffle, an ineligible user,
|
|
6947
|
+
* and "no wins" all surface as `errCode 0` with an empty list.
|
|
6948
|
+
*
|
|
6949
|
+
* **Reading the result**
|
|
6950
|
+
* - Null-check `user` before reading it — it is `null` whenever
|
|
6951
|
+
* `won_prizes` is empty.
|
|
6952
|
+
* - For the avatar, use `user.avatar_id` (already a full URL for a system
|
|
6953
|
+
* avatar, otherwise an avatar token to resolve against the widget's
|
|
6954
|
+
* avatar domain); `user.avatar_url` is always `null`.
|
|
6955
|
+
* - Render `public_username` as-is (it is server-masked for privacy, e.g.
|
|
6956
|
+
* `"32:r*****"`) and substitute a "You" label for the current user.
|
|
6957
|
+
* - Treat `claimed_date` as the claim flag: `null` until claimed, then
|
|
6958
|
+
* epoch ms.
|
|
6959
|
+
*
|
|
6960
|
+
* **Idempotency / Side effects**: safe and read-only — one-shot promise,
|
|
6961
|
+
* no client cache, no subscription. The server caches the response
|
|
6962
|
+
* briefly; a successful {@link claimRafflePrize} invalidates that cache,
|
|
6963
|
+
* so a follow-up call reflects the new `claimed_date`. This method does
|
|
6964
|
+
* NOT refresh the {@link getRaffles} list or fire its `onUpdate` — re-call
|
|
6965
|
+
* manually to pick up newly-won prizes or a `claimed_date` flip.
|
|
6966
|
+
*
|
|
6967
|
+
* **UI guidance**: see [UI Guide — `getRaffleWonPrizes`](../../docs/ui/raffles/UIGuide_getRaffleWonPrizes.md).
|
|
6968
|
+
*
|
|
6969
|
+
* **Visitor mode**: not supported (see "Authentication required").
|
|
6970
|
+
*
|
|
6971
|
+
* @param props.raffle_id The parent raffle's `id` (from `TRaffle.id`). Required.
|
|
6972
|
+
* @param props.offset Zero-based index of the first row to return. Defaults to `0`.
|
|
6973
|
+
* @param props.limit Page size. Defaults to `20`.
|
|
6974
|
+
* @returns Promise resolving to {@link GetRaffleWonPrizesResponse}
|
|
6975
|
+
* (`user`, this page of `won_prizes`, and `total`;
|
|
6976
|
+
* `errCode 0` on success).
|
|
6977
|
+
*
|
|
6978
|
+
* @example
|
|
6979
|
+
* ```ts
|
|
6980
|
+
* const raffles = await window._smartico.api.getRaffles();
|
|
6981
|
+
* const raffle = raffles[0];
|
|
6982
|
+
*
|
|
6983
|
+
* // First page of the user's won prizes for this raffle.
|
|
6984
|
+
* const page = await window._smartico.api.getRaffleWonPrizes({
|
|
6985
|
+
* raffle_id: raffle.id,
|
|
6986
|
+
* offset: 0,
|
|
6987
|
+
* limit: 20,
|
|
6988
|
+
* });
|
|
6989
|
+
*
|
|
6990
|
+
* if (page.errCode !== 0) {
|
|
6991
|
+
* console.error('[smartico] could not load won prizes — show a retry state:', page.errMsg);
|
|
6992
|
+
* return;
|
|
6993
|
+
* }
|
|
6994
|
+
* if (page.won_prizes.length === 0) {
|
|
6995
|
+
* console.log('[smartico] no wins in this raffle (or not eligible) — render the empty state');
|
|
6996
|
+
* return;
|
|
6997
|
+
* }
|
|
6998
|
+
*
|
|
6999
|
+
* console.log('[smartico]', page.user?.public_username, 'won', page.total, 'prizes total');
|
|
7000
|
+
* for (const prize of page.won_prizes) {
|
|
7001
|
+
* console.log('[smartico] render prize card —', prize.public_meta.name, prize.public_meta.image_url);
|
|
7002
|
+
* if (prize.requires_claim && !prize.claimed_date) {
|
|
7003
|
+
* console.log('[smartico] show a Claim CTA — on click call claimRafflePrize({ won_id:', prize.raf_won_id, '})');
|
|
7004
|
+
* }
|
|
7005
|
+
* }
|
|
7006
|
+
*
|
|
7007
|
+
* // Load more.
|
|
7008
|
+
* if (page.offset + page.won_prizes.length < page.total) {
|
|
7009
|
+
* const next = await window._smartico.api.getRaffleWonPrizes({
|
|
7010
|
+
* raffle_id: raffle.id,
|
|
7011
|
+
* offset: page.offset + page.limit,
|
|
7012
|
+
* limit: 20,
|
|
7013
|
+
* });
|
|
7014
|
+
* console.log('[smartico] appended', next.won_prizes.length, 'more prizes');
|
|
7015
|
+
* }
|
|
7016
|
+
* ```
|
|
7017
|
+
*/
|
|
7018
|
+
;
|
|
7019
|
+
_proto.getRaffleWonPrizes = function getRaffleWonPrizes(props) {
|
|
7020
|
+
try {
|
|
7021
|
+
var _props$offset, _props$limit;
|
|
7022
|
+
var _this7 = this;
|
|
7023
|
+
if (!props.raffle_id) {
|
|
7024
|
+
throw new Error('raffle_id is required');
|
|
7025
|
+
}
|
|
7026
|
+
return Promise.resolve(_this7.api.getRaffleWonPrizes(_this7.userExtId, {
|
|
7027
|
+
raffle_id: props.raffle_id,
|
|
7028
|
+
offset: (_props$offset = props.offset) != null ? _props$offset : 0,
|
|
7029
|
+
limit: (_props$limit = props.limit) != null ? _props$limit : 20
|
|
7030
|
+
}));
|
|
7031
|
+
} catch (e) {
|
|
7032
|
+
return Promise.reject(e);
|
|
7033
|
+
}
|
|
5766
7034
|
};
|
|
5767
7035
|
return WSAPIRaffles;
|
|
5768
7036
|
}(WSAPIJackpots);
|
|
@@ -5775,24 +7043,98 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
|
|
|
5775
7043
|
_inheritsLoose(WSAPIMiniGames, _WSAPIRaffles);
|
|
5776
7044
|
var _proto = WSAPIMiniGames.prototype;
|
|
5777
7045
|
/**
|
|
5778
|
-
* Returns
|
|
5779
|
-
*
|
|
5780
|
-
*
|
|
7046
|
+
* Returns all mini-game templates ("SAW" = Spin And Win — the
|
|
7047
|
+
* umbrella term for wheel-spin, scratch-card, lootbox, gift-box,
|
|
7048
|
+
* treasure-hunt, plinko, coin-flip, quiz, and several other formats)
|
|
7049
|
+
* configured for the label. Optionally subscribes to live updates
|
|
7050
|
+
* via `onUpdate`: the callback fires whenever the user's
|
|
7051
|
+
* `spin_count` changes, jackpot grows, a manual spin is issued, or
|
|
7052
|
+
* a spin response lands.
|
|
7053
|
+
*
|
|
7054
|
+
* The list is NOT filtered by spin availability — every configured
|
|
7055
|
+
* template is returned, including ones the user cannot currently
|
|
7056
|
+
* play. The `visibile_when_can_spin` flag on each template hints
|
|
7057
|
+
* which to hide in a default lobby view (consumer-side filter).
|
|
5781
7058
|
*
|
|
5782
|
-
*
|
|
5783
|
-
*
|
|
5784
|
-
*
|
|
5785
|
-
*
|
|
5786
|
-
*
|
|
5787
|
-
*
|
|
7059
|
+
* @remarks
|
|
7060
|
+
* **Subscription model (`onUpdate`)**
|
|
7061
|
+
* The callback receives the FULL refreshed template list (never a
|
|
7062
|
+
* diff/patch). Each subsequent call to `getMiniGames({ onUpdate })`
|
|
7063
|
+
* REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
|
|
7064
|
+
* it) to keep the prior callback in place; the callback is never
|
|
7065
|
+
* auto-cleared.
|
|
5788
7066
|
*
|
|
5789
|
-
* **
|
|
5790
|
-
*
|
|
5791
|
-
*
|
|
5792
|
-
*
|
|
7067
|
+
* **Update triggers** — the callback fires when:
|
|
7068
|
+
*
|
|
7069
|
+
* 1. The server pushes a `spin_count` change (campaign award,
|
|
7070
|
+
* store purchase, BO manual issuance, mission reward).
|
|
7071
|
+
* 2. Any {@link playMiniGame} or {@link playMiniGameBatch}
|
|
7072
|
+
* resolves on this connection — the cached array refreshes
|
|
7073
|
+
* with updated `spin_count`, `jackpot_current`, and any new
|
|
7074
|
+
* `next_available_spin_ts`.
|
|
7075
|
+
* 3. Acknowledge responses land (via auto-acknowledge or
|
|
7076
|
+
* {@link miniGameWinAcknowledgeRequest}).
|
|
7077
|
+
*
|
|
7078
|
+
* Jackpot growth is observable on the refreshed `jackpot_current`
|
|
7079
|
+
* field — the SDK inlines the live value into template `name` /
|
|
7080
|
+
* `promo_text` / prize `name` via a `{{jackpot}}` template
|
|
7081
|
+
* substitution at fetch time.
|
|
7082
|
+
*
|
|
7083
|
+
* **Game-type variants**
|
|
7084
|
+
* All twelve `SAWGameType` values (`SpinAWheel`, `ScratchCard`,
|
|
7085
|
+
* `MatchX`, `GiftBox`, `PrizeDrop`, `Quiz`, `LootboxWeekdays`,
|
|
7086
|
+
* `LootboxCalendarDays`, `TreasureHunt`, `Voyager`, `Plinko`,
|
|
7087
|
+
* `CoinFlip`) surface through the same template shape. Most are
|
|
7088
|
+
* played via {@link playMiniGame}; the exceptions are:
|
|
7089
|
+
* - `PrizeDrop` — server-push only; the consumer does NOT call
|
|
7090
|
+
* `playMiniGame`. Prizes arrive via the prize-drop push channel.
|
|
7091
|
+
* - `MatchX` / `Quiz` — predictions are submitted via a separate
|
|
7092
|
+
* games server (not this SDK); the SAW spin is fired
|
|
7093
|
+
* server-internally to deduct the buy-in.
|
|
7094
|
+
*
|
|
7095
|
+
* **Cache TTL**: the SDK caches the response for 30 seconds. Cache
|
|
7096
|
+
* is fully cleared on login / logout.
|
|
7097
|
+
*
|
|
7098
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
7099
|
+
*
|
|
7100
|
+
* **UI guidance**: see [UI Guide — `getMiniGames`](../../docs/ui/minigames/UIGuide_getMiniGames.md).
|
|
7101
|
+
*
|
|
7102
|
+
* **Visitor mode**: supported. Only templates configured with
|
|
7103
|
+
* `is_visitor_mode = true` in the BO are returned for anonymous
|
|
7104
|
+
* sessions. Spins from these templates may also be played (visitor
|
|
7105
|
+
* mode is the one mini-game flow that does support play — see
|
|
7106
|
+
* {@link playMiniGame} for the visitor-stop semantics).
|
|
7107
|
+
*
|
|
7108
|
+
* @param params Optional. Omit to fetch without subscribing.
|
|
7109
|
+
* @param params.onUpdate Callback invoked with the full refreshed
|
|
7110
|
+
* template array after any spin-count
|
|
7111
|
+
* change, spin response, or acknowledge
|
|
7112
|
+
* response on this connection.
|
|
7113
|
+
* @returns Promise resolving to the template
|
|
7114
|
+
* array. Empty if no templates are
|
|
7115
|
+
* visible to the user.
|
|
7116
|
+
*
|
|
7117
|
+
* @example
|
|
7118
|
+
* ```ts
|
|
7119
|
+
* const games = await window._smartico.api.getMiniGames({
|
|
7120
|
+
* onUpdate: (refreshed) => {
|
|
7121
|
+
* console.log('[smartico] mini-game templates refreshed — re-render lobby from this array:', refreshed);
|
|
7122
|
+
* },
|
|
5793
7123
|
* });
|
|
5794
|
-
* ```
|
|
5795
7124
|
*
|
|
7125
|
+
* // Filter the lobby view per the visibility flag.
|
|
7126
|
+
* const visible = games.filter(g =>
|
|
7127
|
+
* !g.visibile_when_can_spin || (g.spin_count && g.spin_count > 0)
|
|
7128
|
+
* );
|
|
7129
|
+
*
|
|
7130
|
+
* for (const g of visible) {
|
|
7131
|
+
* console.log('[smartico] render game card', g.id, '—', g.name,
|
|
7132
|
+
* '— type:', g.saw_game_type,
|
|
7133
|
+
* '— buy-in:', g.saw_buyin_type,
|
|
7134
|
+
* '— spins available:', g.spin_count ?? 0,
|
|
7135
|
+
* '— jackpot:', g.jackpot_current, g.jackpot_symbol);
|
|
7136
|
+
* }
|
|
7137
|
+
* ```
|
|
5796
7138
|
*/
|
|
5797
7139
|
_proto.getMiniGames = function getMiniGames(_temp) {
|
|
5798
7140
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
@@ -5810,19 +7152,73 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
|
|
|
5810
7152
|
}
|
|
5811
7153
|
}
|
|
5812
7154
|
/**
|
|
5813
|
-
* Returns
|
|
5814
|
-
*
|
|
5815
|
-
*
|
|
5816
|
-
*
|
|
7155
|
+
* Returns a paginated, newest-first list of the user's past
|
|
7156
|
+
* mini-game spins — each row carries the won prize ID, the
|
|
7157
|
+
* client-side `request_id` used for the spin, and a
|
|
7158
|
+
* server-recorded `is_claimed` flag (`true` if the spin has been
|
|
7159
|
+
* acknowledged). Optionally filter to a single template via
|
|
7160
|
+
* `saw_template_id`.
|
|
7161
|
+
*
|
|
7162
|
+
* Use this to power a "My prizes" / win-history surface, or to
|
|
7163
|
+
* recover unacknowledged spins (rows with `is_claimed === false`
|
|
7164
|
+
* carry a `client_request_id` you can pass to
|
|
7165
|
+
* {@link miniGameWinAcknowledgeRequest}).
|
|
5817
7166
|
*
|
|
5818
|
-
*
|
|
5819
|
-
*
|
|
5820
|
-
*
|
|
5821
|
-
*
|
|
5822
|
-
*
|
|
5823
|
-
*
|
|
7167
|
+
* @remarks
|
|
7168
|
+
* **Pagination**
|
|
7169
|
+
* `limit` defaults to 20, `offset` defaults to 0. Sort order is
|
|
7170
|
+
* `create_date` DESC (newest first) — no client-side re-sort
|
|
7171
|
+
* required. For "load more" pagination, advance `offset` by the
|
|
7172
|
+
* page size on each subsequent call.
|
|
7173
|
+
*
|
|
7174
|
+
* The underlying protocol carries a `hasMore` boolean on the
|
|
7175
|
+
* response, but the SDK strips it from the public surface —
|
|
7176
|
+
* detect end of list when the returned array length is less than
|
|
7177
|
+
* `limit`.
|
|
7178
|
+
*
|
|
7179
|
+
* **`is_claimed` semantics**
|
|
7180
|
+
* Maps directly to the server's "acknowledge_date is non-null"
|
|
7181
|
+
* state. A spin where the auto-acknowledge fire-and-forget
|
|
7182
|
+
* succeeded shows `is_claimed: true`; a spin where the
|
|
7183
|
+
* acknowledge was lost (network drop) or where the user is on an
|
|
7184
|
+
* explicit-acknowledge flow shows `is_claimed: false` with a
|
|
7185
|
+
* usable `client_request_id`. A server-side fallback job
|
|
7186
|
+
* auto-acknowledges stale rows every ~60 seconds — so even
|
|
7187
|
+
* "lost" prizes are eventually delivered without consumer action.
|
|
7188
|
+
*
|
|
7189
|
+
* **Cache TTL**: the SDK caches the response for 30 seconds.
|
|
7190
|
+
* Cache is invalidated implicitly when a new spin or acknowledge
|
|
7191
|
+
* response lands.
|
|
7192
|
+
*
|
|
7193
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
7194
|
+
*
|
|
7195
|
+
* **UI guidance**: see [UI Guide — `getMiniGamesHistory`](../../docs/ui/minigames/UIGuide_getMiniGamesHistory.md).
|
|
5824
7196
|
*
|
|
5825
|
-
* **Visitor mode
|
|
7197
|
+
* **Visitor mode**: not supported.
|
|
7198
|
+
*
|
|
7199
|
+
* @param params Optional pagination + filter bag.
|
|
7200
|
+
* @param params.limit Page size. Defaults to 20.
|
|
7201
|
+
* @param params.offset Number of rows to skip. Defaults to 0.
|
|
7202
|
+
* @param params.saw_template_id When set, scopes the history to
|
|
7203
|
+
* a single template's spins.
|
|
7204
|
+
*
|
|
7205
|
+
* @returns Promise resolving to `TSawHistory[]` in newest-first
|
|
7206
|
+
* order. Empty when the user has no history.
|
|
7207
|
+
*
|
|
7208
|
+
* @example
|
|
7209
|
+
* ```ts
|
|
7210
|
+
* const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
|
|
7211
|
+
*
|
|
7212
|
+
* // Show unacknowledged spins with a Claim CTA.
|
|
7213
|
+
* const unacknowledged = history.filter(h => !h.is_claimed);
|
|
7214
|
+
* console.log('[smartico] surface a "Claim" CTA on these', unacknowledged.length, 'history rows:',
|
|
7215
|
+
* unacknowledged.map(h => h.client_request_id));
|
|
7216
|
+
*
|
|
7217
|
+
* // Load-more pagination — advance offset by the prior page size.
|
|
7218
|
+
* const page2 = await window._smartico.api.getMiniGamesHistory({ limit: 20, offset: 20 });
|
|
7219
|
+
* console.log('[smartico] page 2 loaded —', page2.length, 'more rows;',
|
|
7220
|
+
* page2.length < 20 ? 'end of list reached, hide "Load more"' : 'keep "Load more" visible');
|
|
7221
|
+
* ```
|
|
5826
7222
|
*/
|
|
5827
7223
|
;
|
|
5828
7224
|
_proto.getMiniGamesHistory = function getMiniGamesHistory(_ref2) {
|
|
@@ -5839,18 +7235,164 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
|
|
|
5839
7235
|
}
|
|
5840
7236
|
}
|
|
5841
7237
|
/**
|
|
5842
|
-
* Plays
|
|
5843
|
-
*
|
|
5844
|
-
*
|
|
7238
|
+
* Plays one round of a mini-game template — runs the server's
|
|
7239
|
+
* randomised prize selection, deducts the buy-in cost (if any),
|
|
7240
|
+
* and returns the won `prize_id`. After the play resolves, the SDK
|
|
7241
|
+
* automatically fires a server-side acknowledgement on a
|
|
7242
|
+
* fire-and-forget basis, marking the spin as "delivered" so the
|
|
7243
|
+
* prize takes effect.
|
|
7244
|
+
*
|
|
7245
|
+
* Works for all `SAWGameType` values EXCEPT:
|
|
7246
|
+
* - `PrizeDrop` — prizes arrive server-pushed; do NOT call
|
|
7247
|
+
* `playMiniGame` for this type.
|
|
7248
|
+
* - `MatchX` / `Quiz` — prediction submission goes through a
|
|
7249
|
+
* separate games server; `playMiniGame` is not the entry point.
|
|
5845
7250
|
*
|
|
5846
|
-
*
|
|
5847
|
-
*
|
|
5848
|
-
*
|
|
5849
|
-
*
|
|
7251
|
+
* @remarks
|
|
7252
|
+
* **Preconditions**
|
|
7253
|
+
* Read the candidate template from {@link getMiniGames} and check:
|
|
7254
|
+
* - `spin_count > 0` for spin-based templates
|
|
7255
|
+
* (`saw_buyin_type === 'spins'`).
|
|
7256
|
+
* - Sufficient balance for paid templates — points / gems /
|
|
7257
|
+
* diamonds from {@link getUserProfile} against
|
|
7258
|
+
* `buyin_cost_points` / `_gems` / `_diamonds`.
|
|
7259
|
+
* - `next_available_spin_ts` is in the past (or unset) — the
|
|
7260
|
+
* server enforces a per-period max-attempts cap.
|
|
7261
|
+
* - Template is currently in its active period
|
|
7262
|
+
* (operator-configured `activeFromDate` / `activeTillDate`).
|
|
7263
|
+
*
|
|
7264
|
+
* **Error codes** (in `err_code`, typed as {@link SAWSpinErrorCode})
|
|
7265
|
+
* - `0` (`SAW_OK`) — success; `prize_id` identifies the won prize
|
|
7266
|
+
* in `template.prizes`.
|
|
7267
|
+
* - `40001` (`SAW_NO_SPINS`) — user has no spin attempts for a
|
|
7268
|
+
* spin-based template.
|
|
7269
|
+
* - `40002` (`SAW_PRIZE_POOL_EMPTY`) — all prize slots in the
|
|
7270
|
+
* template are depleted.
|
|
7271
|
+
* - `40003` (`SAW_NOT_ENOUGH_POINTS`) — insufficient points for a
|
|
7272
|
+
* points-cost template.
|
|
7273
|
+
* - `40004` (`SAW_FAILED_MAX_SPINS_REACHED`) — per-period
|
|
7274
|
+
* max-attempts cap reached. The server's
|
|
7275
|
+
* `first_spin_in_period` value (exposed in
|
|
7276
|
+
* {@link TMiniGamePlayBatchResult}; not surfaced in the single
|
|
7277
|
+
* `TMiniGamePlayResult`) marks the period start.
|
|
7278
|
+
* - `40007` (`SAW_TEMPLATE_NOT_ACTIVE`) — template outside its
|
|
7279
|
+
* active time window.
|
|
7280
|
+
* - `40009` (`SAW_NOT_IN_SEGMENT`) — user fails the template's
|
|
7281
|
+
* visibility segment check, OR (for lootbox variants) the day's
|
|
7282
|
+
* prize pool is empty.
|
|
7283
|
+
* - `40011` (`SAW_NO_BALANCE_GEMS`) — insufficient gems.
|
|
7284
|
+
* - `40012` (`SAW_NO_BALANCE_DIAMONDS`) — insufficient diamonds.
|
|
7285
|
+
* - `-40001` (`SAW_VISITOR_STOP_SPIN_REQUEST`) — visitor session
|
|
7286
|
+
* tried to play a non-visitor-mode template. The default UI
|
|
7287
|
+
* silently stops the game; no prize awarded.
|
|
7288
|
+
* - other non-zero — generic server error. Surface `err_message`.
|
|
7289
|
+
*
|
|
7290
|
+
* **Prize handling**
|
|
7291
|
+
* On `err_code === 0`, `prize_id` matches an entry in
|
|
7292
|
+
* `template.prizes`. Look up the prize's `prize_type`
|
|
7293
|
+
* ({@link MiniGamePrizeTypeName}) to decide UI treatment:
|
|
7294
|
+
* - `'no-prize'` — the user spun but won nothing (an operator-
|
|
7295
|
+
* configured "loss" slot). Buy-in is still deducted.
|
|
7296
|
+
* - `'points'` / `'gems-and-diamonds'` / `'spin'` — value
|
|
7297
|
+
* credited to the user's profile / spin balance; visible on
|
|
7298
|
+
* the next refresh.
|
|
7299
|
+
* - `'bonus'` — surfaces via {@link getBonuses}.
|
|
7300
|
+
* - `'jackpot'` — drains the template's `jackpot_current` to the
|
|
7301
|
+
* user; resets the accumulator.
|
|
7302
|
+
* - `'raffle-ticket'` — adds tickets to the relevant raffle.
|
|
7303
|
+
* - `'mission'` / `'change-level'` — visible via the
|
|
7304
|
+
* corresponding domain methods.
|
|
7305
|
+
* - `'manual'` — operator delivers offline.
|
|
7306
|
+
*
|
|
7307
|
+
* **Auto-acknowledge**
|
|
7308
|
+
* The SDK calls the server's acknowledge endpoint immediately
|
|
7309
|
+
* after the spin response, on a fire-and-forget basis (not
|
|
7310
|
+
* awaited). This marks the spin as "delivered" so prize effects
|
|
7311
|
+
* take hold. If the auto-acknowledge fails (network drop), the
|
|
7312
|
+
* spin appears as `is_claimed: false` in
|
|
7313
|
+
* {@link getMiniGamesHistory}; the consumer can recover it by
|
|
7314
|
+
* passing the `client_request_id` to
|
|
7315
|
+
* {@link miniGameWinAcknowledgeRequest}. A server-side fallback
|
|
7316
|
+
* job auto-acknowledges stale spins every ~60 seconds, so prizes
|
|
7317
|
+
* are eventually delivered even without consumer action.
|
|
7318
|
+
*
|
|
7319
|
+
* **Idempotency**: NOT idempotent. A double-click sends two
|
|
7320
|
+
* spins and deducts the buy-in twice. The SDK does NOT guard
|
|
7321
|
+
* against rapid clicks at the public API level — guard the call
|
|
7322
|
+
* site with an in-flight flag. The server enforces a per-user
|
|
7323
|
+
* per-template lock that serialises concurrent requests, so two
|
|
7324
|
+
* simultaneous calls won't be processed in parallel, but they
|
|
7325
|
+
* will both be processed sequentially (i.e. both deduct).
|
|
7326
|
+
*
|
|
7327
|
+
* **Refresh after success (and after failure)**
|
|
7328
|
+
* The SDK automatically refreshes the templates cache on every
|
|
7329
|
+
* spin response and fires any `onUpdate` callback registered via
|
|
7330
|
+
* {@link getMiniGames} or this method. After `err_code === 0`, the
|
|
7331
|
+
* affected template's `spin_count` / `jackpot_current` /
|
|
7332
|
+
* `next_available_spin_ts` reflect the new state on the
|
|
7333
|
+
* refreshed array.
|
|
7334
|
+
*
|
|
7335
|
+
* **Side effects** (on `err_code === 0`)
|
|
7336
|
+
* - Buy-in deducted from the user's balance (points / gems /
|
|
7337
|
+
* diamonds / spin tickets — depending on `saw_buyin_type`).
|
|
7338
|
+
* Balance updates flow via the user-properties channel
|
|
7339
|
+
* (subscribe to {@link getUserProfile} `props_change` to
|
|
7340
|
+
* observe).
|
|
7341
|
+
* - Prize value credited per the prize's type (see "Prize
|
|
7342
|
+
* handling" above).
|
|
7343
|
+
* - A `minigame_attempt` analytics event fires server-side with
|
|
7344
|
+
* the result status.
|
|
7345
|
+
*
|
|
7346
|
+
* **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
|
|
7347
|
+
*
|
|
7348
|
+
* **Visitor mode**: not supported. Visitor sessions trying to
|
|
7349
|
+
* spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
|
|
7350
|
+
*
|
|
7351
|
+
* @param template_id The mini-game template ID (from
|
|
7352
|
+
* `TMiniGameTemplate.id`).
|
|
7353
|
+
* @param params Optional. Pass an `onUpdate` callback to
|
|
7354
|
+
* subscribe to subsequent template refreshes.
|
|
7355
|
+
* @returns `{ err_code, err_message, prize_id }` — success when
|
|
7356
|
+
* `err_code === 0`. `prize_id` is always populated; look
|
|
7357
|
+
* it up in `template.prizes` to interpret the prize.
|
|
7358
|
+
*
|
|
7359
|
+
* @example
|
|
7360
|
+
* ```ts
|
|
7361
|
+
* const games = await window._smartico.api.getMiniGames({
|
|
7362
|
+
* onUpdate: (refreshed) => console.log('[smartico] templates refreshed — re-render lobby', refreshed),
|
|
5850
7363
|
* });
|
|
5851
|
-
*
|
|
7364
|
+
* const game = games.find(g => g.id === templateId);
|
|
5852
7365
|
*
|
|
5853
|
-
*
|
|
7366
|
+
* if (!game) {
|
|
7367
|
+
* console.log('[smartico] template not in current list — refresh getMiniGames');
|
|
7368
|
+
* return;
|
|
7369
|
+
* }
|
|
7370
|
+
* if (game.saw_buyin_type === 'spins' && (game.spin_count ?? 0) === 0) {
|
|
7371
|
+
* console.log('[smartico] no spins available — disable Play button, show "No spins" message');
|
|
7372
|
+
* return;
|
|
7373
|
+
* }
|
|
7374
|
+
*
|
|
7375
|
+
* console.log('[smartico] play starting — set in-flight flag, start game animation (wheel spin / scratch / lootbox open / etc.)');
|
|
7376
|
+
* const r = await window._smartico.api.playMiniGame(game.id);
|
|
7377
|
+
* console.log('[smartico] play response received');
|
|
7378
|
+
*
|
|
7379
|
+
* if (r.err_code === 0) {
|
|
7380
|
+
* const prize = game.prizes.find(p => p.id === r.prize_id);
|
|
7381
|
+
* if (prize?.prize_type === 'no-prize') {
|
|
7382
|
+
* console.log('[smartico] user lost — animate to the no-prize slot and show "Better luck next time" modal');
|
|
7383
|
+
* } else {
|
|
7384
|
+
* console.log('[smartico] user won — animate to prize', prize?.name,
|
|
7385
|
+
* '— show acknowledge modal per template.acknowledge_type;',
|
|
7386
|
+
* 'getMiniGames onUpdate fires shortly with refreshed spin_count / jackpot');
|
|
7387
|
+
* }
|
|
7388
|
+
* } else if (r.err_code === 40004) {
|
|
7389
|
+
* console.error('[smartico] max spins reached — show countdown to next available spin (use playMiniGameBatch for first_spin_in_period if needed)');
|
|
7390
|
+
* } else if (r.err_code === -40001) {
|
|
7391
|
+
* console.log('[smartico] visitor stopped — silently end the game, no prize modal');
|
|
7392
|
+
* } else {
|
|
7393
|
+
* console.error('[smartico] play failed — show generic error with this message:', r.err_message);
|
|
7394
|
+
* }
|
|
7395
|
+
* ```
|
|
5854
7396
|
*/
|
|
5855
7397
|
;
|
|
5856
7398
|
_proto.playMiniGame = function playMiniGame(template_id, _temp2) {
|
|
@@ -5875,12 +7417,63 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
|
|
|
5875
7417
|
}
|
|
5876
7418
|
}
|
|
5877
7419
|
/**
|
|
5878
|
-
*
|
|
5879
|
-
*
|
|
5880
|
-
*
|
|
5881
|
-
*
|
|
5882
|
-
*
|
|
5883
|
-
*
|
|
7420
|
+
* Manually acknowledges a mini-game spin — marks the spin as
|
|
7421
|
+
* "delivered" so the prize takes effect server-side. Most consumers
|
|
7422
|
+
* do NOT need to call this method directly; {@link playMiniGame}
|
|
7423
|
+
* and {@link playMiniGameBatch} auto-acknowledge on success. Use
|
|
7424
|
+
* this only for recovery scenarios.
|
|
7425
|
+
*
|
|
7426
|
+
* @remarks
|
|
7427
|
+
* **When to call**
|
|
7428
|
+
* - **Lost auto-acknowledge** — when the WebSocket dropped between
|
|
7429
|
+
* the spin response and the auto-acknowledge fire-and-forget,
|
|
7430
|
+
* the spin shows `is_claimed: false` in
|
|
7431
|
+
* {@link getMiniGamesHistory}. Pass that row's
|
|
7432
|
+
* `client_request_id` here to deliver the prize.
|
|
7433
|
+
* - **Explicit-acknowledge UI** — for templates configured with
|
|
7434
|
+
* the `ExplicitAcknowledge` acknowledge type (operator
|
|
7435
|
+
* decision), the consumer's UI shows a "Claim" CTA after the
|
|
7436
|
+
* prize animation. Click handler calls this method with the
|
|
7437
|
+
* spin's `client_request_id` rather than auto-acknowledging.
|
|
7438
|
+
*
|
|
7439
|
+
* **No-op on already-acknowledged spins**
|
|
7440
|
+
* The server's acknowledge SQL matches on `acknowledge_date IS
|
|
7441
|
+
* NULL` — a duplicate call returns successfully with no effect.
|
|
7442
|
+
*
|
|
7443
|
+
* **Server-side fallback**
|
|
7444
|
+
* Even without ever calling this method, a server-side job
|
|
7445
|
+
* auto-acknowledges stale spins every ~60 seconds — so prizes are
|
|
7446
|
+
* eventually delivered. The `is_claimed` flag flips on the next
|
|
7447
|
+
* `getMiniGamesHistory` call after the job runs.
|
|
7448
|
+
*
|
|
7449
|
+
* **Idempotency**: safe. Repeated calls have no effect after the
|
|
7450
|
+
* first.
|
|
7451
|
+
*
|
|
7452
|
+
* **Side effects** (on first successful call for an unacknowledged
|
|
7453
|
+
* spin)
|
|
7454
|
+
* - Prize value credited per the prize's type (see
|
|
7455
|
+
* {@link playMiniGame} "Prize handling").
|
|
7456
|
+
* - The spin's `is_claimed` flag flips to `true` on the next
|
|
7457
|
+
* {@link getMiniGamesHistory} call.
|
|
7458
|
+
*
|
|
7459
|
+
* **Visitor mode**: not supported.
|
|
7460
|
+
*
|
|
7461
|
+
* @param request_id The `client_request_id` from a `TSawHistory`
|
|
7462
|
+
* row returned by {@link getMiniGamesHistory}.
|
|
7463
|
+
*
|
|
7464
|
+
* @example
|
|
7465
|
+
* ```ts
|
|
7466
|
+
* const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
|
|
7467
|
+
* const unacknowledged = history.filter(h => !h.is_claimed);
|
|
7468
|
+
*
|
|
7469
|
+
* for (const row of unacknowledged) {
|
|
7470
|
+
* console.log('[smartico] re-acknowledging stale spin', row.client_request_id);
|
|
7471
|
+
* await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
|
|
7472
|
+
* }
|
|
7473
|
+
*
|
|
7474
|
+
* // Re-fetch history to see the updated is_claimed flags.
|
|
7475
|
+
* const fresh = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
|
|
7476
|
+
* console.log('[smartico] history after recovery —', fresh.filter(h => !h.is_claimed).length, 'still unacknowledged');
|
|
5884
7477
|
* ```
|
|
5885
7478
|
*/
|
|
5886
7479
|
;
|
|
@@ -5893,17 +7486,108 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
|
|
|
5893
7486
|
}
|
|
5894
7487
|
}
|
|
5895
7488
|
/**
|
|
5896
|
-
* Plays
|
|
5897
|
-
*
|
|
5898
|
-
*
|
|
7489
|
+
* Plays a mini-game template `spin_count` times in one round-trip.
|
|
7490
|
+
* Returns an array of per-spin results — each independent, each
|
|
7491
|
+
* with its own error code. Like {@link playMiniGame}, the SDK
|
|
7492
|
+
* auto-acknowledges every result on a fire-and-forget basis.
|
|
5899
7493
|
*
|
|
5900
|
-
*
|
|
5901
|
-
*
|
|
5902
|
-
*
|
|
5903
|
-
*
|
|
5904
|
-
*
|
|
7494
|
+
* Use this when a UI offers "spin N times" affordances
|
|
7495
|
+
* (multi-spin buttons, lootbox open-N flows). The server processes
|
|
7496
|
+
* each spin independently — there is no atomicity / rollback if
|
|
7497
|
+
* one fails.
|
|
7498
|
+
*
|
|
7499
|
+
* @remarks
|
|
7500
|
+
* **Result shape note** — `TMiniGamePlayBatchResult` uses
|
|
7501
|
+
* `errCode` / `errMessage` (camelCase) — DIFFERENT from
|
|
7502
|
+
* {@link TMiniGamePlayResult} which uses `err_code` / `err_message`
|
|
7503
|
+
* (snake_case). Branch on the camelCase keys when reading batch
|
|
7504
|
+
* results.
|
|
7505
|
+
*
|
|
7506
|
+
* **Per-spin independence**
|
|
7507
|
+
* The server iterates the requested spins and calls the prize
|
|
7508
|
+
* engine once per entry. If spin #2 fails with `SAW_NO_SPINS`,
|
|
7509
|
+
* spin #3 is still attempted — the server does NOT stop on first
|
|
7510
|
+
* error and does NOT roll back successful spins. Each
|
|
7511
|
+
* `results[i].errCode` is independent.
|
|
7512
|
+
*
|
|
7513
|
+
* Practical implication: if the user has 3 spins available and
|
|
7514
|
+
* requests 5, expect results 0-2 with `errCode === 0` and results
|
|
7515
|
+
* 3-4 with `errCode === SAW_NO_SPINS`.
|
|
7516
|
+
*
|
|
7517
|
+
* **Error codes**
|
|
7518
|
+
* Per-result `errCode` is from {@link SAWSpinErrorCode}. See
|
|
7519
|
+
* {@link playMiniGame} for the full table; the same codes apply
|
|
7520
|
+
* per spin.
|
|
7521
|
+
*
|
|
7522
|
+
* **`first_spin_in_period` field**
|
|
7523
|
+
* Populated on results where `errCode === SAW_FAILED_MAX_SPINS_REACHED`
|
|
7524
|
+
* (40004). The value is the epoch-ms timestamp of the user's
|
|
7525
|
+
* first spin in the current cooldown period. Compute the
|
|
7526
|
+
* countdown as:
|
|
7527
|
+
* `template.max_spins_period_ms - (Date.now() - first_spin_in_period)`.
|
|
7528
|
+
*
|
|
7529
|
+
* **`jackpot_amount` field**
|
|
7530
|
+
* Populated on results where the won prize is a jackpot
|
|
7531
|
+
* (`prize_type === 'jackpot'`). The amount the user just claimed
|
|
7532
|
+
* from the template's jackpot accumulator.
|
|
7533
|
+
*
|
|
7534
|
+
* **Auto-acknowledge**
|
|
7535
|
+
* The SDK fires a batch-acknowledge for all `request_id`s after
|
|
7536
|
+
* the batch response lands — fire-and-forget. Same recovery
|
|
7537
|
+
* semantics as {@link playMiniGame}: lost acknowledgements
|
|
7538
|
+
* become recoverable via {@link miniGameWinAcknowledgeRequest}
|
|
7539
|
+
* per row, and a server-side fallback job auto-acknowledges
|
|
7540
|
+
* stale spins every ~60 seconds.
|
|
7541
|
+
*
|
|
7542
|
+
* **Idempotency**: NOT idempotent. A double-click sends two
|
|
7543
|
+
* batches. Guard the call site with an in-flight flag.
|
|
7544
|
+
*
|
|
7545
|
+
* **Refresh after success (and after failure)**
|
|
7546
|
+
* Same as {@link playMiniGame} — the templates cache refreshes
|
|
7547
|
+
* and any `onUpdate` callback registered via {@link getMiniGames}
|
|
7548
|
+
* fires with the updated `spin_count` / `jackpot_current`.
|
|
7549
|
+
*
|
|
7550
|
+
* **Side effects** (per-spin, on `errCode === 0`)
|
|
7551
|
+
* Same as {@link playMiniGame} — buy-in deducted, prize value
|
|
7552
|
+
* credited per prize type.
|
|
7553
|
+
*
|
|
7554
|
+
* **UI guidance**: see [UI Guide — `playMiniGameBatch`](../../docs/ui/minigames/UIGuide_playMiniGameBatch.md).
|
|
7555
|
+
*
|
|
7556
|
+
* **Visitor mode**: not supported.
|
|
7557
|
+
*
|
|
7558
|
+
* @param template_id The mini-game template ID.
|
|
7559
|
+
* @param spin_count Number of spins to play. The server attempts
|
|
7560
|
+
* all `spin_count` spins — partial successes
|
|
7561
|
+
* are normal when the user runs out of
|
|
7562
|
+
* balance / spins mid-batch.
|
|
7563
|
+
* @param params Optional. Pass an `onUpdate` callback to
|
|
7564
|
+
* subscribe to subsequent template refreshes.
|
|
7565
|
+
* @returns `TMiniGamePlayBatchResult[]` — one entry per requested
|
|
7566
|
+
* spin, in request order. Note the camelCase `errCode` /
|
|
7567
|
+
* `errMessage` keys (see "Result shape note" above).
|
|
7568
|
+
*
|
|
7569
|
+
* @example
|
|
7570
|
+
* ```ts
|
|
7571
|
+
* const game = (await window._smartico.api.getMiniGames()).find(g => g.id === templateId);
|
|
7572
|
+
* if (!game) return;
|
|
7573
|
+
*
|
|
7574
|
+
* console.log('[smartico] batch play starting — set in-flight flag, animate the chosen N spins sequentially in UI');
|
|
7575
|
+
* const results = await window._smartico.api.playMiniGameBatch(game.id, 5);
|
|
7576
|
+
* console.log('[smartico] batch response received — clear in-flight flag');
|
|
7577
|
+
*
|
|
7578
|
+
* for (const [i, r] of results.entries()) {
|
|
7579
|
+
* if (r.errCode === 0) {
|
|
7580
|
+
* const prize = game.prizes.find(p => p.id === r.saw_prize_id);
|
|
7581
|
+
* console.log('[smartico] spin', i, 'won:', prize?.name,
|
|
7582
|
+
* r.jackpot_amount ? '(jackpot: ' + r.jackpot_amount + ')' : '');
|
|
7583
|
+
* } else if (r.errCode === 40004) {
|
|
7584
|
+
* const msTillNext = game.max_spins_period_ms! - (Date.now() - (r.first_spin_in_period ?? 0));
|
|
7585
|
+
* console.log('[smartico] spin', i, 'capped — ' + Math.ceil(msTillNext / 1000) + ' s until next allowed');
|
|
7586
|
+
* } else {
|
|
7587
|
+
* console.error('[smartico] spin', i, 'failed —', r.errCode, r.errMessage);
|
|
7588
|
+
* }
|
|
7589
|
+
* }
|
|
5905
7590
|
* ```
|
|
5906
|
-
* **Visitor mode: not supported**
|
|
5907
7591
|
*/
|
|
5908
7592
|
;
|
|
5909
7593
|
_proto.playMiniGameBatch = function playMiniGameBatch(template_id, spin_count, _temp3) {
|
|
@@ -5971,19 +7655,63 @@ var WSAPIAvatars = /*#__PURE__*/function (_WSAPIMiniGames) {
|
|
|
5971
7655
|
_inheritsLoose(WSAPIAvatars, _WSAPIMiniGames);
|
|
5972
7656
|
var _proto = WSAPIAvatars.prototype;
|
|
5973
7657
|
/**
|
|
5974
|
-
* Returns the
|
|
5975
|
-
*
|
|
5976
|
-
*
|
|
5977
|
-
* The result is cached for 30 seconds.
|
|
7658
|
+
* Returns the avatar catalog available to the current user — every pre-defined
|
|
7659
|
+
* avatar configured for the label, with per-user unlock flags (`is_given`, `is_in_use`)
|
|
7660
|
+
* applied server-side.
|
|
5978
7661
|
*
|
|
5979
|
-
*
|
|
5980
|
-
*
|
|
5981
|
-
*
|
|
5982
|
-
* console.log(result);
|
|
5983
|
-
* });
|
|
5984
|
-
* ```
|
|
7662
|
+
* The returned `avatar_url` is the absolute CDN URL (the SDK prefixes relative paths
|
|
7663
|
+
* with the configured avatar domain). AI-customized variants are NOT returned here —
|
|
7664
|
+
* those live in {@link getAvatarsCustomized}.
|
|
5985
7665
|
*
|
|
5986
|
-
*
|
|
7666
|
+
* @remarks
|
|
7667
|
+
* **Preconditions**
|
|
7668
|
+
* - User must be authenticated. Visitor mode is not supported.
|
|
7669
|
+
* - No other prerequisite calls.
|
|
7670
|
+
*
|
|
7671
|
+
* **Visibility filter** (consumer-applied)
|
|
7672
|
+
* Avatars with `hide_until_achieved === true && is_given === false` should be filtered
|
|
7673
|
+
* out of the grid — they represent surprise unlocks that should remain hidden until
|
|
7674
|
+
* the user earns them. The default Smartico UI drops these before rendering.
|
|
7675
|
+
*
|
|
7676
|
+
* **Lock state** (consumer-applied)
|
|
7677
|
+
* Lock condition: `!is_given && avatar_source_type_id !== 0`. Free avatars
|
|
7678
|
+
* (`avatar_source_type_id === 0`) are always selectable; non-free avatars are locked
|
|
7679
|
+
* until `is_given` flips to true (operator grants via campaign, mission reward, store
|
|
7680
|
+
* purchase, etc.).
|
|
7681
|
+
*
|
|
7682
|
+
* **Sort order**
|
|
7683
|
+
* Server does NOT pre-sort. Caller must sort by `priority` ascending (lower = first).
|
|
7684
|
+
*
|
|
7685
|
+
* **Refresh**
|
|
7686
|
+
* - The SDK caches results for 30 seconds.
|
|
7687
|
+
* - {@link setAvatar} clears this cache on completion; the next call re-fetches.
|
|
7688
|
+
* - No push subscription — there is no `onUpdate` callback for avatar methods.
|
|
7689
|
+
* - When `is_given` flips server-side (e.g. the user earns a new avatar), the change
|
|
7690
|
+
* surfaces only on the next call after the 30-second cache window expires.
|
|
7691
|
+
*
|
|
7692
|
+
* **Visitor mode**: not supported.
|
|
7693
|
+
*
|
|
7694
|
+
* **UI guidance**: see [UI Guide — `getAvatarsList`](../../docs/ui/avatars/UIGuide_getAvatarsList.md).
|
|
7695
|
+
*
|
|
7696
|
+
* @returns Array of {@link TAvatarDefinition} — empty array if the feature is disabled
|
|
7697
|
+
* on the label.
|
|
7698
|
+
*
|
|
7699
|
+
* @example
|
|
7700
|
+
* ```ts
|
|
7701
|
+
* const avatars = await window._smartico.api.getAvatarsList();
|
|
7702
|
+
*
|
|
7703
|
+
* // Apply the standard visibility filter and sort.
|
|
7704
|
+
* const visible = avatars
|
|
7705
|
+
* .filter((a) => !a.hide_until_achieved || a.is_given)
|
|
7706
|
+
* .sort((a, b) => a.priority - b.priority);
|
|
7707
|
+
*
|
|
7708
|
+
* console.log('[smartico] visible avatars:', visible.length, '— render as a grid');
|
|
7709
|
+
*
|
|
7710
|
+
* const active = visible.find((a) => a.is_in_use);
|
|
7711
|
+
* if (active) {
|
|
7712
|
+
* console.log('[smartico] currently in use — overlay a checkmark on this card:', active.avatar_real_id);
|
|
7713
|
+
* }
|
|
7714
|
+
* ```
|
|
5987
7715
|
*/
|
|
5988
7716
|
_proto.getAvatarsList = function getAvatarsList() {
|
|
5989
7717
|
try {
|
|
@@ -5996,18 +7724,70 @@ var WSAPIAvatars = /*#__PURE__*/function (_WSAPIMiniGames) {
|
|
|
5996
7724
|
}
|
|
5997
7725
|
}
|
|
5998
7726
|
/**
|
|
5999
|
-
* Returns the
|
|
6000
|
-
* Each entry represents a previously generated AI customization for a specific base avatar.
|
|
6001
|
-
* The result is cached for 30 seconds.
|
|
7727
|
+
* Returns the user's previously generated AI-customized avatar variants.
|
|
6002
7728
|
*
|
|
6003
|
-
*
|
|
6004
|
-
*
|
|
6005
|
-
*
|
|
6006
|
-
*
|
|
6007
|
-
* });
|
|
6008
|
-
* ```
|
|
7729
|
+
* Each entry is one AI-generated image derived from a base avatar in the catalog
|
|
7730
|
+
* (the base is identified by `avatar_real_id` and was originally a
|
|
7731
|
+
* {@link TAvatarDefinition} from {@link getAvatarsList}). These variants are stored
|
|
7732
|
+
* server-side under the user record and persist across sessions.
|
|
6009
7733
|
*
|
|
6010
|
-
*
|
|
7734
|
+
* @remarks
|
|
7735
|
+
* **Preconditions**
|
|
7736
|
+
* - User must be authenticated. Visitor mode is not supported.
|
|
7737
|
+
* - Has meaning only after at least one successful AI customization run (see below).
|
|
7738
|
+
* New users get an empty array.
|
|
7739
|
+
*
|
|
7740
|
+
* **Where customized avatars come from**
|
|
7741
|
+
* AI customization is **not** a WebSocket method on this SDK. It is a separate HTTP
|
|
7742
|
+
* POST to the operator-configured `avatar-customize` endpoint that takes a base avatar
|
|
7743
|
+
* plus a style prompt from {@link getAvatarPrompts} and returns a generated CDN URL.
|
|
7744
|
+
* Once that POST resolves successfully, the new variant is persisted and surfaces in
|
|
7745
|
+
* the next `getAvatarsCustomized()` call. The variant URL can then be passed to
|
|
7746
|
+
* {@link setAvatar} to activate it.
|
|
7747
|
+
*
|
|
7748
|
+
* **Relation to `getAvatarsList`**
|
|
7749
|
+
* AI variants do NOT appear in {@link getAvatarsList}. Catalog and variants are two
|
|
7750
|
+
* separate collections — combine them client-side if the UI needs a unified view per
|
|
7751
|
+
* base avatar.
|
|
7752
|
+
*
|
|
7753
|
+
* **Sort order**
|
|
7754
|
+
* Server does NOT pre-sort. Caller typically sorts by `dt_created` descending to show
|
|
7755
|
+
* the newest variant first.
|
|
7756
|
+
*
|
|
7757
|
+
* **Refresh**
|
|
7758
|
+
* - The SDK caches results for 30 seconds.
|
|
7759
|
+
* - {@link setAvatar} clears this cache on completion.
|
|
7760
|
+
* - After a successful AI customization POST, the consumer should re-call to surface
|
|
7761
|
+
* the new variant — the customization endpoint is outside the SDK so the SDK cannot
|
|
7762
|
+
* auto-invalidate.
|
|
7763
|
+
* - No push subscription.
|
|
7764
|
+
*
|
|
7765
|
+
* **Visitor mode**: not supported.
|
|
7766
|
+
*
|
|
7767
|
+
* **UI guidance**: see [UI Guide — `getAvatarsCustomized`](../../docs/ui/avatars/UIGuide_getAvatarsCustomized.md).
|
|
7768
|
+
*
|
|
7769
|
+
* @returns Array of {@link TAvatarCustomized} — empty if the user has never run AI
|
|
7770
|
+
* customization, or if the feature is disabled on the label.
|
|
7771
|
+
*
|
|
7772
|
+
* @example
|
|
7773
|
+
* ```ts
|
|
7774
|
+
* const variants = await window._smartico.api.getAvatarsCustomized();
|
|
7775
|
+
*
|
|
7776
|
+
* // Group by the base avatar so the UI can show "this base has 3 AI variants".
|
|
7777
|
+
* const byBase = new Map<number, typeof variants>();
|
|
7778
|
+
* for (const v of variants) {
|
|
7779
|
+
* const list = byBase.get(v.avatar_real_id) ?? [];
|
|
7780
|
+
* list.push(v);
|
|
7781
|
+
* byBase.set(v.avatar_real_id, list);
|
|
7782
|
+
* }
|
|
7783
|
+
*
|
|
7784
|
+
* // Newest-first within each base.
|
|
7785
|
+
* for (const list of byBase.values()) {
|
|
7786
|
+
* list.sort((a, b) => b.dt_created.localeCompare(a.dt_created));
|
|
7787
|
+
* }
|
|
7788
|
+
*
|
|
7789
|
+
* console.log('[smartico] AI variants by base avatar — render as a carousel under each base');
|
|
7790
|
+
* ```
|
|
6011
7791
|
*/
|
|
6012
7792
|
;
|
|
6013
7793
|
_proto.getAvatarsCustomized = function getAvatarsCustomized() {
|
|
@@ -6021,18 +7801,53 @@ var WSAPIAvatars = /*#__PURE__*/function (_WSAPIMiniGames) {
|
|
|
6021
7801
|
}
|
|
6022
7802
|
}
|
|
6023
7803
|
/**
|
|
6024
|
-
* Returns the
|
|
6025
|
-
* Each prompt represents a visual style that can be applied to a base avatar.
|
|
6026
|
-
* The result is cached for 30 seconds.
|
|
7804
|
+
* Returns the catalog of AI style prompts available for avatar customization.
|
|
6027
7805
|
*
|
|
6028
|
-
*
|
|
6029
|
-
*
|
|
6030
|
-
*
|
|
6031
|
-
*
|
|
6032
|
-
* });
|
|
6033
|
-
* ```
|
|
7806
|
+
* Each entry is a "style" the user can apply to a base avatar (e.g. "Cartoon",
|
|
7807
|
+
* "Watercolor", "Cyberpunk"). Prompts carry a cost expressed in points, gems, or
|
|
7808
|
+
* diamonds — applying a prompt deducts the cost server-side as part of the AI
|
|
7809
|
+
* generation request.
|
|
6034
7810
|
*
|
|
6035
|
-
*
|
|
7811
|
+
* @remarks
|
|
7812
|
+
* **Preconditions**
|
|
7813
|
+
* - User must be authenticated. Visitor mode is not supported.
|
|
7814
|
+
* - No other prerequisite calls. The customization UI typically calls this on demand
|
|
7815
|
+
* when the user opens the style picker, not on app boot.
|
|
7816
|
+
*
|
|
7817
|
+
* **Cost handling**
|
|
7818
|
+
* Each prompt declares `cost_currency_type_id` (0 = points, 1 = gems, 2 = diamonds)
|
|
7819
|
+
* and `cost_value` (amount). The deduction happens server-side inside the
|
|
7820
|
+
* `avatar-customize` HTTP POST (the AI generation request, which is NOT part of this
|
|
7821
|
+
* SDK). The client should compare `cost_value` against the live balance from
|
|
7822
|
+
* {@link getUserProfile} to disable prompts the user cannot afford, but the server is
|
|
7823
|
+
* the source of truth and will reject under-funded requests authoritatively.
|
|
7824
|
+
*
|
|
7825
|
+
* **Refresh**
|
|
7826
|
+
* - The SDK caches results for 30 seconds.
|
|
7827
|
+
* - Not invalidated by {@link setAvatar} (prompts are catalog metadata, independent
|
|
7828
|
+
* of the user's active avatar).
|
|
7829
|
+
* - No push subscription.
|
|
7830
|
+
*
|
|
7831
|
+
* **Visitor mode**: not supported.
|
|
7832
|
+
*
|
|
7833
|
+
* **UI guidance**: see [UI Guide — `getAvatarPrompts`](../../docs/ui/avatars/UIGuide_getAvatarPrompts.md).
|
|
7834
|
+
*
|
|
7835
|
+
* @returns Array of {@link TAvatarPrompt} — empty if the AI customization feature is
|
|
7836
|
+
* disabled on the label.
|
|
7837
|
+
*
|
|
7838
|
+
* @example
|
|
7839
|
+
* ```ts
|
|
7840
|
+
* const [prompts, profile] = await Promise.all([
|
|
7841
|
+
* window._smartico.api.getAvatarPrompts(),
|
|
7842
|
+
* window._smartico.api.getUserProfile(),
|
|
7843
|
+
* ]);
|
|
7844
|
+
*
|
|
7845
|
+
* for (const p of prompts) {
|
|
7846
|
+
* // The consumer reads the matching balance from profile based on
|
|
7847
|
+
* // p.cost_currency_type_id (0=points, 1=gems, 2=diamonds).
|
|
7848
|
+
* console.log('[smartico] prompt', p.name, '— cost', p.cost_value, 'currency_type', p.cost_currency_type_id);
|
|
7849
|
+
* }
|
|
7850
|
+
* ```
|
|
6036
7851
|
*/
|
|
6037
7852
|
;
|
|
6038
7853
|
_proto.getAvatarPrompts = function getAvatarPrompts() {
|
|
@@ -6046,27 +7861,114 @@ var WSAPIAvatars = /*#__PURE__*/function (_WSAPIMiniGames) {
|
|
|
6046
7861
|
}
|
|
6047
7862
|
}
|
|
6048
7863
|
/**
|
|
6049
|
-
*
|
|
6050
|
-
*
|
|
6051
|
-
*
|
|
6052
|
-
* After a successful call, the avatar list cache is cleared so the next `getAvatarsList()` call reflects `is_in_use`.
|
|
7864
|
+
* Activates the specified avatar for the current user. The chosen image becomes the
|
|
7865
|
+
* profile avatar — any subsequent {@link getUserProfile} call will reflect the new
|
|
7866
|
+
* `avatar_url`.
|
|
6053
7867
|
*
|
|
6054
|
-
*
|
|
6055
|
-
*
|
|
6056
|
-
*
|
|
6057
|
-
*
|
|
6058
|
-
*
|
|
6059
|
-
*
|
|
6060
|
-
*
|
|
6061
|
-
*
|
|
6062
|
-
*
|
|
6063
|
-
*
|
|
6064
|
-
*
|
|
6065
|
-
*
|
|
7868
|
+
* Pass `avatar_url` (a {@link TAvatarDefinition.url} from the catalog or a
|
|
7869
|
+
* {@link TAvatarCustomized.url} from the AI-variant list) plus `avatar_real_id` of the
|
|
7870
|
+
* base avatar. The server validates ownership before applying — locked avatars are
|
|
7871
|
+
* rejected.
|
|
7872
|
+
*
|
|
7873
|
+
* @remarks
|
|
7874
|
+
* **Preconditions**
|
|
7875
|
+
* - User must be authenticated. Visitor mode is not supported.
|
|
7876
|
+
* - `avatar_url` must be non-empty and `avatar_real_id` must be truthy — the SDK
|
|
7877
|
+
* throws synchronously otherwise (the request never reaches the server).
|
|
7878
|
+
* - The avatar must exist in the catalog from {@link getAvatarsList} (or be an AI
|
|
7879
|
+
* variant of a base avatar the user already owns). Free avatars
|
|
7880
|
+
* (`avatar_source_type_id === 0`) and the user's currently active avatar bypass the
|
|
7881
|
+
* ownership check; all others require `is_given === true`.
|
|
7882
|
+
*
|
|
7883
|
+
* **Error codes** (in `err_code`)
|
|
7884
|
+
* - `0` — success; cache is cleared and the profile avatar updates immediately.
|
|
7885
|
+
* - `1` — avatar not found in the catalog. The `avatar_real_id` doesn't exist for
|
|
7886
|
+
* this label.
|
|
7887
|
+
* - `2` — avatar inactive (deactivated by the operator).
|
|
7888
|
+
* - `3` — outside the avatar's active time window
|
|
7889
|
+
* (`active_from_date` / `active_till_date`).
|
|
7890
|
+
* - `4` — user does not own this avatar (it isn't in their `is_given` set and isn't
|
|
7891
|
+
* a free / default avatar).
|
|
7892
|
+
* - other non-zero — generic server error; surface `err_message` if present.
|
|
7893
|
+
*
|
|
7894
|
+
* The default Smartico UI shows a hardcoded "Failed to apply avatar" toast on any
|
|
7895
|
+
* non-zero `err_code` and does not surface `err_message`. Custom UIs SHOULD branch
|
|
7896
|
+
* on the code and prefer `err_message` when present (it is the localized server
|
|
7897
|
+
* string).
|
|
7898
|
+
*
|
|
7899
|
+
* **Refresh after success**
|
|
7900
|
+
* - The SDK clears both the `getAvatarsList` and `getAvatarsCustomized` caches —
|
|
7901
|
+
* the next call to either returns fresh data with the new `is_in_use` flag set on
|
|
7902
|
+
* the chosen avatar.
|
|
7903
|
+
* - The server persists the new avatar URL on the user record; {@link getUserProfile}
|
|
7904
|
+
* reflects it on the next read in this session.
|
|
7905
|
+
* - **No push to other open sessions.** A second device / tab the user is logged in
|
|
7906
|
+
* on will not see the new avatar until it next calls {@link getUserProfile} or
|
|
7907
|
+
* re-identifies. Plan UI accordingly.
|
|
7908
|
+
*
|
|
7909
|
+
* **Idempotency**: safe to retry. Re-applying the same `avatar_real_id` returns
|
|
7910
|
+
* `err_code: 0` and produces no double side effects (no double-deduction — this
|
|
7911
|
+
* method does not charge any currency — and no duplicate log entries).
|
|
7912
|
+
*
|
|
7913
|
+
* **Side effects**: updates the user's stored `avatar_id` / `avatar_real_id`. Does
|
|
7914
|
+
* NOT cost points, gems, or diamonds — the cost lives on the separate AI
|
|
7915
|
+
* customization HTTP flow ({@link getAvatarPrompts}). Does NOT write a user-visible
|
|
7916
|
+
* entry to {@link getActivityLog}.
|
|
7917
|
+
*
|
|
7918
|
+
* **UI guidance**: see [UI Guide — `setAvatar`](../../docs/ui/avatars/UIGuide_setAvatar.md).
|
|
7919
|
+
*
|
|
7920
|
+
* **Visitor mode**: not supported.
|
|
7921
|
+
*
|
|
7922
|
+
* @param props.avatar_url Absolute CDN URL of the avatar image. Read from
|
|
7923
|
+
* {@link TAvatarDefinition.url} for catalog avatars or
|
|
7924
|
+
* {@link TAvatarCustomized.url} for AI variants.
|
|
7925
|
+
* @param props.avatar_real_id Numeric ID of the base avatar from
|
|
7926
|
+
* {@link TAvatarDefinition.avatar_real_id}. For AI
|
|
7927
|
+
* variants, this is the `avatar_real_id` of the base
|
|
7928
|
+
* they were derived from.
|
|
7929
|
+
* @returns {@link TSetAvatarResult} — check `err_code === 0` for success.
|
|
7930
|
+
*
|
|
7931
|
+
* @example
|
|
7932
|
+
* ```ts
|
|
7933
|
+
* const avatars = await window._smartico.api.getAvatarsList();
|
|
7934
|
+
* const target = avatars.find((a) => a.avatar_real_id === 7);
|
|
7935
|
+
*
|
|
7936
|
+
* if (!target) {
|
|
7937
|
+
* console.error('[smartico] avatar 7 not in catalog — hide the picker entry');
|
|
7938
|
+
* return;
|
|
7939
|
+
* }
|
|
7940
|
+
*
|
|
7941
|
+
* const isLocked = !target.is_given && target.avatar_source_type_id !== 0;
|
|
7942
|
+
* if (isLocked) {
|
|
7943
|
+
* console.log('[smartico] avatar is locked — show "earn this first" prompt instead of calling setAvatar');
|
|
7944
|
+
* return;
|
|
7945
|
+
* }
|
|
7946
|
+
*
|
|
7947
|
+
* const r = await window._smartico.api.setAvatar({
|
|
7948
|
+
* avatar_url: target.avatar_url,
|
|
7949
|
+
* avatar_real_id: target.avatar_real_id,
|
|
6066
7950
|
* });
|
|
6067
|
-
* ```
|
|
6068
7951
|
*
|
|
6069
|
-
*
|
|
7952
|
+
* switch (r.err_code) {
|
|
7953
|
+
* case 0:
|
|
7954
|
+
* console.log('[smartico] avatar applied — close picker, refresh header avatar');
|
|
7955
|
+
* break;
|
|
7956
|
+
* case 1:
|
|
7957
|
+
* console.error('[smartico] avatar not in catalog — refresh catalog and show error');
|
|
7958
|
+
* break;
|
|
7959
|
+
* case 2:
|
|
7960
|
+
* console.error('[smartico] avatar inactive — operator disabled it; hide from picker');
|
|
7961
|
+
* break;
|
|
7962
|
+
* case 3:
|
|
7963
|
+
* console.error('[smartico] outside time window — show "available on X" message');
|
|
7964
|
+
* break;
|
|
7965
|
+
* case 4:
|
|
7966
|
+
* console.error('[smartico] not owned — show unlock requirements');
|
|
7967
|
+
* break;
|
|
7968
|
+
* default:
|
|
7969
|
+
* console.error('[smartico] avatar apply failed — show generic error toast:', r.err_message);
|
|
7970
|
+
* }
|
|
7971
|
+
* ```
|
|
6070
7972
|
*/
|
|
6071
7973
|
;
|
|
6072
7974
|
_proto.setAvatar = function setAvatar(props) {
|
|
@@ -6102,37 +8004,65 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6102
8004
|
_inheritsLoose(WSAPIGamePick, _WSAPIAvatars);
|
|
6103
8005
|
var _proto = WSAPIGamePick.prototype;
|
|
6104
8006
|
/**
|
|
6105
|
-
* Returns
|
|
6106
|
-
*
|
|
6107
|
-
*
|
|
6108
|
-
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
6109
|
-
*
|
|
6110
|
-
* **Response** `GamesApiResponse<GamePickRound[]>`:
|
|
6111
|
-
* - `errCode` - 0 on success
|
|
6112
|
-
* - `data` - Array of rounds, each containing:
|
|
6113
|
-
* - `round_id`, `round_name` - Round identifier and display name
|
|
6114
|
-
* - `open_date`, `last_bet_date` - Timestamps (ms) for round open and betting deadline
|
|
6115
|
-
* - `is_active_now`, `is_resolved` - Round state flags
|
|
6116
|
-
* - `round_status_id` - Round status: -1 (active), 2 (no more bets), 3 (all events resolved), 4 (round resolved)
|
|
6117
|
-
* - `score_full_win`, `score_part_win`, `score_lost` - Scoring rules per prediction outcome
|
|
6118
|
-
* - `user_score` - Current user's total score in this round
|
|
6119
|
-
* - `user_placed_bet` - Whether the user has submitted predictions
|
|
6120
|
-
* - `has_open_for_bet_events` - Whether there are events still open for betting
|
|
6121
|
-
* - `events[]` - Array of events with `gp_event_id`, `market_type_id`, `event_meta` (team names, images, sport), `match_date`, `is_open_for_bets`, `odds_details`, and user selection fields
|
|
6122
|
-
*
|
|
6123
|
-
* **Example**:
|
|
6124
|
-
* ```
|
|
6125
|
-
* _smartico.api.gamePickGetActiveRounds({
|
|
6126
|
-
* saw_template_id: 1083,
|
|
6127
|
-
* }).then((result) => {
|
|
6128
|
-
* console.log(result.data); // GamePickRound[]
|
|
6129
|
-
* result.data.forEach(round => {
|
|
6130
|
-
* console.log(round.round_name, round.events.length);
|
|
6131
|
-
* });
|
|
6132
|
-
* });
|
|
6133
|
-
* ```
|
|
8007
|
+
* Returns every open round for a MatchX or Quiz game template, with the full
|
|
8008
|
+
* event list (matches / questions) and the current user's selections per event.
|
|
6134
8009
|
*
|
|
6135
|
-
*
|
|
8010
|
+
* Use to power the rounds-lobby screen — typically a list of round cards a user
|
|
8011
|
+
* can tap into to make predictions. For a single round, use
|
|
8012
|
+
* {@link gamePickGetActiveRound} (lighter payload when only one round is shown).
|
|
8013
|
+
*
|
|
8014
|
+
* @remarks
|
|
8015
|
+
* **Preconditions**
|
|
8016
|
+
* - User must be authenticated.
|
|
8017
|
+
* - `saw_template_id` must reference a MatchX or Quiz game template. The SDK
|
|
8018
|
+
* throws synchronously if it's missing.
|
|
8019
|
+
*
|
|
8020
|
+
* **Transport**
|
|
8021
|
+
* Game Pick methods are HTTP REST calls to a separate Game Pick games server
|
|
8022
|
+
* (not the main WebSocket). One consequence: there is no SDK cache and no push
|
|
8023
|
+
* subscription — every call is a fresh server roundtrip.
|
|
8024
|
+
*
|
|
8025
|
+
* **Round status**
|
|
8026
|
+
* Each round's `round_status_id` is a {@link GPRoundStatus} value. Rounds with
|
|
8027
|
+
* status `NoEventsDefined` (1) are filtered out server-side and never appear
|
|
8028
|
+
* here. Other values: `Other` (-1, normally open), `NoMoreBetsAllowed` (2),
|
|
8029
|
+
* `AllEventsResolved_ButNotRound` (3), `RoundResolved` (4 — appears here only
|
|
8030
|
+
* briefly during transition; use {@link gamePickGetHistory} for resolved rounds).
|
|
8031
|
+
*
|
|
8032
|
+
* **Error codes** (in `errCode`)
|
|
8033
|
+
* - `0` — success.
|
|
8034
|
+
* - `100002` — template not found (the `saw_template_id` doesn't reference a
|
|
8035
|
+
* MatchX/Quiz game).
|
|
8036
|
+
* - `100003` — no open rounds available for this template right now.
|
|
8037
|
+
* - `100000` — auth hash invalid; SDK session needs re-initialization.
|
|
8038
|
+
* - `100004` — generic server error.
|
|
8039
|
+
*
|
|
8040
|
+
* **Refresh**
|
|
8041
|
+
* - No cache; every call is live.
|
|
8042
|
+
* - No push subscription. Poll while the user is on the screen if you need
|
|
8043
|
+
* live round-status changes (typically every 30–60 s is enough).
|
|
8044
|
+
*
|
|
8045
|
+
* **Visitor mode**: not supported. The SDK throws synchronously on visitor
|
|
8046
|
+
* sessions.
|
|
8047
|
+
*
|
|
8048
|
+
* **UI guidance**: see [UI Guide — `gamePickGetActiveRounds`](../../docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md).
|
|
8049
|
+
*
|
|
8050
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8051
|
+
* @returns Wrapped {@link GamesApiResponse} of {@link GamePickRound} array.
|
|
8052
|
+
*
|
|
8053
|
+
* @example
|
|
8054
|
+
* ```ts
|
|
8055
|
+
* const r = await window._smartico.api.gamePickGetActiveRounds({ saw_template_id: 1083 });
|
|
8056
|
+
*
|
|
8057
|
+
* if (r.errCode !== 0) {
|
|
8058
|
+
* console.error('[smartico] active rounds fetch failed — show empty rounds lobby:', r.errMessage);
|
|
8059
|
+
* return;
|
|
8060
|
+
* }
|
|
8061
|
+
*
|
|
8062
|
+
* for (const round of r.data ?? []) {
|
|
8063
|
+
* console.log('[smartico] render a round card:', round.round_name, '— events:', round.events.length, 'user has placed bet:', round.user_placed_bet);
|
|
8064
|
+
* }
|
|
8065
|
+
* ```
|
|
6136
8066
|
*/
|
|
6137
8067
|
_proto.gamePickGetActiveRounds = function gamePickGetActiveRounds(props) {
|
|
6138
8068
|
try {
|
|
@@ -6146,29 +8076,56 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6146
8076
|
}
|
|
6147
8077
|
}
|
|
6148
8078
|
/**
|
|
6149
|
-
* Returns a single
|
|
6150
|
-
*
|
|
8079
|
+
* Returns a single round (events, user selections, scoring rules) for a
|
|
8080
|
+
* MatchX or Quiz game. Use to power the round-detail / prediction-input
|
|
8081
|
+
* screen the user lands on after picking a round from the lobby.
|
|
6151
8082
|
*
|
|
6152
|
-
*
|
|
6153
|
-
*
|
|
8083
|
+
* Same shape as one entry of {@link gamePickGetActiveRounds}; cheaper when the
|
|
8084
|
+
* UI only shows one round at a time.
|
|
6154
8085
|
*
|
|
6155
|
-
*
|
|
6156
|
-
*
|
|
6157
|
-
* -
|
|
6158
|
-
*
|
|
8086
|
+
* @remarks
|
|
8087
|
+
* **Preconditions**
|
|
8088
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8089
|
+
* - `saw_template_id` and `round_id` are mandatory — the SDK throws if either
|
|
8090
|
+
* is missing.
|
|
8091
|
+
*
|
|
8092
|
+
* **Error codes** (in `errCode`)
|
|
8093
|
+
* - `0` — success.
|
|
8094
|
+
* - `4` — round / event not found (e.g. round resolved after the last
|
|
8095
|
+
* `gamePickGetActiveRounds` poll); non-fatal — retry after a fresh active-
|
|
8096
|
+
* rounds fetch.
|
|
8097
|
+
* - `100002` — template not found.
|
|
8098
|
+
* - `100000` — auth hash invalid.
|
|
8099
|
+
* - `100004` — generic server error.
|
|
8100
|
+
*
|
|
8101
|
+
* **Refresh**
|
|
8102
|
+
* - No cache; every call is live.
|
|
8103
|
+
* - Re-call after {@link gamePickSubmitSelection} or
|
|
8104
|
+
* {@link gamePickSubmitSelectionQuiz} to surface the persisted predictions.
|
|
8105
|
+
* - Poll while the user is on the prediction screen if event resolution
|
|
8106
|
+
* updates are needed (typically every 30–60 s).
|
|
6159
8107
|
*
|
|
6160
|
-
* **
|
|
6161
|
-
*
|
|
6162
|
-
*
|
|
6163
|
-
*
|
|
6164
|
-
*
|
|
6165
|
-
*
|
|
6166
|
-
*
|
|
6167
|
-
*
|
|
8108
|
+
* **Visitor mode**: not supported.
|
|
8109
|
+
*
|
|
8110
|
+
* **UI guidance**: see [UI Guide — `gamePickGetActiveRound`](../../docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md).
|
|
8111
|
+
*
|
|
8112
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8113
|
+
* @param props.round_id ID of the round to fetch.
|
|
8114
|
+
* @returns Wrapped {@link GamesApiResponse} of a single {@link GamePickRound}.
|
|
8115
|
+
*
|
|
8116
|
+
* @example
|
|
8117
|
+
* ```ts
|
|
8118
|
+
* const r = await window._smartico.api.gamePickGetActiveRound({
|
|
8119
|
+
* saw_template_id: 1083,
|
|
8120
|
+
* round_id: 31652,
|
|
6168
8121
|
* });
|
|
6169
|
-
* ```
|
|
6170
8122
|
*
|
|
6171
|
-
*
|
|
8123
|
+
* if (r.errCode === 0 && r.data) {
|
|
8124
|
+
* console.log('[smartico] render round detail page —', r.data.round_name, '— user has placed bet:', r.data.user_placed_bet, 'score so far:', r.data.user_score);
|
|
8125
|
+
* } else {
|
|
8126
|
+
* console.error('[smartico] round fetch failed — bounce back to the lobby and refresh:', r.errMessage);
|
|
8127
|
+
* }
|
|
8128
|
+
* ```
|
|
6172
8129
|
*/
|
|
6173
8130
|
;
|
|
6174
8131
|
_proto.gamePickGetActiveRound = function gamePickGetActiveRound(props) {
|
|
@@ -6186,29 +8143,52 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6186
8143
|
}
|
|
6187
8144
|
}
|
|
6188
8145
|
/**
|
|
6189
|
-
* Returns the
|
|
6190
|
-
* Each round
|
|
8146
|
+
* Returns the full round history (active + resolved) for a MatchX or Quiz game
|
|
8147
|
+
* template, newest-first. Each round carries the user's predictions plus the
|
|
8148
|
+
* server-resolved outcome on each event.
|
|
6191
8149
|
*
|
|
6192
|
-
*
|
|
8150
|
+
* Use to power a "Past predictions" / history tab. For just the open rounds,
|
|
8151
|
+
* use {@link gamePickGetActiveRounds} (faster — skips resolved data).
|
|
6193
8152
|
*
|
|
6194
|
-
*
|
|
6195
|
-
*
|
|
6196
|
-
* -
|
|
6197
|
-
* Each round has the same structure as in `gamePickGetActiveRounds`, including resolved events
|
|
6198
|
-
* with `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) and `resolution_score`
|
|
8153
|
+
* @remarks
|
|
8154
|
+
* **Preconditions**
|
|
8155
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
6199
8156
|
*
|
|
6200
|
-
* **
|
|
6201
|
-
*
|
|
6202
|
-
* _smartico.api.gamePickGetHistory({
|
|
6203
|
-
* saw_template_id: 1083,
|
|
6204
|
-
* }).then((result) => {
|
|
6205
|
-
* result.data.forEach(round => {
|
|
6206
|
-
* console.log(round.round_name, 'Score:', round.user_score, 'Resolved:', round.is_resolved);
|
|
6207
|
-
* });
|
|
6208
|
-
* });
|
|
6209
|
-
* ```
|
|
8157
|
+
* **Sort order**
|
|
8158
|
+
* Server returns rounds newest-first. No client-side sort needed.
|
|
6210
8159
|
*
|
|
6211
|
-
* **
|
|
8160
|
+
* **Per-event resolution**
|
|
8161
|
+
* Each event in the rounds carries `resolution_type_id` — values are from
|
|
8162
|
+
* {@link GamePickResolutionType}: `None` (0, not yet resolved), `Lost` (2),
|
|
8163
|
+
* `PartialWin` (3), `FullWin` (4). Use these to render result badges on
|
|
8164
|
+
* each event row.
|
|
8165
|
+
*
|
|
8166
|
+
* **Error codes** (in `errCode`)
|
|
8167
|
+
* - `0` — success.
|
|
8168
|
+
* - `100002` — template not found.
|
|
8169
|
+
* - `100000` — auth hash invalid.
|
|
8170
|
+
* - `100004` — generic server error.
|
|
8171
|
+
*
|
|
8172
|
+
* **Refresh**
|
|
8173
|
+
* - No cache.
|
|
8174
|
+
* - No push subscription. Re-call when the user opens the history tab.
|
|
8175
|
+
*
|
|
8176
|
+
* **Visitor mode**: not supported.
|
|
8177
|
+
*
|
|
8178
|
+
* **UI guidance**: see [UI Guide — `gamePickGetHistory`](../../docs/ui/gamepick/UIGuide_gamePickGetHistory.md).
|
|
8179
|
+
*
|
|
8180
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8181
|
+
* @returns Wrapped {@link GamesApiResponse} of {@link GamePickRound} array,
|
|
8182
|
+
* newest-first.
|
|
8183
|
+
*
|
|
8184
|
+
* @example
|
|
8185
|
+
* ```ts
|
|
8186
|
+
* const r = await window._smartico.api.gamePickGetHistory({ saw_template_id: 1083 });
|
|
8187
|
+
*
|
|
8188
|
+
* for (const round of r.data ?? []) {
|
|
8189
|
+
* console.log('[smartico] history row —', round.round_name, 'score:', round.user_score, 'resolved:', round.is_resolved);
|
|
8190
|
+
* }
|
|
8191
|
+
* ```
|
|
6212
8192
|
*/
|
|
6213
8193
|
;
|
|
6214
8194
|
_proto.gamePickGetHistory = function gamePickGetHistory(props) {
|
|
@@ -6223,36 +8203,66 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6223
8203
|
}
|
|
6224
8204
|
}
|
|
6225
8205
|
/**
|
|
6226
|
-
* Returns the leaderboard for a
|
|
6227
|
-
*
|
|
6228
|
-
*
|
|
6229
|
-
*
|
|
6230
|
-
* @
|
|
6231
|
-
*
|
|
6232
|
-
*
|
|
6233
|
-
*
|
|
6234
|
-
*
|
|
6235
|
-
*
|
|
6236
|
-
*
|
|
6237
|
-
*
|
|
6238
|
-
*
|
|
6239
|
-
*
|
|
6240
|
-
*
|
|
6241
|
-
*
|
|
6242
|
-
*
|
|
6243
|
-
*
|
|
6244
|
-
*
|
|
6245
|
-
*
|
|
6246
|
-
*
|
|
6247
|
-
*
|
|
6248
|
-
*
|
|
6249
|
-
*
|
|
6250
|
-
*
|
|
6251
|
-
*
|
|
8206
|
+
* Returns the leaderboard for a MatchX or Quiz game round — ranked list of
|
|
8207
|
+
* players plus the current user's entry (`my_user`). Pass `round_id: -1` for
|
|
8208
|
+
* the season / overall leaderboard across every round in the template.
|
|
8209
|
+
*
|
|
8210
|
+
* @remarks
|
|
8211
|
+
* **Preconditions**
|
|
8212
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8213
|
+
*
|
|
8214
|
+
* **`round_id` semantics**
|
|
8215
|
+
* - Positive `round_id` — per-round leaderboard scoped to that round's events.
|
|
8216
|
+
* - `-1` — season / overall leaderboard aggregating scores across every round
|
|
8217
|
+
* of the template.
|
|
8218
|
+
*
|
|
8219
|
+
* **`my_user`**
|
|
8220
|
+
* The current user's entry is returned separately from the `users[]` array
|
|
8221
|
+
* — `my_user` may be `null` if the user has never made a prediction on this
|
|
8222
|
+
* round / template. Use it to render the user's rank in a sticky footer or
|
|
8223
|
+
* "you are here" highlight regardless of pagination.
|
|
8224
|
+
*
|
|
8225
|
+
* **Username masking**
|
|
8226
|
+
* `public_username` on other players may be masked / anonymized by operator
|
|
8227
|
+
* label settings. Always pair with `avatar_url` so the user can recognize
|
|
8228
|
+
* themselves in the ranking by avatar even when usernames are hidden.
|
|
8229
|
+
*
|
|
8230
|
+
* **Error codes** (in `errCode`)
|
|
8231
|
+
* - `0` — success.
|
|
8232
|
+
* - `100002` — template not found.
|
|
8233
|
+
* - `100000` — auth hash invalid.
|
|
8234
|
+
* - `100004` — generic server error.
|
|
8235
|
+
*
|
|
8236
|
+
* **Refresh**
|
|
8237
|
+
* - No cache.
|
|
8238
|
+
* - No push subscription. Poll while the leaderboard is visible
|
|
8239
|
+
* (every 30–60 s) if you want live rank updates after match
|
|
8240
|
+
* resolution.
|
|
8241
|
+
*
|
|
8242
|
+
* **Visitor mode**: not supported.
|
|
8243
|
+
*
|
|
8244
|
+
* **UI guidance**: see [UI Guide — `gamePickGetBoard`](../../docs/ui/gamepick/UIGuide_gamePickGetBoard.md).
|
|
8245
|
+
*
|
|
8246
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8247
|
+
* @param props.round_id Round ID, or `-1` for the season leaderboard.
|
|
8248
|
+
* @returns Wrapped {@link GamesApiResponse} of {@link GamePickRoundBoard}.
|
|
8249
|
+
*
|
|
8250
|
+
* @example
|
|
8251
|
+
* ```ts
|
|
8252
|
+
* const r = await window._smartico.api.gamePickGetBoard({
|
|
8253
|
+
* saw_template_id: 1083,
|
|
8254
|
+
* round_id: -1, // season leaderboard
|
|
6252
8255
|
* });
|
|
6253
|
-
* ```
|
|
6254
8256
|
*
|
|
6255
|
-
*
|
|
8257
|
+
* if (r.errCode === 0 && r.data) {
|
|
8258
|
+
* console.log('[smartico] render leaderboard rows for top', r.data.users.length, 'players');
|
|
8259
|
+
* if (r.data.my_user) {
|
|
8260
|
+
* console.log('[smartico] pin "you are rank #' + r.data.my_user.gp_position + '" footer to bottom');
|
|
8261
|
+
* } else {
|
|
8262
|
+
* console.log('[smartico] user not ranked — render "Play a round to join the leaderboard" CTA');
|
|
8263
|
+
* }
|
|
8264
|
+
* }
|
|
8265
|
+
* ```
|
|
6256
8266
|
*/
|
|
6257
8267
|
;
|
|
6258
8268
|
_proto.gamePickGetBoard = function gamePickGetBoard(props) {
|
|
@@ -6270,43 +8280,107 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6270
8280
|
}
|
|
6271
8281
|
}
|
|
6272
8282
|
/**
|
|
6273
|
-
* Submits score predictions for a round in a MatchX game.
|
|
6274
|
-
*
|
|
6275
|
-
*
|
|
6276
|
-
*
|
|
6277
|
-
*
|
|
6278
|
-
*
|
|
6279
|
-
*
|
|
6280
|
-
*
|
|
6281
|
-
*
|
|
6282
|
-
*
|
|
6283
|
-
* **
|
|
6284
|
-
* -
|
|
6285
|
-
* - `
|
|
6286
|
-
*
|
|
6287
|
-
*
|
|
6288
|
-
*
|
|
6289
|
-
*
|
|
6290
|
-
*
|
|
6291
|
-
*
|
|
6292
|
-
*
|
|
6293
|
-
*
|
|
6294
|
-
*
|
|
6295
|
-
*
|
|
6296
|
-
*
|
|
6297
|
-
*
|
|
6298
|
-
*
|
|
6299
|
-
*
|
|
6300
|
-
*
|
|
6301
|
-
*
|
|
6302
|
-
*
|
|
6303
|
-
*
|
|
6304
|
-
*
|
|
6305
|
-
*
|
|
8283
|
+
* Submits all score predictions for a round in a MatchX game in one shot.
|
|
8284
|
+
* Each event in the round must carry `team1_user_selection` and
|
|
8285
|
+
* `team2_user_selection` (the predicted scores).
|
|
8286
|
+
*
|
|
8287
|
+
* On the user's FIRST submit for a round, the server charges one buy-in (one
|
|
8288
|
+
* "spin" / one currency deduction based on the template's `saw_buyin_type_id`).
|
|
8289
|
+
* Subsequent edits within the same round are free and only persist changed
|
|
8290
|
+
* selections.
|
|
8291
|
+
*
|
|
8292
|
+
* @remarks
|
|
8293
|
+
* **Preconditions**
|
|
8294
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8295
|
+
* - `saw_template_id` and `props.round.round_id` are mandatory — SDK throws if
|
|
8296
|
+
* either is missing.
|
|
8297
|
+
* - Each event passed must include `gp_event_id` and the two
|
|
8298
|
+
* `team{1,2}_user_selection` fields. Missing events default to "no change".
|
|
8299
|
+
*
|
|
8300
|
+
* **Error codes** (in `errCode`)
|
|
8301
|
+
* - `0` — success; the response `data` is the updated round with
|
|
8302
|
+
* `user_placed_bet === true` and `has_not_submitted_changes === false`.
|
|
8303
|
+
* - `3` (`NoBetsUpdatedOnSubmit`) — submit produced no changes, OR every event
|
|
8304
|
+
* is past its `last_bet_date` deadline. The buy-in is NOT consumed; the
|
|
8305
|
+
* current round is still returned in `data`.
|
|
8306
|
+
* - `4` — round / event not found; refresh state and retry.
|
|
8307
|
+
* - `100002` — template not found.
|
|
8308
|
+
* - `100000` — auth hash invalid.
|
|
8309
|
+
* - `100004` — generic server error.
|
|
8310
|
+
*
|
|
8311
|
+
* Buy-in failures pass through the {@link SAWSpinErrorCode} values on first
|
|
8312
|
+
* submit:
|
|
8313
|
+
* - `40001` — no spins left (when `saw_buyin_type_id` is Spins).
|
|
8314
|
+
* - `40003` — insufficient points.
|
|
8315
|
+
* - `40004` — global max-spins cap hit.
|
|
8316
|
+
* - `40007` — template outside its active date window.
|
|
8317
|
+
* - `40009` — user excluded by segment rule.
|
|
8318
|
+
* - `40011` — insufficient gems.
|
|
8319
|
+
* - `40012` — insufficient diamonds.
|
|
8320
|
+
*
|
|
8321
|
+
* **Idempotency**
|
|
8322
|
+
* Re-submitting identical selections returns `errCode: 3` (no changes); the
|
|
8323
|
+
* buy-in is consumed exactly once per round-per-user. Re-submitting after
|
|
8324
|
+
* `last_bet_date` also returns `errCode: 3` without consuming the buy-in.
|
|
8325
|
+
*
|
|
8326
|
+
* **Side effects**
|
|
8327
|
+
* - First successful submit deducts the buy-in (Points / Gems / Diamonds /
|
|
8328
|
+
* one Spin) per `saw_buyin_type_id`.
|
|
8329
|
+
* - Reports a `minigame_matchx_prediction` event to the operator's event log.
|
|
8330
|
+
* - Updates the round's participant counter (`users_cnt`) and per-event
|
|
8331
|
+
* counters (`num_users`).
|
|
8332
|
+
* - Score is awarded after the operator resolves the round
|
|
8333
|
+
* ({@link GPRoundStatus} = `RoundResolved`).
|
|
8334
|
+
*
|
|
8335
|
+
* **Visitor mode**: not supported.
|
|
8336
|
+
*
|
|
8337
|
+
* **UI guidance**: see [UI Guide — `gamePickSubmitSelection`](../../docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md).
|
|
8338
|
+
*
|
|
8339
|
+
* @param props.saw_template_id ID of the MatchX game template.
|
|
8340
|
+
* @param props.round Round object with `round_id` + `events[]`
|
|
8341
|
+
* carrying the user's score predictions.
|
|
8342
|
+
* @returns Wrapped {@link GamesApiResponse} with the updated round.
|
|
8343
|
+
*
|
|
8344
|
+
* @example
|
|
8345
|
+
* ```ts
|
|
8346
|
+
* const ar = await window._smartico.api.gamePickGetActiveRound({
|
|
8347
|
+
* saw_template_id: 1190,
|
|
8348
|
+
* round_id: 38665,
|
|
6306
8349
|
* });
|
|
6307
|
-
*
|
|
8350
|
+
* if (ar.errCode !== 0 || !ar.data) {
|
|
8351
|
+
* console.error('[smartico] could not fetch round to submit — show error and bounce back');
|
|
8352
|
+
* return;
|
|
8353
|
+
* }
|
|
6308
8354
|
*
|
|
6309
|
-
*
|
|
8355
|
+
* const round = ar.data;
|
|
8356
|
+
* round.events = round.events.map(e => ({
|
|
8357
|
+
* gp_event_id: e.gp_event_id,
|
|
8358
|
+
* team1_user_selection: 1,
|
|
8359
|
+
* team2_user_selection: 0,
|
|
8360
|
+
* }));
|
|
8361
|
+
*
|
|
8362
|
+
* const r = await window._smartico.api.gamePickSubmitSelection({
|
|
8363
|
+
* saw_template_id: 1190,
|
|
8364
|
+
* round,
|
|
8365
|
+
* });
|
|
8366
|
+
*
|
|
8367
|
+
* switch (r.errCode) {
|
|
8368
|
+
* case 0:
|
|
8369
|
+
* console.log('[smartico] predictions saved — show confirmation, refresh leaderboard');
|
|
8370
|
+
* break;
|
|
8371
|
+
* case 3:
|
|
8372
|
+
* console.log('[smartico] nothing changed (or all events closed) — silent no-op');
|
|
8373
|
+
* break;
|
|
8374
|
+
* case 40001:
|
|
8375
|
+
* case 40003:
|
|
8376
|
+
* case 40011:
|
|
8377
|
+
* case 40012:
|
|
8378
|
+
* console.error('[smartico] insufficient balance / spins — show top-up CTA:', r.errMessage);
|
|
8379
|
+
* break;
|
|
8380
|
+
* default:
|
|
8381
|
+
* console.error('[smartico] submit failed — show generic error toast:', r.errMessage);
|
|
8382
|
+
* }
|
|
8383
|
+
* ```
|
|
6310
8384
|
*/
|
|
6311
8385
|
;
|
|
6312
8386
|
_proto.gamePickSubmitSelection = function gamePickSubmitSelection(props) {
|
|
@@ -6325,42 +8399,83 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6325
8399
|
}
|
|
6326
8400
|
}
|
|
6327
8401
|
/**
|
|
6328
|
-
* Submits answers for a round in
|
|
6329
|
-
*
|
|
6330
|
-
*
|
|
6331
|
-
*
|
|
6332
|
-
*
|
|
6333
|
-
*
|
|
6334
|
-
*
|
|
6335
|
-
*
|
|
6336
|
-
*
|
|
6337
|
-
*
|
|
6338
|
-
* **
|
|
6339
|
-
* -
|
|
6340
|
-
* - `
|
|
6341
|
-
*
|
|
6342
|
-
*
|
|
6343
|
-
*
|
|
6344
|
-
*
|
|
6345
|
-
*
|
|
6346
|
-
*
|
|
6347
|
-
*
|
|
6348
|
-
*
|
|
6349
|
-
*
|
|
6350
|
-
*
|
|
6351
|
-
*
|
|
6352
|
-
*
|
|
6353
|
-
*
|
|
6354
|
-
*
|
|
6355
|
-
*
|
|
6356
|
-
*
|
|
6357
|
-
*
|
|
6358
|
-
*
|
|
6359
|
-
*
|
|
8402
|
+
* Submits all quiz answers for a round in one shot. Each event in the round
|
|
8403
|
+
* must carry `user_selection` (the answer value — typically `"1"` / `"2"` /
|
|
8404
|
+
* `"x"` for 1×2 markets, `"yes"` / `"no"` for binary markets, or any
|
|
8405
|
+
* operator-defined string for custom markets).
|
|
8406
|
+
*
|
|
8407
|
+
* Same first-submit buy-in behavior as {@link gamePickSubmitSelection} — one
|
|
8408
|
+
* buy-in is charged on the first successful submit; subsequent edits within
|
|
8409
|
+
* the same round are free.
|
|
8410
|
+
*
|
|
8411
|
+
* @remarks
|
|
8412
|
+
* **Preconditions**
|
|
8413
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8414
|
+
* - `saw_template_id` and `props.round.round_id` are mandatory — SDK throws if
|
|
8415
|
+
* either is missing.
|
|
8416
|
+
* - Each event must include `gp_event_id` and `user_selection`. Missing
|
|
8417
|
+
* events default to "no change".
|
|
8418
|
+
*
|
|
8419
|
+
* **Error codes** (in `errCode`)
|
|
8420
|
+
* - `0` — success.
|
|
8421
|
+
* - `3` (`NoBetsUpdatedOnSubmit`) — no changes, OR every event past
|
|
8422
|
+
* `last_bet_date`. Buy-in NOT consumed; current round returned in `data`.
|
|
8423
|
+
* - `4` — round / event not found.
|
|
8424
|
+
* - `100002` — template not found.
|
|
8425
|
+
* - `100000` — auth hash invalid.
|
|
8426
|
+
* - `100004` — generic server error.
|
|
8427
|
+
*
|
|
8428
|
+
* Buy-in failures use the same {@link SAWSpinErrorCode} pass-through values
|
|
8429
|
+
* as {@link gamePickSubmitSelection} — see that method's TSDoc for the
|
|
8430
|
+
* `40001` / `40003` / `40004` / `40007` / `40009` / `40011` / `40012`
|
|
8431
|
+
* semantics.
|
|
8432
|
+
*
|
|
8433
|
+
* **Idempotency**: identical to {@link gamePickSubmitSelection} — re-submit
|
|
8434
|
+
* returns `errCode: 3` and never double-charges the buy-in.
|
|
8435
|
+
*
|
|
8436
|
+
* **Side effects**: identical to {@link gamePickSubmitSelection}, with the
|
|
8437
|
+
* reported event being `minigame_quiz_prediction` instead of
|
|
8438
|
+
* `minigame_matchx_prediction`.
|
|
8439
|
+
*
|
|
8440
|
+
* **Visitor mode**: not supported.
|
|
8441
|
+
*
|
|
8442
|
+
* **UI guidance**: see [UI Guide — `gamePickSubmitSelectionQuiz`](../../docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md).
|
|
8443
|
+
*
|
|
8444
|
+
* @param props.saw_template_id ID of the Quiz game template.
|
|
8445
|
+
* @param props.round Round object with `round_id` + `events[]`
|
|
8446
|
+
* carrying the user's answer selections.
|
|
8447
|
+
* @returns Wrapped {@link GamesApiResponse} with the updated round.
|
|
8448
|
+
*
|
|
8449
|
+
* @example
|
|
8450
|
+
* ```ts
|
|
8451
|
+
* const ar = await window._smartico.api.gamePickGetActiveRound({
|
|
8452
|
+
* saw_template_id: 1183,
|
|
8453
|
+
* round_id: 37974,
|
|
6360
8454
|
* });
|
|
6361
|
-
*
|
|
8455
|
+
* if (ar.errCode !== 0 || !ar.data) {
|
|
8456
|
+
* console.error('[smartico] could not fetch round to submit answers — show error');
|
|
8457
|
+
* return;
|
|
8458
|
+
* }
|
|
6362
8459
|
*
|
|
6363
|
-
*
|
|
8460
|
+
* const round = ar.data;
|
|
8461
|
+
* round.events = round.events.map(e => ({
|
|
8462
|
+
* gp_event_id: e.gp_event_id,
|
|
8463
|
+
* user_selection: 'x',
|
|
8464
|
+
* }));
|
|
8465
|
+
*
|
|
8466
|
+
* const r = await window._smartico.api.gamePickSubmitSelectionQuiz({
|
|
8467
|
+
* saw_template_id: 1183,
|
|
8468
|
+
* round,
|
|
8469
|
+
* });
|
|
8470
|
+
*
|
|
8471
|
+
* if (r.errCode === 0) {
|
|
8472
|
+
* console.log('[smartico] quiz answers saved — show confirmation');
|
|
8473
|
+
* } else if (r.errCode === 3) {
|
|
8474
|
+
* console.log('[smartico] nothing changed — silent no-op');
|
|
8475
|
+
* } else {
|
|
8476
|
+
* console.error('[smartico] quiz submit failed:', r.errMessage);
|
|
8477
|
+
* }
|
|
8478
|
+
* ```
|
|
6364
8479
|
*/
|
|
6365
8480
|
;
|
|
6366
8481
|
_proto.gamePickSubmitSelectionQuiz = function gamePickSubmitSelectionQuiz(props) {
|
|
@@ -6378,36 +8493,52 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6378
8493
|
return Promise.reject(e);
|
|
6379
8494
|
}
|
|
6380
8495
|
}
|
|
6381
|
-
/**
|
|
6382
|
-
* Returns the current user's profile
|
|
6383
|
-
*
|
|
6384
|
-
*
|
|
6385
|
-
*
|
|
6386
|
-
*
|
|
6387
|
-
*
|
|
6388
|
-
* **Response** `GamesApiResponse<GamePickUserInfo>`:
|
|
6389
|
-
* - `errCode` - 0 on success
|
|
6390
|
-
* - `data`:
|
|
6391
|
-
* - `ext_user_id` - External user ID (Smartico internal numeric ID)
|
|
6392
|
-
* - `int_user_id` - Internal user ID within the games system
|
|
6393
|
-
* - `public_username` - Display name
|
|
6394
|
-
* - `avatar_url` - User's avatar image URL
|
|
6395
|
-
* - `last_wallet_sync_time` - Last time the user's balance was synced from Smartico
|
|
6396
|
-
* - `ach_points_balance` - User's current points balance
|
|
6397
|
-
* - `ach_gems_balance` - User's current gems balance
|
|
6398
|
-
* - `ach_diamonds_balance` - User's current diamonds balance
|
|
6399
|
-
* - `pubic_username_set` - Whether the user has set a custom username
|
|
6400
|
-
*
|
|
6401
|
-
* **Example**:
|
|
6402
|
-
* ```
|
|
6403
|
-
* _smartico.api.gamePickGetUserInfo({
|
|
6404
|
-
* saw_template_id: 1083,
|
|
6405
|
-
* }).then((result) => {
|
|
6406
|
-
* console.log(result.data.public_username, result.data.ach_points_balance);
|
|
6407
|
-
* });
|
|
6408
|
-
* ```
|
|
8496
|
+
/**
|
|
8497
|
+
* Returns the current user's profile within the Game Pick system — display
|
|
8498
|
+
* name, avatar, balances, and last wallet-sync timestamp. The Game Pick server
|
|
8499
|
+
* maintains its own user record that mirrors the user's Smartico balances; the
|
|
8500
|
+
* mirror is updated at most once per minute, so `last_wallet_sync_time` tells
|
|
8501
|
+
* the consumer how stale the balances on the response are.
|
|
6409
8502
|
*
|
|
6410
|
-
*
|
|
8503
|
+
* On the user's first call for a given game, the Game Pick server lazily
|
|
8504
|
+
* provisions a user record — so this method doubles as a "register the user
|
|
8505
|
+
* with this game" call.
|
|
8506
|
+
*
|
|
8507
|
+
* @remarks
|
|
8508
|
+
* **Preconditions**
|
|
8509
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8510
|
+
*
|
|
8511
|
+
* **Balance freshness**
|
|
8512
|
+
* The balances returned here are the cached mirror — at most ~1 minute stale.
|
|
8513
|
+
* For an up-to-the-second view of Points / Gems / Diamonds, read from
|
|
8514
|
+
* {@link getUserProfile} instead. Use this method's balances only for
|
|
8515
|
+
* in-Game-Pick display.
|
|
8516
|
+
*
|
|
8517
|
+
* **Error codes** (in `errCode`)
|
|
8518
|
+
* - `0` — success.
|
|
8519
|
+
* - `100002` — template not found.
|
|
8520
|
+
* - `100000` — auth hash invalid.
|
|
8521
|
+
* - `100004` — generic server error.
|
|
8522
|
+
*
|
|
8523
|
+
* **Refresh**
|
|
8524
|
+
* - No cache. Server-side mirror refreshes at most every 60 s.
|
|
8525
|
+
* - No push subscription.
|
|
8526
|
+
*
|
|
8527
|
+
* **Visitor mode**: not supported.
|
|
8528
|
+
*
|
|
8529
|
+
* **UI guidance**: see [UI Guide — `gamePickGetUserInfo`](../../docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md).
|
|
8530
|
+
*
|
|
8531
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8532
|
+
* @returns Wrapped {@link GamesApiResponse} of {@link GamePickUserInfo}.
|
|
8533
|
+
*
|
|
8534
|
+
* @example
|
|
8535
|
+
* ```ts
|
|
8536
|
+
* const r = await window._smartico.api.gamePickGetUserInfo({ saw_template_id: 1083 });
|
|
8537
|
+
*
|
|
8538
|
+
* if (r.errCode === 0 && r.data) {
|
|
8539
|
+
* console.log('[smartico] render Game Pick header — name:', r.data.public_username, '— points:', r.data.ach_points_balance, '— synced:', r.data.last_wallet_sync_time);
|
|
8540
|
+
* }
|
|
8541
|
+
* ```
|
|
6411
8542
|
*/
|
|
6412
8543
|
;
|
|
6413
8544
|
_proto.gamePickGetUserInfo = function gamePickGetUserInfo(props) {
|
|
@@ -6422,38 +8553,56 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6422
8553
|
}
|
|
6423
8554
|
}
|
|
6424
8555
|
/**
|
|
6425
|
-
* Returns the game configuration
|
|
6426
|
-
*
|
|
6427
|
-
*
|
|
6428
|
-
*
|
|
6429
|
-
*
|
|
6430
|
-
* **Response** `GamesApiResponse<GamePickGameInfo>`:
|
|
6431
|
-
* - `errCode` - 0 on success
|
|
6432
|
-
* - `data`:
|
|
6433
|
-
* - `sawTemplate` - Game template configuration including:
|
|
6434
|
-
* - `saw_template_id`, `saw_game_type_id` (6 = MatchX/Quiz)
|
|
6435
|
-
* - `saw_template_ui_definition` - UI settings (name, ranking options, ask_for_username, etc.)
|
|
6436
|
-
* - `saw_buyin_type_id` - Cost type (1=Free, 2=Points, 3=Gems, 4=Diamonds, 5=Spins)
|
|
6437
|
-
* - `buyin_cost_points` - Cost per attempt
|
|
6438
|
-
* - `spin_count` - Available attempts for the current user
|
|
6439
|
-
* - `allRounds[]` - List of all rounds (metadata only, no events), each with:
|
|
6440
|
-
* - `round_id`, `round_name`, `round_description`
|
|
6441
|
-
* - `open_date`, `last_bet_date` - Timestamps (ms)
|
|
6442
|
-
* - `is_active_now`, `is_resolved`, `round_status_id`
|
|
6443
|
-
* - `labelInfo` - Label/brand configuration and settings
|
|
6444
|
-
*
|
|
6445
|
-
* **Example**:
|
|
6446
|
-
* ```
|
|
6447
|
-
* _smartico.api.gamePickGetGameInfo({
|
|
6448
|
-
* saw_template_id: 1189,
|
|
6449
|
-
* }).then((result) => {
|
|
6450
|
-
* console.log(result.data.sawTemplate.saw_template_ui_definition.name);
|
|
6451
|
-
* console.log('Rounds:', result.data.allRounds.length);
|
|
6452
|
-
* console.log('Buy-in type:', result.data.sawTemplate.saw_buyin_type_id);
|
|
6453
|
-
* });
|
|
6454
|
-
* ```
|
|
8556
|
+
* Returns the game template configuration plus a metadata listing of every
|
|
8557
|
+
* round (without events). Use to power the game's welcome / lobby screen —
|
|
8558
|
+
* shows the template name, buy-in cost, the user's remaining attempts, and
|
|
8559
|
+
* the full round list.
|
|
6455
8560
|
*
|
|
6456
|
-
*
|
|
8561
|
+
* The `allRounds[]` here is a lightweight metadata-only view — to render
|
|
8562
|
+
* predictions or leaderboards, call {@link gamePickGetActiveRound} /
|
|
8563
|
+
* {@link gamePickGetActiveRounds} / {@link gamePickGetBoard} for the rounds
|
|
8564
|
+
* the user actually opens.
|
|
8565
|
+
*
|
|
8566
|
+
* @remarks
|
|
8567
|
+
* **Preconditions**
|
|
8568
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8569
|
+
*
|
|
8570
|
+
* **Buy-in semantics**
|
|
8571
|
+
* The `sawTemplate.saw_buyin_type_id` value determines which currency is
|
|
8572
|
+
* deducted on the user's first prediction in any round:
|
|
8573
|
+
* - Free — no deduction.
|
|
8574
|
+
* - Points — `buyin_cost_points` deducted from the user's points balance.
|
|
8575
|
+
* - Gems — deducted from the user's gems balance.
|
|
8576
|
+
* - Diamonds — deducted from the user's diamonds balance.
|
|
8577
|
+
* - Spins — one spin counted from `spin_count`.
|
|
8578
|
+
*
|
|
8579
|
+
* **Error codes** (in `errCode`)
|
|
8580
|
+
* - `0` — success.
|
|
8581
|
+
* - `100002` — template not found.
|
|
8582
|
+
* - `100000` — auth hash invalid.
|
|
8583
|
+
* - `100004` — generic server error.
|
|
8584
|
+
*
|
|
8585
|
+
* **Refresh**
|
|
8586
|
+
* - No cache.
|
|
8587
|
+
* - No push subscription. Re-call after a successful
|
|
8588
|
+
* {@link gamePickSubmitSelection} to refresh `spin_count`.
|
|
8589
|
+
*
|
|
8590
|
+
* **Visitor mode**: not supported.
|
|
8591
|
+
*
|
|
8592
|
+
* **UI guidance**: see [UI Guide — `gamePickGetGameInfo`](../../docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md).
|
|
8593
|
+
*
|
|
8594
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8595
|
+
* @returns Wrapped {@link GamesApiResponse} of {@link GamePickGameInfo}.
|
|
8596
|
+
*
|
|
8597
|
+
* @example
|
|
8598
|
+
* ```ts
|
|
8599
|
+
* const r = await window._smartico.api.gamePickGetGameInfo({ saw_template_id: 1189 });
|
|
8600
|
+
*
|
|
8601
|
+
* if (r.errCode === 0 && r.data) {
|
|
8602
|
+
* console.log('[smartico] render Game Pick lobby — title:', r.data.sawTemplate.saw_template_ui_definition.name);
|
|
8603
|
+
* console.log('[smartico] rounds available:', r.data.allRounds.length, '— buy-in type:', r.data.sawTemplate.saw_buyin_type_id, 'cost:', r.data.sawTemplate.buyin_cost_points);
|
|
8604
|
+
* }
|
|
8605
|
+
* ```
|
|
6457
8606
|
*/
|
|
6458
8607
|
;
|
|
6459
8608
|
_proto.gamePickGetGameInfo = function gamePickGetGameInfo(props) {
|
|
@@ -6468,35 +8617,73 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
|
|
|
6468
8617
|
}
|
|
6469
8618
|
}
|
|
6470
8619
|
/**
|
|
6471
|
-
* Returns round
|
|
6472
|
-
*
|
|
6473
|
-
*
|
|
6474
|
-
*
|
|
6475
|
-
*
|
|
6476
|
-
*
|
|
6477
|
-
*
|
|
6478
|
-
*
|
|
6479
|
-
*
|
|
6480
|
-
*
|
|
6481
|
-
* -
|
|
6482
|
-
*
|
|
6483
|
-
*
|
|
6484
|
-
*
|
|
6485
|
-
*
|
|
6486
|
-
*
|
|
6487
|
-
*
|
|
6488
|
-
*
|
|
6489
|
-
*
|
|
6490
|
-
*
|
|
6491
|
-
*
|
|
6492
|
-
* })
|
|
6493
|
-
*
|
|
6494
|
-
*
|
|
6495
|
-
*
|
|
8620
|
+
* Returns a round with another player's predictions instead of the current
|
|
8621
|
+
* user's. The target player is identified by `int_user_id` (the Game Pick
|
|
8622
|
+
* system's internal user ID, obtained from {@link gamePickGetBoard}'s
|
|
8623
|
+
* `users[].int_user_id`).
|
|
8624
|
+
*
|
|
8625
|
+
* Use to power "view this player's picks" affordances opened from leaderboard
|
|
8626
|
+
* rows — community / social inspection of how a top-ranked user predicted.
|
|
8627
|
+
*
|
|
8628
|
+
* @remarks
|
|
8629
|
+
* **Preconditions**
|
|
8630
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
8631
|
+
* - `saw_template_id`, `round_id`, and `int_user_id` are all mandatory — SDK
|
|
8632
|
+
* throws synchronously if any is missing.
|
|
8633
|
+
* - `int_user_id` must come from a leaderboard fetch in the same game
|
|
8634
|
+
* template; it is stable within a template but not portable across
|
|
8635
|
+
* templates.
|
|
8636
|
+
*
|
|
8637
|
+
* **Shape vs `gamePickGetActiveRound`**
|
|
8638
|
+
* Same {@link GamePickRound} structure, but `user_selection` /
|
|
8639
|
+
* `team1_user_selection` / `team2_user_selection` reflect the TARGET user's
|
|
8640
|
+
* predictions instead of the caller's. Each event still carries its own
|
|
8641
|
+
* `resolution_type_id` (see {@link GamePickResolutionType}) so the UI can
|
|
8642
|
+
* render result badges per pick.
|
|
8643
|
+
*
|
|
8644
|
+
* **Error codes** (in `errCode`)
|
|
8645
|
+
* - `0` — success.
|
|
8646
|
+
* - `4` — round / event / user not found.
|
|
8647
|
+
* - `100002` — template not found.
|
|
8648
|
+
* - `100000` — auth hash invalid.
|
|
8649
|
+
* - `100004` — generic server error.
|
|
8650
|
+
*
|
|
8651
|
+
* **Refresh**
|
|
8652
|
+
* - No cache. Re-call when opening a different leaderboard row's
|
|
8653
|
+
* "view picks" modal.
|
|
8654
|
+
* - No push subscription.
|
|
8655
|
+
*
|
|
8656
|
+
* **Visitor mode**: not supported.
|
|
8657
|
+
*
|
|
8658
|
+
* **UI guidance**: see [UI Guide — `gamePickGetRoundInfoForUser`](../../docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md).
|
|
8659
|
+
*
|
|
8660
|
+
* @param props.saw_template_id ID of the MatchX or Quiz game template.
|
|
8661
|
+
* @param props.round_id ID of the round to inspect.
|
|
8662
|
+
* @param props.int_user_id Internal user ID from
|
|
8663
|
+
* `gamePickGetBoard.users[].int_user_id`.
|
|
8664
|
+
* @returns Wrapped {@link GamesApiResponse} with the target user's
|
|
8665
|
+
* {@link GamePickRound}.
|
|
8666
|
+
*
|
|
8667
|
+
* @example
|
|
8668
|
+
* ```ts
|
|
8669
|
+
* const board = await window._smartico.api.gamePickGetBoard({
|
|
8670
|
+
* saw_template_id: 1083, round_id: 31652,
|
|
6496
8671
|
* });
|
|
6497
|
-
*
|
|
8672
|
+
* const topPlayer = board.data?.users?.[0];
|
|
8673
|
+
* if (!topPlayer) return;
|
|
6498
8674
|
*
|
|
6499
|
-
*
|
|
8675
|
+
* const r = await window._smartico.api.gamePickGetRoundInfoForUser({
|
|
8676
|
+
* saw_template_id: 1083,
|
|
8677
|
+
* round_id: 31652,
|
|
8678
|
+
* int_user_id: topPlayer.int_user_id,
|
|
8679
|
+
* });
|
|
8680
|
+
*
|
|
8681
|
+
* if (r.errCode === 0 && r.data) {
|
|
8682
|
+
* for (const ev of r.data.events) {
|
|
8683
|
+
* console.log('[smartico] render row —', ev.event_meta.team1_name, 'vs', ev.event_meta.team2_name, '— picked:', ev.user_selection, '— resolution:', ev.resolution_type_id);
|
|
8684
|
+
* }
|
|
8685
|
+
* }
|
|
8686
|
+
* ```
|
|
6500
8687
|
*/
|
|
6501
8688
|
;
|
|
6502
8689
|
_proto.gamePickGetRoundInfoForUser = function gamePickGetRoundInfoForUser(props) {
|
|
@@ -6527,21 +8714,135 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
|
|
|
6527
8714
|
_inheritsLoose(WSAPILeaderBoard, _WSAPIGamePick);
|
|
6528
8715
|
var _proto = WSAPILeaderBoard.prototype;
|
|
6529
8716
|
/**
|
|
6530
|
-
* Returns the
|
|
6531
|
-
*
|
|
8717
|
+
* Returns the operator-configured standalone leaderboard for the
|
|
8718
|
+
* given period type — top-20 ranked entries, the current user's
|
|
8719
|
+
* own entry (when authenticated), and the configured prize table.
|
|
8720
|
+
* Use this to power a leaderboard page with daily / weekly /
|
|
8721
|
+
* monthly tabs.
|
|
6532
8722
|
*
|
|
6533
|
-
*
|
|
6534
|
-
*
|
|
6535
|
-
*
|
|
6536
|
-
* console.log(result);
|
|
6537
|
-
* });
|
|
6538
|
-
* ```
|
|
8723
|
+
* The leaderboard for each period type is configured separately by
|
|
8724
|
+
* the operator. A label may have any combination of DAILY, WEEKLY,
|
|
8725
|
+
* and MONTHLY boards configured (or none).
|
|
6539
8726
|
*
|
|
6540
|
-
*
|
|
6541
|
-
*
|
|
6542
|
-
*
|
|
6543
|
-
*
|
|
6544
|
-
*
|
|
8727
|
+
* @remarks
|
|
8728
|
+
* **Return value note** — the runtime may return `undefined` if no
|
|
8729
|
+
* board is configured for the requested `periodType`, despite the
|
|
8730
|
+
* static return type being `Promise<LeaderBoardDetailsT>`. Defend
|
|
8731
|
+
* against that case in consumer code.
|
|
8732
|
+
*
|
|
8733
|
+
* **Preconditions**
|
|
8734
|
+
* Pass a `periodType` from {@link LeaderBoardPeriodType}
|
|
8735
|
+
* (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
|
|
8736
|
+
* `getPreviousPeriod: true` to fetch the most-recently-ended
|
|
8737
|
+
* period's snapshot (yesterday's results, last week's results,
|
|
8738
|
+
* last month's results) instead of the current live period. The
|
|
8739
|
+
* SDK only exposes one period back — older snapshots are not
|
|
8740
|
+
* reachable through this method.
|
|
8741
|
+
*
|
|
8742
|
+
* **Top-20 cap**
|
|
8743
|
+
* The server hard-caps `users[]` at 20 entries, ordered by
|
|
8744
|
+
* `position` ASC. Position values are server-computed (DENSE_RANK
|
|
8745
|
+
* over all participants); the truncation at 20 is for transport
|
|
8746
|
+
* size only — `position` may exceed 20 elsewhere.
|
|
8747
|
+
*
|
|
8748
|
+
* **The `me` field**
|
|
8749
|
+
* Always populated for authenticated users (even when they have
|
|
8750
|
+
* zero points in the period). `me.position === -1` is the signal
|
|
8751
|
+
* that the user is active but ranked outside the top 20 (or has no
|
|
8752
|
+
* activity yet). `me` is `undefined` for visitor-mode sessions.
|
|
8753
|
+
*
|
|
8754
|
+
* **Rewards are points only**
|
|
8755
|
+
* `rewards[].points` are gamification points credited to the user's
|
|
8756
|
+
* balance when the period finalizes. The leaderboard never awards
|
|
8757
|
+
* gems, diamonds, store items, or bonuses. The first element of
|
|
8758
|
+
* the array is the prize for place 1, the second for place 2, and
|
|
8759
|
+
* so on. The array length is the number of paid places.
|
|
8760
|
+
*
|
|
8761
|
+
* **Cache TTL — single shared key (known limitation)**
|
|
8762
|
+
* The SDK caches the response for 30 seconds under a SINGLE shared
|
|
8763
|
+
* key — calling `getLeaderBoard(DAILY)` followed by
|
|
8764
|
+
* `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
|
|
8765
|
+
* cached DAILY result for the WEEKLY call. Same applies to
|
|
8766
|
+
* switching `getPreviousPeriod`. To force a fresh fetch when
|
|
8767
|
+
* switching periods or current/previous, call
|
|
8768
|
+
* `_smartico.api.clearCaches()` before the second call, or simply
|
|
8769
|
+
* wait out the TTL.
|
|
8770
|
+
*
|
|
8771
|
+
* **Period boundaries**
|
|
8772
|
+
* The server finalizes each period on a server-configurable
|
|
8773
|
+
* schedule: DAILY at midnight + operator-defined offset; WEEKLY
|
|
8774
|
+
* at the start of Monday; MONTHLY on the 1st of each month. At
|
|
8775
|
+
* finalization, the server distributes the configured `rewards[]`
|
|
8776
|
+
* points to the top placeholders and resets the live board. After
|
|
8777
|
+
* finalization, `getLeaderBoard(periodType, false)` returns the
|
|
8778
|
+
* NEW (empty) period's board; call with
|
|
8779
|
+
* `getPreviousPeriod: true` to see the just-ended standings.
|
|
8780
|
+
*
|
|
8781
|
+
* **Refresh model**
|
|
8782
|
+
* - One-shot fetch (no subscription).
|
|
8783
|
+
* - No push event refreshes the cache; finalization at the period
|
|
8784
|
+
* boundary is NOT pushed to the client.
|
|
8785
|
+
* - Poll manually if the consumer needs near-live state during an
|
|
8786
|
+
* in-progress period.
|
|
8787
|
+
*
|
|
8788
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
8789
|
+
*
|
|
8790
|
+
* **UI guidance**: see [UI Guide — `getLeaderBoard`](../../docs/ui/leaderboard/UIGuide_getLeaderBoard.md).
|
|
8791
|
+
*
|
|
8792
|
+
* **Visitor mode**: supported. The same shape is returned, scoped
|
|
8793
|
+
* to the brand's public leaderboard. `me` is `undefined` for
|
|
8794
|
+
* visitors.
|
|
8795
|
+
*
|
|
8796
|
+
* @param periodType The board's period type
|
|
8797
|
+
* ({@link LeaderBoardPeriodType}).
|
|
8798
|
+
* Selects which pre-configured board to
|
|
8799
|
+
* fetch; the board itself is bound to one
|
|
8800
|
+
* period by the operator.
|
|
8801
|
+
* @param getPreviousPeriod When `true`, returns the most recent
|
|
8802
|
+
* finalized snapshot for that period type
|
|
8803
|
+
* (e.g. last week's results). Defaults to
|
|
8804
|
+
* `false` (current in-progress period).
|
|
8805
|
+
* @returns Promise resolving to `LeaderBoardDetailsT`.
|
|
8806
|
+
* **At runtime, may resolve to `undefined`**
|
|
8807
|
+
* when no board is configured for the
|
|
8808
|
+
* requested period type — guard against it.
|
|
8809
|
+
*
|
|
8810
|
+
* @example
|
|
8811
|
+
* ```ts
|
|
8812
|
+
* import { LeaderBoardPeriodType } from '@smartico/public-api';
|
|
8813
|
+
*
|
|
8814
|
+
* const board = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY);
|
|
8815
|
+
*
|
|
8816
|
+
* if (!board) {
|
|
8817
|
+
* console.log('[smartico] no weekly board configured for this label — hide the leaderboard surface');
|
|
8818
|
+
* return;
|
|
8819
|
+
* }
|
|
8820
|
+
*
|
|
8821
|
+
* console.log('[smartico] render leaderboard tab —', board.name, '—', board.users.length, 'ranked entries (top 20 max)');
|
|
8822
|
+
*
|
|
8823
|
+
* // Render prize table.
|
|
8824
|
+
* for (const reward of board.rewards) {
|
|
8825
|
+
* console.log('[smartico] prize row — place', reward.place, '→', reward.points, 'points');
|
|
8826
|
+
* }
|
|
8827
|
+
*
|
|
8828
|
+
* // "Me" panel — sticky row showing the current user's rank.
|
|
8829
|
+
* if (board.me) {
|
|
8830
|
+
* if (board.me.position === -1) {
|
|
8831
|
+
* console.log('[smartico] user is unranked — show "You are unranked, earn points to enter the leaderboard"');
|
|
8832
|
+
* } else if (board.me.position > 20) {
|
|
8833
|
+
* console.log('[smartico] user is ranked', board.me.position, 'but outside the visible top-20 — show sticky "me" row with', board.me.points, 'points');
|
|
8834
|
+
* } else {
|
|
8835
|
+
* console.log('[smartico] user is in the top 20 at position', board.me.position, '— highlight their row in the main list');
|
|
8836
|
+
* }
|
|
8837
|
+
* }
|
|
8838
|
+
*
|
|
8839
|
+
* // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
|
|
8840
|
+
* await window._smartico.api.clearCaches();
|
|
8841
|
+
* const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
|
|
8842
|
+
* console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
|
|
8843
|
+
*
|
|
8844
|
+
* // Visitor-mode equivalent — me is always undefined.
|
|
8845
|
+
* // const visitorBoard = await window._smartico.vapi('EN').getLeaderBoard(LeaderBoardPeriodType.DAILY);
|
|
6545
8846
|
* ```
|
|
6546
8847
|
*/
|
|
6547
8848
|
_proto.getLeaderBoard = function getLeaderBoard(periodType, getPreviousPeriod) {
|
|
@@ -6565,23 +8866,49 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6565
8866
|
_inheritsLoose(WSAPIInbox, _WSAPILeaderBoard);
|
|
6566
8867
|
var _proto = WSAPIInbox.prototype;
|
|
6567
8868
|
/**
|
|
6568
|
-
*
|
|
6569
|
-
* Use this
|
|
6570
|
-
*
|
|
8869
|
+
* Records that an engagement (inbox message, popup) was displayed to
|
|
8870
|
+
* the user. Use this to drive engagement analytics — every visible
|
|
8871
|
+
* inbox message should fire one impression event per render
|
|
8872
|
+
* occurrence, and every popup display should fire one.
|
|
6571
8873
|
*
|
|
6572
|
-
* **
|
|
6573
|
-
*
|
|
6574
|
-
*
|
|
6575
|
-
* engagement_uid: 'abc123-def456',
|
|
6576
|
-
* activityType: 31 // Inbox
|
|
6577
|
-
* });
|
|
6578
|
-
* ```
|
|
8874
|
+
* **Fire-and-forget**: the call is asynchronous and one-way — there
|
|
8875
|
+
* is no response promise to await and no error reporting. The SDK
|
|
8876
|
+
* swallows transport failures silently. Returns `void`.
|
|
6579
8877
|
*
|
|
6580
|
-
*
|
|
8878
|
+
* @remarks
|
|
8879
|
+
* **When to call**
|
|
8880
|
+
* - Inbox: when a message becomes visible (the user opens / scrolls
|
|
8881
|
+
* it into view). The default Smartico UI fires this when the
|
|
8882
|
+
* message detail expands, alongside
|
|
8883
|
+
* {@link markInboxMessageAsRead}.
|
|
8884
|
+
* - Popup: when the popup content is shown to the user.
|
|
8885
|
+
*
|
|
8886
|
+
* **Activity types**
|
|
8887
|
+
* Pass {@link ActivityTypeLimited.Inbox} (`31`) for inbox messages,
|
|
8888
|
+
* {@link ActivityTypeLimited.Popup} (`30`) for popups. Other values
|
|
8889
|
+
* are not used by the engagement-impression channel.
|
|
8890
|
+
*
|
|
8891
|
+
* **Idempotency**: the server records every impression event —
|
|
8892
|
+
* repeated calls add to the impression count. Don't fire it on
|
|
8893
|
+
* every re-render; fire it once per logical "display" event
|
|
8894
|
+
* (modal open, list-row scroll-into-view, popup show).
|
|
8895
|
+
*
|
|
8896
|
+
* **Side effects**: server-side increments the engagement's
|
|
8897
|
+
* `impression_count` and updates `last_impression_date`. The
|
|
8898
|
+
* counter is observable via operator analytics; the SDK consumer
|
|
8899
|
+
* receives no signal back.
|
|
8900
|
+
*
|
|
8901
|
+
* **Visitor mode**: not supported.
|
|
6581
8902
|
*
|
|
6582
|
-
* @
|
|
6583
|
-
*
|
|
6584
|
-
*
|
|
8903
|
+
* @example
|
|
8904
|
+
* ```ts
|
|
8905
|
+
* // When the user opens an inbox message in the detail view.
|
|
8906
|
+
* window._smartico.api.reportImpressionEvent({
|
|
8907
|
+
* engagement_uid: message.message_guid,
|
|
8908
|
+
* activityType: 31, // ActivityTypeLimited.Inbox
|
|
8909
|
+
* });
|
|
8910
|
+
* console.log('[smartico] inbox impression reported for', message.message_guid, '— no response to await, fire-and-forget');
|
|
8911
|
+
* ```
|
|
6585
8912
|
*/
|
|
6586
8913
|
_proto.reportImpressionEvent = function reportImpressionEvent(_ref) {
|
|
6587
8914
|
var engagement_uid = _ref.engagement_uid,
|
|
@@ -6589,25 +8916,54 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6589
8916
|
this.api.reportEngagementImpression(this.userExtId, engagement_uid, activityType);
|
|
6590
8917
|
}
|
|
6591
8918
|
/**
|
|
6592
|
-
*
|
|
6593
|
-
*
|
|
6594
|
-
*
|
|
8919
|
+
* Records that the user interacted with an engagement — typically
|
|
8920
|
+
* tapping a CTA button, following a deep-link, or clicking a popup
|
|
8921
|
+
* action. Use this to drive engagement analytics on what users
|
|
8922
|
+
* actually act on (vs what they merely see —
|
|
8923
|
+
* {@link reportImpressionEvent}).
|
|
6595
8924
|
*
|
|
6596
|
-
* **
|
|
6597
|
-
*
|
|
6598
|
-
*
|
|
6599
|
-
* engagement_uid: 'abc123-def456',
|
|
6600
|
-
* activityType: 31 // Inbox
|
|
6601
|
-
* action: 'dp:gf_missions'
|
|
6602
|
-
* });
|
|
6603
|
-
* ```
|
|
8925
|
+
* **Fire-and-forget**: the call is asynchronous and one-way — there
|
|
8926
|
+
* is no response promise to await and no error reporting. The SDK
|
|
8927
|
+
* swallows transport failures silently. Returns `void`.
|
|
6604
8928
|
*
|
|
6605
|
-
*
|
|
8929
|
+
* @remarks
|
|
8930
|
+
* **When to call**
|
|
8931
|
+
* - Inbox: when the user taps a CTA button on a message or follows
|
|
8932
|
+
* a deep-link inside the message body. Pass the deep-link or URL
|
|
8933
|
+
* as `action`.
|
|
8934
|
+
* - Popup: when the user clicks a popup action button.
|
|
8935
|
+
*
|
|
8936
|
+
* **Activity types**
|
|
8937
|
+
* Pass {@link ActivityTypeLimited.Inbox} (`31`) for inbox,
|
|
8938
|
+
* {@link ActivityTypeLimited.Popup} (`30`) for popups.
|
|
8939
|
+
*
|
|
8940
|
+
* **`action` payload**
|
|
8941
|
+
* Pass the deep-link or URL that the user triggered (e.g.
|
|
8942
|
+
* `'dp:gf_missions'`, `'https://example.com/promo'`). The SDK
|
|
8943
|
+
* forwards the string to the server for analytics — it does not
|
|
8944
|
+
* execute the deep-link. To execute deep-links safely, call
|
|
8945
|
+
* `_smartico.dp(action)` separately.
|
|
8946
|
+
*
|
|
8947
|
+
* **Idempotency**: the server records every click event —
|
|
8948
|
+
* repeated calls add to the count. Fire once per logical user
|
|
8949
|
+
* action.
|
|
8950
|
+
*
|
|
8951
|
+
* **Side effects**: server-side updates the engagement's
|
|
8952
|
+
* `last_action` field; observable via operator analytics. The SDK
|
|
8953
|
+
* consumer receives no signal back.
|
|
6606
8954
|
*
|
|
6607
|
-
*
|
|
6608
|
-
*
|
|
6609
|
-
* @
|
|
6610
|
-
*
|
|
8955
|
+
* **Visitor mode**: not supported.
|
|
8956
|
+
*
|
|
8957
|
+
* @example
|
|
8958
|
+
* ```ts
|
|
8959
|
+
* // When the user taps a CTA button in an inbox message.
|
|
8960
|
+
* window._smartico.api.reportClickEvent({
|
|
8961
|
+
* engagement_uid: message.message_guid,
|
|
8962
|
+
* activityType: 31, // ActivityTypeLimited.Inbox
|
|
8963
|
+
* action: 'dp:gf_missions',
|
|
8964
|
+
* });
|
|
8965
|
+
* window._smartico.dp('dp:gf_missions'); // separately execute the deep-link
|
|
8966
|
+
* ```
|
|
6611
8967
|
*/;
|
|
6612
8968
|
_proto.reportClickEvent = function reportClickEvent(_ref2) {
|
|
6613
8969
|
var engagement_uid = _ref2.engagement_uid,
|
|
@@ -6615,19 +8971,118 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6615
8971
|
action = _ref2.action;
|
|
6616
8972
|
this.api.reportEngagementAction(this.userExtId, engagement_uid, activityType, action);
|
|
6617
8973
|
}
|
|
6618
|
-
/**
|
|
6619
|
-
*
|
|
6620
|
-
*
|
|
6621
|
-
*
|
|
6622
|
-
*
|
|
6623
|
-
*
|
|
6624
|
-
*
|
|
6625
|
-
* All other action like mark as read, favorite, delete, etc. can be done using this message GUID.
|
|
6626
|
-
* The "onUpdate" callback will be triggered when the user receives a new message. It will provide an updated list of messages, ranging from 0 to 20, to the onUpdate callback function.
|
|
8974
|
+
/**
|
|
8975
|
+
* Returns the user's inbox messages — newest first — with optional
|
|
8976
|
+
* filtering by category, favorite status, and read state. Each
|
|
8977
|
+
* `TInboxMessage` is a lightweight envelope (`message_guid`,
|
|
8978
|
+
* `sent_date`, `read`, `favorite`, `category_id`, `expire_on_dt`);
|
|
8979
|
+
* fetch the rich body (title, preview, icon, html_body, buttons)
|
|
8980
|
+
* separately via {@link getInboxMessageBody}.
|
|
6627
8981
|
*
|
|
6628
|
-
*
|
|
8982
|
+
* Use this to power an inbox list screen. Subscribe via `onUpdate`
|
|
8983
|
+
* to react to newly-arrived messages pushed by the server (from
|
|
8984
|
+
* campaigns, automation rules, manual operator sends).
|
|
8985
|
+
*
|
|
8986
|
+
* @remarks
|
|
8987
|
+
* **Subscription model (`onUpdate`)**
|
|
8988
|
+
* The callback receives the FULL refreshed message list (never a
|
|
8989
|
+
* diff/patch). Each subsequent call to `getInboxMessages({ onUpdate })`
|
|
8990
|
+
* REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
|
|
8991
|
+
* it) to keep the prior callback in place; the callback is never
|
|
8992
|
+
* auto-cleared.
|
|
8993
|
+
*
|
|
8994
|
+
* **Update triggers** — the callback fires ONLY when:
|
|
8995
|
+
*
|
|
8996
|
+
* 1. A new message is pushed by the server (campaign / automation /
|
|
8997
|
+
* operator send). The refreshed list includes the new message
|
|
8998
|
+
* at the top.
|
|
8999
|
+
*
|
|
9000
|
+
* Does NOT fire for: `markInboxMessageAsRead`,
|
|
9001
|
+
* `markAllInboxMessagesAsRead`,
|
|
9002
|
+
* `markUnmarkInboxMessageAsFavorite`, `deleteInboxMessage`,
|
|
9003
|
+
* `deleteAllInboxMessages`. After a mutation, re-call
|
|
9004
|
+
* `getInboxMessages` manually if your UI needs the refreshed list
|
|
9005
|
+
* — or maintain optimistic state locally.
|
|
9006
|
+
*
|
|
9007
|
+
* **Pagination**
|
|
9008
|
+
* `from` (defaults to `0`) and `to` (defaults to `20`) define a
|
|
9009
|
+
* half-open range of message indices. The server caps the page at
|
|
9010
|
+
* **20 messages per request** — passing `to - from > 20` silently
|
|
9011
|
+
* truncates to 20. For "load more" pagination, advance `from` by
|
|
9012
|
+
* the prior page size on each subsequent call.
|
|
9013
|
+
*
|
|
9014
|
+
* **Filters**
|
|
9015
|
+
* All filters are ANDed server-side. Omitting a filter means "no
|
|
9016
|
+
* constraint" on that dimension:
|
|
9017
|
+
* - `categoryId` ({@link InboxCategories}): `General` (0),
|
|
9018
|
+
* `Platform` (1), `Personal` (2). Omit to get all categories.
|
|
9019
|
+
* - `onlyFavorite: true` returns only starred messages.
|
|
9020
|
+
* Omit / `false` returns all (starred and not).
|
|
9021
|
+
* - `read_status` ({@link InboxReadStatus}): `UnreadOnly` (1) or
|
|
9022
|
+
* `ReadOnly` (2). Omit to get both.
|
|
9023
|
+
*
|
|
9024
|
+
* **Server-side filtering** (always applied)
|
|
9025
|
+
* Expired messages (`expire_on_dt` in the past) and
|
|
9026
|
+
* soft-deleted messages are excluded server-side. Consumers do not
|
|
9027
|
+
* need to filter for these.
|
|
9028
|
+
*
|
|
9029
|
+
* **No client cache**: every call sends a fresh server round-trip.
|
|
9030
|
+
* To avoid redundant fetches in your UI, hold the result in
|
|
9031
|
+
* application state and re-fetch on `onUpdate` fires or explicit
|
|
9032
|
+
* user-driven refresh.
|
|
9033
|
+
*
|
|
9034
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
9035
|
+
*
|
|
9036
|
+
* **UI guidance**: see [UI Guide — `getInboxMessages`](../../docs/ui/inbox/UIGuide_getInboxMessages.md).
|
|
9037
|
+
*
|
|
9038
|
+
* **Visitor mode**: not supported.
|
|
9039
|
+
*
|
|
9040
|
+
* @param params Optional filters + subscription.
|
|
9041
|
+
* @param params.from First message index (0-based). Defaults
|
|
9042
|
+
* to `0`.
|
|
9043
|
+
* @param params.to Last message index (exclusive).
|
|
9044
|
+
* Defaults to `20`. Server caps the page
|
|
9045
|
+
* at 20.
|
|
9046
|
+
* @param params.onlyFavorite When `true`, returns only favorite
|
|
9047
|
+
* (starred) messages.
|
|
9048
|
+
* @param params.categoryId When set, returns only messages in this
|
|
9049
|
+
* category ({@link InboxCategories}).
|
|
9050
|
+
* @param params.read_status When set, scopes to read or unread
|
|
9051
|
+
* only ({@link InboxReadStatus}).
|
|
9052
|
+
* @param params.onUpdate Callback invoked with the full
|
|
9053
|
+
* refreshed list when a new message
|
|
9054
|
+
* arrives.
|
|
9055
|
+
*
|
|
9056
|
+
* @returns Promise resolving to up to 20 `TInboxMessage` envelopes.
|
|
9057
|
+
* Empty array when the user has no messages matching the
|
|
9058
|
+
* filter.
|
|
9059
|
+
*
|
|
9060
|
+
* @example
|
|
9061
|
+
* ```ts
|
|
9062
|
+
* const messages = await window._smartico.api.getInboxMessages({
|
|
9063
|
+
* onUpdate: (refreshed) => {
|
|
9064
|
+
* console.log('[smartico] new inbox message arrived — re-render the list from this array, new message is at index 0:', refreshed);
|
|
9065
|
+
* },
|
|
9066
|
+
* });
|
|
6629
9067
|
*
|
|
6630
|
-
*
|
|
9068
|
+
* // For each message, fetch its body for the list view (title, preview, icon).
|
|
9069
|
+
* for (const msg of messages) {
|
|
9070
|
+
* const body = await window._smartico.api.getInboxMessageBody(msg.message_guid);
|
|
9071
|
+
* console.log('[smartico] render message', msg.message_guid,
|
|
9072
|
+
* '— title:', body.title,
|
|
9073
|
+
* '— preview:', body.preview_body,
|
|
9074
|
+
* '— read:', msg.read,
|
|
9075
|
+
* '— favorite:', msg.favorite);
|
|
9076
|
+
* }
|
|
9077
|
+
*
|
|
9078
|
+
* // "Load more" pagination — advance from by the prior page size.
|
|
9079
|
+
* const page2 = await window._smartico.api.getInboxMessages({ from: 20, to: 40 });
|
|
9080
|
+
* console.log('[smartico] page 2:', page2.length, 'messages');
|
|
9081
|
+
*
|
|
9082
|
+
* // Filter examples.
|
|
9083
|
+
* const onlyStarred = await window._smartico.api.getInboxMessages({ onlyFavorite: true });
|
|
9084
|
+
* const onlyUnread = await window._smartico.api.getInboxMessages({ read_status: 1 }); // InboxReadStatus.UnreadOnly
|
|
9085
|
+
* ```
|
|
6631
9086
|
*/;
|
|
6632
9087
|
_proto.getInboxMessages = function getInboxMessages(_temp) {
|
|
6633
9088
|
var _ref3 = _temp === void 0 ? {} : _temp,
|
|
@@ -6648,10 +9103,53 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6648
9103
|
}
|
|
6649
9104
|
}
|
|
6650
9105
|
/**
|
|
6651
|
-
* Returns
|
|
9106
|
+
* Returns the user's current unread inbox message count — a single
|
|
9107
|
+
* integer suitable for driving a header badge. Optionally subscribe
|
|
9108
|
+
* to live updates via `onUpdate`.
|
|
6652
9109
|
*
|
|
6653
|
-
*
|
|
6654
|
-
* @
|
|
9110
|
+
* For most UIs, prefer `core_inbox_unread_count` from
|
|
9111
|
+
* {@link getUserProfile} instead: it carries the same value, is
|
|
9112
|
+
* push-updated in real time via the user-properties channel, and
|
|
9113
|
+
* doesn't require a separate cache. This method is useful when you
|
|
9114
|
+
* want a dedicated subscription tied to the inbox surface rather
|
|
9115
|
+
* than the broader user-properties channel.
|
|
9116
|
+
*
|
|
9117
|
+
* @remarks
|
|
9118
|
+
* **Subscription model**
|
|
9119
|
+
* `onUpdate` fires whenever the cached value changes — either on a
|
|
9120
|
+
* push from the user-properties channel (new message arrival,
|
|
9121
|
+
* mark-as-read, delete) or after an inbox-list fetch that returns
|
|
9122
|
+
* a fresh count.
|
|
9123
|
+
*
|
|
9124
|
+
* **Cache TTL**: 30 seconds. The cached value is patched in place
|
|
9125
|
+
* by push events (no full re-fetch on every push), so the
|
|
9126
|
+
* `onUpdate` callback reflects server state with sub-second latency
|
|
9127
|
+
* regardless of the TTL.
|
|
9128
|
+
*
|
|
9129
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
9130
|
+
*
|
|
9131
|
+
* **Visitor mode**: not supported.
|
|
9132
|
+
*
|
|
9133
|
+
* @param params Optional subscription bag.
|
|
9134
|
+
* @param params.onUpdate Callback invoked with the new unread
|
|
9135
|
+
* count whenever it changes (push-driven).
|
|
9136
|
+
* @returns Promise resolving to the current unread
|
|
9137
|
+
* count (integer, includes `0`).
|
|
9138
|
+
*
|
|
9139
|
+
* @example
|
|
9140
|
+
* ```ts
|
|
9141
|
+
* // Static read for an initial badge render.
|
|
9142
|
+
* const count = await window._smartico.api.getInboxUnreadCount();
|
|
9143
|
+
* console.log('[smartico] inbox badge initial count:', count);
|
|
9144
|
+
*
|
|
9145
|
+
* // Live subscription for badge updates.
|
|
9146
|
+
* await window._smartico.api.getInboxUnreadCount({
|
|
9147
|
+
* onUpdate: (newCount) => {
|
|
9148
|
+
* console.log('[smartico] inbox count changed — update the badge to:', newCount,
|
|
9149
|
+
* '— hide badge entirely when 0, show raw integer otherwise (no "99+" cap in the default UI)');
|
|
9150
|
+
* },
|
|
9151
|
+
* });
|
|
9152
|
+
* ```
|
|
6655
9153
|
*/
|
|
6656
9154
|
;
|
|
6657
9155
|
_proto.getInboxUnreadCount = function getInboxUnreadCount(_temp2) {
|
|
@@ -6670,9 +9168,62 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6670
9168
|
}
|
|
6671
9169
|
}
|
|
6672
9170
|
/**
|
|
6673
|
-
* Returns the
|
|
9171
|
+
* Returns the rich body of a single inbox message — title, preview
|
|
9172
|
+
* text, icon, click action, optional rich HTML body, and optional
|
|
9173
|
+
* buttons. Call this after fetching the envelope list via
|
|
9174
|
+
* {@link getInboxMessages} to render either a list-item preview or
|
|
9175
|
+
* a full detail view.
|
|
9176
|
+
*
|
|
9177
|
+
* The message body is served from a CDN — not over the WebSocket —
|
|
9178
|
+
* so latency depends on CDN proximity rather than WS round-trip
|
|
9179
|
+
* time. There is NO client-side cache; every call is a fresh
|
|
9180
|
+
* HTTP fetch. Browser HTTP caching applies (Cache-Control headers
|
|
9181
|
+
* from the CDN), but the SDK does not memoize the result.
|
|
6674
9182
|
*
|
|
6675
|
-
*
|
|
9183
|
+
* @remarks
|
|
9184
|
+
* **Rich vs simple messages**
|
|
9185
|
+
* The shape of the returned body branches on the `action` field:
|
|
9186
|
+
* - When `action === 'dp:inbox'`, the message has a rich HTML body
|
|
9187
|
+
* (`html_body`) and may have up to 2 action `buttons`. Use these
|
|
9188
|
+
* for a full-detail rendering.
|
|
9189
|
+
* - For any other `action` (deep-link like `'dp:deposit'` or a URL),
|
|
9190
|
+
* the message is a simple notification — `html_body` and
|
|
9191
|
+
* `buttons` will be `undefined` regardless of what's in the
|
|
9192
|
+
* underlying CDN payload. Render `title` + `preview_body` + a
|
|
9193
|
+
* single CTA driving the `action`.
|
|
9194
|
+
*
|
|
9195
|
+
* **The `action` field**
|
|
9196
|
+
* For both shapes, `action` carries either a deep-link
|
|
9197
|
+
* (`'dp:gf_missions'`) or a plain URL. Pass it to `_smartico.dp()`
|
|
9198
|
+
* for safe execution — that helper handles URL vs deep-link
|
|
9199
|
+
* routing.
|
|
9200
|
+
*
|
|
9201
|
+
* **Idempotency / Side effects**: safe. Read-only HTTP fetch.
|
|
9202
|
+
*
|
|
9203
|
+
* **UI guidance**: see [UI Guide — `getInboxMessageBody`](../../docs/ui/inbox/UIGuide_getInboxMessageBody.md).
|
|
9204
|
+
*
|
|
9205
|
+
* **Visitor mode**: not supported.
|
|
9206
|
+
*
|
|
9207
|
+
* @param messageGuid The `message_guid` from a `TInboxMessage`
|
|
9208
|
+
* returned by {@link getInboxMessages}.
|
|
9209
|
+
* @returns Promise resolving to `TInboxMessageBody`.
|
|
9210
|
+
*
|
|
9211
|
+
* @example
|
|
9212
|
+
* ```ts
|
|
9213
|
+
* const body = await window._smartico.api.getInboxMessageBody(messageGuid);
|
|
9214
|
+
*
|
|
9215
|
+
* console.log('[smartico] render message — title:', body.title,
|
|
9216
|
+
* '— preview:', body.preview_body,
|
|
9217
|
+
* '— icon:', body.icon);
|
|
9218
|
+
*
|
|
9219
|
+
* if (body.action === 'dp:inbox' && body.html_body) {
|
|
9220
|
+
* console.log('[smartico] rich message — render the html_body in a sandboxed iframe; render up to 2 action buttons:',
|
|
9221
|
+
* body.buttons?.length ?? 0);
|
|
9222
|
+
* } else {
|
|
9223
|
+
* console.log('[smartico] simple message — show preview_body + single CTA wired to:', body.action,
|
|
9224
|
+
* '— execute via _smartico.dp(body.action)');
|
|
9225
|
+
* }
|
|
9226
|
+
* ```
|
|
6676
9227
|
*/
|
|
6677
9228
|
;
|
|
6678
9229
|
_proto.getInboxMessageBody = function getInboxMessageBody(messageGuid) {
|
|
@@ -6684,9 +9235,52 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6684
9235
|
}
|
|
6685
9236
|
}
|
|
6686
9237
|
/**
|
|
6687
|
-
*
|
|
9238
|
+
* Marks a single inbox message as read. Server-side this flips the
|
|
9239
|
+
* message's `is_read` flag and decrements the user's unread count
|
|
9240
|
+
* (the change propagates back via the user-properties channel —
|
|
9241
|
+
* subscribers to {@link getInboxUnreadCount}'s `onUpdate` and
|
|
9242
|
+
* {@link getUserProfile}'s `core_inbox_unread_count` see it within
|
|
9243
|
+
* ~1 second).
|
|
6688
9244
|
*
|
|
6689
|
-
*
|
|
9245
|
+
* @remarks
|
|
9246
|
+
* **Error codes** (in `err_code`)
|
|
9247
|
+
* - `0` — success; the message is now marked read. Idempotent — a
|
|
9248
|
+
* second call on the same `messageGuid` also returns `0`.
|
|
9249
|
+
* - other non-zero — server error. Surface `err_message` if any.
|
|
9250
|
+
*
|
|
9251
|
+
* **Refresh after success**
|
|
9252
|
+
* The SDK does NOT auto-refresh {@link getInboxMessages} (no
|
|
9253
|
+
* `onUpdate` callback fires after this mutation). The unread-count
|
|
9254
|
+
* channel ({@link getInboxUnreadCount}, `core_inbox_unread_count`)
|
|
9255
|
+
* DOES auto-update — subscribers to it see the new count
|
|
9256
|
+
* automatically. If your inbox list UI shows the `read` field, you
|
|
9257
|
+
* have two options: re-call `getInboxMessages` after the mutation,
|
|
9258
|
+
* or update the local copy optimistically.
|
|
9259
|
+
*
|
|
9260
|
+
* **Idempotency**: safe. Repeated calls return `err_code === 0`.
|
|
9261
|
+
*
|
|
9262
|
+
* **Side effects** (on success)
|
|
9263
|
+
* - Server-side `is_read` flag set to true.
|
|
9264
|
+
* - Server-side `core_inbox_unread_count` decremented (if the
|
|
9265
|
+
* message was previously unread).
|
|
9266
|
+
*
|
|
9267
|
+
* **UI guidance**: see [UI Guide — `markInboxMessageAsRead`](../../docs/ui/inbox/UIGuide_markInboxMessageAsRead.md).
|
|
9268
|
+
*
|
|
9269
|
+
* **Visitor mode**: not supported.
|
|
9270
|
+
*
|
|
9271
|
+
* @param messageGuid The `message_guid` from a `TInboxMessage`.
|
|
9272
|
+
* @returns `{ err_code, err_message }`; success when
|
|
9273
|
+
* `err_code === 0`.
|
|
9274
|
+
*
|
|
9275
|
+
* @example
|
|
9276
|
+
* ```ts
|
|
9277
|
+
* const r = await window._smartico.api.markInboxMessageAsRead(message.message_guid);
|
|
9278
|
+
* if (r.err_code === 0) {
|
|
9279
|
+
* console.log('[smartico] marked as read — optimistically flip the local read indicator; the inbox badge auto-decrements via the user-properties channel');
|
|
9280
|
+
* } else {
|
|
9281
|
+
* console.error('[smartico] mark-as-read failed — keep the local state as-is and show a non-blocking error if appropriate:', r.err_message);
|
|
9282
|
+
* }
|
|
9283
|
+
* ```
|
|
6690
9284
|
*/
|
|
6691
9285
|
;
|
|
6692
9286
|
_proto.markInboxMessageAsRead = function markInboxMessageAsRead(messageGuid) {
|
|
@@ -6703,9 +9297,57 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6703
9297
|
}
|
|
6704
9298
|
}
|
|
6705
9299
|
/**
|
|
6706
|
-
*
|
|
9300
|
+
* Marks ALL of the user's inbox messages as read in one server
|
|
9301
|
+
* round-trip — typically wired to a "Mark all as read" CTA in the
|
|
9302
|
+
* inbox header.
|
|
6707
9303
|
*
|
|
6708
|
-
*
|
|
9304
|
+
* The operation is global to the user — NOT filtered by the
|
|
9305
|
+
* current view (active category tab, favorite filter, etc.). Every
|
|
9306
|
+
* unread message in the user's inbox flips to read.
|
|
9307
|
+
*
|
|
9308
|
+
* @remarks
|
|
9309
|
+
* **Error codes** (in `err_code`)
|
|
9310
|
+
* - `0` — success; all currently-unread messages flipped to read.
|
|
9311
|
+
* - other non-zero — server error. Surface `err_message` if any.
|
|
9312
|
+
*
|
|
9313
|
+
* **Race condition note**: a new message arriving server-side
|
|
9314
|
+
* between the call and its processing remains unread (the
|
|
9315
|
+
* server's mark-all operation is a snapshot in time). Subsequent
|
|
9316
|
+
* `getInboxMessages` calls show the new message as unread.
|
|
9317
|
+
*
|
|
9318
|
+
* **Refresh after success**
|
|
9319
|
+
* Same as {@link markInboxMessageAsRead} — `getInboxMessages`
|
|
9320
|
+
* `onUpdate` does NOT fire automatically, but the unread-count
|
|
9321
|
+
* channel does (the badge will drop to 0, or to the count of any
|
|
9322
|
+
* new messages that arrived during processing).
|
|
9323
|
+
*
|
|
9324
|
+
* **Idempotency**: safe. A second call on an already-all-read
|
|
9325
|
+
* inbox returns `err_code === 0` with no-op effect.
|
|
9326
|
+
*
|
|
9327
|
+
* **Side effects** (on success)
|
|
9328
|
+
* - Every unread message flipped to read.
|
|
9329
|
+
* - `core_inbox_unread_count` drops to 0 (or near 0 if races).
|
|
9330
|
+
*
|
|
9331
|
+
* **UI guidance**: included in the
|
|
9332
|
+
* [UI Guide — `markInboxMessageAsRead`](../../docs/ui/inbox/UIGuide_markInboxMessageAsRead.md)
|
|
9333
|
+
* (Bulk variant section).
|
|
9334
|
+
*
|
|
9335
|
+
* **Visitor mode**: not supported.
|
|
9336
|
+
*
|
|
9337
|
+
* @returns `{ err_code, err_message }`; success when
|
|
9338
|
+
* `err_code === 0`.
|
|
9339
|
+
*
|
|
9340
|
+
* @example
|
|
9341
|
+
* ```ts
|
|
9342
|
+
* console.log('[smartico] mark-all-read starting — set in-flight flag on the "Mark all read" button, show loading dots');
|
|
9343
|
+
* const r = await window._smartico.api.markAllInboxMessagesAsRead();
|
|
9344
|
+
* console.log('[smartico] mark-all-read response — clear in-flight flag');
|
|
9345
|
+
* if (r.err_code === 0) {
|
|
9346
|
+
* console.log('[smartico] all messages marked read — optimistically flip every local read indicator; badge auto-drops via user-properties channel');
|
|
9347
|
+
* } else {
|
|
9348
|
+
* console.error('[smartico] mark-all failed — surface a non-blocking error:', r.err_message);
|
|
9349
|
+
* }
|
|
9350
|
+
* ```
|
|
6709
9351
|
*/
|
|
6710
9352
|
;
|
|
6711
9353
|
_proto.markAllInboxMessagesAsRead = function markAllInboxMessagesAsRead() {
|
|
@@ -6722,9 +9364,57 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6722
9364
|
}
|
|
6723
9365
|
}
|
|
6724
9366
|
/**
|
|
6725
|
-
*
|
|
9367
|
+
* Toggles a message's favorite (starred) state — pass `mark: true`
|
|
9368
|
+
* to favorite, `mark: false` to unfavorite. Use to power a star
|
|
9369
|
+
* icon click handler on the inbox list.
|
|
6726
9370
|
*
|
|
6727
|
-
*
|
|
9371
|
+
* @remarks
|
|
9372
|
+
* **Error codes** (in `err_code`)
|
|
9373
|
+
* - `0` — success; the message's favorite state flipped to the
|
|
9374
|
+
* requested value.
|
|
9375
|
+
* - other non-zero — server error. Surface `err_message` if any.
|
|
9376
|
+
*
|
|
9377
|
+
* **Refresh after success**
|
|
9378
|
+
* The SDK does NOT auto-refresh {@link getInboxMessages}. To
|
|
9379
|
+
* reflect the new state in the UI, update the local copy of the
|
|
9380
|
+
* affected `TInboxMessage` (set `favorite` to the new value) or
|
|
9381
|
+
* re-call `getInboxMessages`.
|
|
9382
|
+
*
|
|
9383
|
+
* **Idempotency**: safe. `mark: true` on an already-favorite
|
|
9384
|
+
* message returns `err_code === 0` (no-op). Same for `mark: false`
|
|
9385
|
+
* on a non-favorite.
|
|
9386
|
+
*
|
|
9387
|
+
* **Side effects** (on success)
|
|
9388
|
+
* - Server-side `is_starred` flag set to the requested value.
|
|
9389
|
+
* - No effect on read state, unread count, or other fields.
|
|
9390
|
+
*
|
|
9391
|
+
* **UI guidance**: see [UI Guide — `markUnmarkInboxMessageAsFavorite`](../../docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md).
|
|
9392
|
+
*
|
|
9393
|
+
* **Visitor mode**: not supported.
|
|
9394
|
+
*
|
|
9395
|
+
* @param messageGuid The `message_guid` from a `TInboxMessage`.
|
|
9396
|
+
* @param mark `true` to favorite, `false` to unfavorite.
|
|
9397
|
+
* @returns `{ err_code, err_message }`; success when
|
|
9398
|
+
* `err_code === 0`.
|
|
9399
|
+
*
|
|
9400
|
+
* @example
|
|
9401
|
+
* ```ts
|
|
9402
|
+
* // Toggle handler — flip the local state optimistically, then
|
|
9403
|
+
* // call the server, and revert if the call fails.
|
|
9404
|
+
* const target = !message.favorite;
|
|
9405
|
+
* console.log('[smartico] optimistically flip the star to', target, '— it will revert if the server rejects');
|
|
9406
|
+
*
|
|
9407
|
+
* const r = await window._smartico.api.markUnmarkInboxMessageAsFavorite(
|
|
9408
|
+
* message.message_guid,
|
|
9409
|
+
* target,
|
|
9410
|
+
* );
|
|
9411
|
+
*
|
|
9412
|
+
* if (r.err_code === 0) {
|
|
9413
|
+
* console.log('[smartico] favorite toggled — keep the local state and show a brief "Added to favorites" / "Removed from favorites" toast');
|
|
9414
|
+
* } else {
|
|
9415
|
+
* console.error('[smartico] favorite toggle failed — revert the local state and show an error toast:', r.err_message);
|
|
9416
|
+
* }
|
|
9417
|
+
* ```
|
|
6728
9418
|
*/
|
|
6729
9419
|
;
|
|
6730
9420
|
_proto.markUnmarkInboxMessageAsFavorite = function markUnmarkInboxMessageAsFavorite(messageGuid, mark) {
|
|
@@ -6741,9 +9431,52 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6741
9431
|
}
|
|
6742
9432
|
}
|
|
6743
9433
|
/**
|
|
6744
|
-
*
|
|
9434
|
+
* Soft-deletes a single inbox message. After deletion, the message
|
|
9435
|
+
* is excluded from future {@link getInboxMessages} responses
|
|
9436
|
+
* server-side, but its row is retained for analytics — there is no
|
|
9437
|
+
* "undelete" path via the SDK.
|
|
6745
9438
|
*
|
|
6746
|
-
*
|
|
9439
|
+
* @remarks
|
|
9440
|
+
* **Error codes** (in `err_code`)
|
|
9441
|
+
* - `0` — success; the message is now deleted from the user's
|
|
9442
|
+
* view.
|
|
9443
|
+
* - other non-zero — server error. Surface `err_message` if any.
|
|
9444
|
+
*
|
|
9445
|
+
* **Refresh after success**
|
|
9446
|
+
* The SDK does NOT auto-refresh {@link getInboxMessages}. Drop the
|
|
9447
|
+
* deleted message from your local list, or re-call
|
|
9448
|
+
* `getInboxMessages` to reload. If the deleted message was unread,
|
|
9449
|
+
* the unread count drops automatically via the user-properties
|
|
9450
|
+
* channel.
|
|
9451
|
+
*
|
|
9452
|
+
* **Idempotency**: safe. A second call on an already-deleted
|
|
9453
|
+
* `messageGuid` returns `err_code === 0` (server treats it as a
|
|
9454
|
+
* no-op — already-deleted messages are filtered out).
|
|
9455
|
+
*
|
|
9456
|
+
* **Side effects** (on success)
|
|
9457
|
+
* - Server-side `is_deleted` flag set to true.
|
|
9458
|
+
* - If the message was unread, `core_inbox_unread_count`
|
|
9459
|
+
* decrements via the user-properties channel.
|
|
9460
|
+
*
|
|
9461
|
+
* **UI guidance**: see [UI Guide — `deleteInboxMessage`](../../docs/ui/inbox/UIGuide_deleteInboxMessage.md).
|
|
9462
|
+
*
|
|
9463
|
+
* **Visitor mode**: not supported.
|
|
9464
|
+
*
|
|
9465
|
+
* @param messageGuid The `message_guid` from a `TInboxMessage`.
|
|
9466
|
+
* @returns `{ err_code, err_message }`; success when
|
|
9467
|
+
* `err_code === 0`.
|
|
9468
|
+
*
|
|
9469
|
+
* @example
|
|
9470
|
+
* ```ts
|
|
9471
|
+
* // Swipe-to-delete on mobile; trash-icon click on desktop.
|
|
9472
|
+
* console.log('[smartico] delete starting — animate the row out of the list (slide left/right by 100%)');
|
|
9473
|
+
* const r = await window._smartico.api.deleteInboxMessage(message.message_guid);
|
|
9474
|
+
* if (r.err_code === 0) {
|
|
9475
|
+
* console.log('[smartico] deleted — drop the message from the local list, fire a brief "Message deleted" toast (no undo affordance — there is no undelete via the SDK)');
|
|
9476
|
+
* } else {
|
|
9477
|
+
* console.error('[smartico] delete failed — animate the row back into place and show a non-blocking error:', r.err_message);
|
|
9478
|
+
* }
|
|
9479
|
+
* ```
|
|
6747
9480
|
*/
|
|
6748
9481
|
;
|
|
6749
9482
|
_proto.deleteInboxMessage = function deleteInboxMessage(messageGuid) {
|
|
@@ -6760,9 +9493,61 @@ var WSAPIInbox = /*#__PURE__*/function (_WSAPILeaderBoard) {
|
|
|
6760
9493
|
}
|
|
6761
9494
|
}
|
|
6762
9495
|
/**
|
|
6763
|
-
*
|
|
9496
|
+
* Soft-deletes ALL of the user's inbox messages in one server
|
|
9497
|
+
* round-trip — typically wired to a "Delete all" CTA in the inbox
|
|
9498
|
+
* header (usually behind a confirm dialog given the destructive
|
|
9499
|
+
* nature).
|
|
6764
9500
|
*
|
|
6765
|
-
*
|
|
9501
|
+
* The operation is global to the user — NOT filtered by the
|
|
9502
|
+
* current view (active category tab, favorite filter, etc.). Every
|
|
9503
|
+
* non-deleted message in the user's inbox flips to deleted.
|
|
9504
|
+
*
|
|
9505
|
+
* @remarks
|
|
9506
|
+
* **Error codes** (in `err_code`)
|
|
9507
|
+
* - `0` — success; the entire inbox is now empty from the user's
|
|
9508
|
+
* view.
|
|
9509
|
+
* - other non-zero — server error. Surface `err_message` if any.
|
|
9510
|
+
*
|
|
9511
|
+
* **Race condition note**: a new message arriving server-side
|
|
9512
|
+
* between the call and its processing is NOT deleted (the
|
|
9513
|
+
* server's delete-all operation is a snapshot in time). Subsequent
|
|
9514
|
+
* `getInboxMessages` calls show the new message.
|
|
9515
|
+
*
|
|
9516
|
+
* **Refresh after success**
|
|
9517
|
+
* Same as {@link deleteInboxMessage} — `getInboxMessages` `onUpdate`
|
|
9518
|
+
* does not fire automatically. Replace the local list with `[]`
|
|
9519
|
+
* (or re-call `getInboxMessages`). The unread count drops to 0
|
|
9520
|
+
* (or near-0 if races) via the user-properties channel.
|
|
9521
|
+
*
|
|
9522
|
+
* **Idempotency**: safe. A second call on an already-empty inbox
|
|
9523
|
+
* returns `err_code === 0` with no-op effect.
|
|
9524
|
+
*
|
|
9525
|
+
* **Side effects** (on success)
|
|
9526
|
+
* - Every message flipped to deleted server-side.
|
|
9527
|
+
* - `core_inbox_unread_count` drops to 0.
|
|
9528
|
+
* - There is no SDK undelete path — recovery requires operator
|
|
9529
|
+
* intervention.
|
|
9530
|
+
*
|
|
9531
|
+
* **UI guidance**: included in the
|
|
9532
|
+
* [UI Guide — `deleteInboxMessage`](../../docs/ui/inbox/UIGuide_deleteInboxMessage.md)
|
|
9533
|
+
* (Bulk variant section).
|
|
9534
|
+
*
|
|
9535
|
+
* **Visitor mode**: not supported.
|
|
9536
|
+
*
|
|
9537
|
+
* @returns `{ err_code, err_message }`; success when
|
|
9538
|
+
* `err_code === 0`.
|
|
9539
|
+
*
|
|
9540
|
+
* @example
|
|
9541
|
+
* ```ts
|
|
9542
|
+
* // After a confirm dialog "Are you sure you want to delete all messages?"
|
|
9543
|
+
* console.log('[smartico] delete-all confirmed — show loading state on the "Delete all" button');
|
|
9544
|
+
* const r = await window._smartico.api.deleteAllInboxMessages();
|
|
9545
|
+
* if (r.err_code === 0) {
|
|
9546
|
+
* console.log('[smartico] inbox cleared — replace the local list with [], fire a "All messages deleted" toast, badge auto-drops to 0');
|
|
9547
|
+
* } else {
|
|
9548
|
+
* console.error('[smartico] delete-all failed — show a non-blocking error toast:', r.err_message);
|
|
9549
|
+
* }
|
|
9550
|
+
* ```
|
|
6766
9551
|
*/
|
|
6767
9552
|
;
|
|
6768
9553
|
_proto.deleteAllInboxMessages = function deleteAllInboxMessages() {
|
|
@@ -8843,16 +11628,25 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
8843
11628
|
return Promise.reject(e);
|
|
8844
11629
|
}
|
|
8845
11630
|
};
|
|
8846
|
-
_proto.
|
|
11631
|
+
_proto.getRaffleWonPrizes = function getRaffleWonPrizes(user_ext_id, props) {
|
|
8847
11632
|
try {
|
|
8848
11633
|
var _this97 = this;
|
|
8849
|
-
var message = _this97.buildMessage(user_ext_id, exports.ClassId.
|
|
11634
|
+
var message = _this97.buildMessage(user_ext_id, exports.ClassId.RAF_GET_WON_PRIZES_REQUEST, props);
|
|
11635
|
+
return Promise.resolve(_this97.send(message, exports.ClassId.RAF_GET_WON_PRIZES_RESPONSE));
|
|
11636
|
+
} catch (e) {
|
|
11637
|
+
return Promise.reject(e);
|
|
11638
|
+
}
|
|
11639
|
+
};
|
|
11640
|
+
_proto.getActivityLog = function getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset) {
|
|
11641
|
+
try {
|
|
11642
|
+
var _this98 = this;
|
|
11643
|
+
var message = _this98.buildMessage(user_ext_id, exports.ClassId.GET_POINT_HISTORY_REQUEST, {
|
|
8850
11644
|
startTimeSeconds: Math.floor(startTimeSeconds),
|
|
8851
11645
|
endTimeSeconds: Math.floor(endTimeSeconds),
|
|
8852
11646
|
limit: limit,
|
|
8853
11647
|
offset: offset
|
|
8854
11648
|
});
|
|
8855
|
-
return Promise.resolve(
|
|
11649
|
+
return Promise.resolve(_this98.send(message, exports.ClassId.GET_POINT_HISTORY_RESPONSE));
|
|
8856
11650
|
} catch (e) {
|
|
8857
11651
|
return Promise.reject(e);
|
|
8858
11652
|
}
|
|
@@ -8865,11 +11659,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
8865
11659
|
to = 50;
|
|
8866
11660
|
}
|
|
8867
11661
|
try {
|
|
8868
|
-
var
|
|
11662
|
+
var _this99 = this;
|
|
8869
11663
|
var limit = to - from > 50 ? 50 : to - from;
|
|
8870
11664
|
var offset = from;
|
|
8871
|
-
return Promise.resolve(
|
|
8872
|
-
return ActivityLogTransform(
|
|
11665
|
+
return Promise.resolve(_this99.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).then(function (_this99$getActivityLo) {
|
|
11666
|
+
return ActivityLogTransform(_this99$getActivityLo.logHistory);
|
|
8873
11667
|
});
|
|
8874
11668
|
} catch (e) {
|
|
8875
11669
|
return Promise.reject(e);
|