@smartico/public-api 0.0.402 → 0.0.404

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/.claude/skills/api-tsdoc/SKILL.md +675 -0
  2. package/.claude/skills/api-tsdoc-final/SKILL.md +266 -0
  3. package/.claude/skills/api-tsdoc-howto/SKILL.md +143 -0
  4. package/dist/MiniGames/SAWTemplate.d.ts +4 -0
  5. package/dist/NodeCache.d.ts +1 -0
  6. package/dist/OCache.d.ts +7 -0
  7. package/dist/SmarticoGlobal.d.ts +0 -6
  8. package/dist/WSAPI/WSAPITypes.d.ts +43 -0
  9. package/dist/WSAPI/WSAPIUser.d.ts +3 -0
  10. package/dist/index.js +92 -33
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.mjs +60 -10
  13. package/dist/index.modern.mjs.map +1 -1
  14. package/docs/api/interfaces/TUserProfile.md +136 -0
  15. package/docs/capabilities/_responses/buyStoreItem.json +4 -0
  16. package/docs/capabilities/_responses/claimBonus.json +4 -0
  17. package/docs/capabilities/_responses/gamePickGetActiveRound.json +95 -0
  18. package/docs/capabilities/_responses/gamePickGetActiveRounds.json +191 -0
  19. package/docs/capabilities/_responses/gamePickGetBoard.json +47 -0
  20. package/docs/capabilities/_responses/gamePickGetGameInfo.json +355 -0
  21. package/docs/capabilities/_responses/gamePickGetHistory.json +191 -0
  22. package/docs/capabilities/_responses/gamePickGetUserInfo.json +14 -0
  23. package/docs/capabilities/_responses/getAchCategories.json +12 -0
  24. package/docs/capabilities/_responses/getActivityLog.json +1 -0
  25. package/docs/capabilities/_responses/getAvatarPrompts.json +16 -0
  26. package/docs/capabilities/_responses/getAvatarsCustomized.json +12 -0
  27. package/docs/capabilities/_responses/getAvatarsList.json +24 -0
  28. package/docs/capabilities/_responses/getBadges.json +98 -0
  29. package/docs/capabilities/_responses/getBonuses.json +18 -0
  30. package/docs/capabilities/_responses/getClanInfo.json +39 -0
  31. package/docs/capabilities/_responses/getClans.json +35 -0
  32. package/docs/capabilities/_responses/getCurrentLevel.json +20 -0
  33. package/docs/capabilities/_responses/getCustomSections.json +25 -0
  34. package/docs/capabilities/_responses/getInboxMessageBody.json +7 -0
  35. package/docs/capabilities/_responses/getInboxMessages.json +18 -0
  36. package/docs/capabilities/_responses/getInboxUnreadCount.json +1 -0
  37. package/docs/capabilities/_responses/getJackpotEligibleGames.json +20 -0
  38. package/docs/capabilities/_responses/getJackpotWinners.json +28 -0
  39. package/docs/capabilities/_responses/getLeaderBoard.json +45 -0
  40. package/docs/capabilities/_responses/getLevels.json +40 -0
  41. package/docs/capabilities/_responses/getMiniGames.json +208 -0
  42. package/docs/capabilities/_responses/getMiniGamesHistory.json +1 -0
  43. package/docs/capabilities/_responses/getMissions.json +117 -0
  44. package/docs/capabilities/_responses/getRaffleDrawRun.json +62 -0
  45. package/docs/capabilities/_responses/getRaffleDrawRunsHistory.json +34 -0
  46. package/docs/capabilities/_responses/getRaffles.json +140 -0
  47. package/docs/capabilities/_responses/getStoreCategories.json +12 -0
  48. package/docs/capabilities/_responses/getStoreItems.json +47 -0
  49. package/docs/capabilities/_responses/getStorePurchasedItems.json +49 -0
  50. package/docs/capabilities/_responses/getTournamentInstanceInfo.json +75 -0
  51. package/docs/capabilities/_responses/getTournamentsList.json +66 -0
  52. package/docs/capabilities/_responses/getTranslations.json +25 -0
  53. package/docs/capabilities/_responses/getUserLevelExtraCounters.json +4 -0
  54. package/docs/capabilities/_responses/getUserProfile.json +34 -0
  55. package/docs/capabilities/_responses/jackpotGet.json +113 -0
  56. package/docs/capabilities/_responses/jackpotOptIn.json +9 -0
  57. package/docs/capabilities/_responses/jackpotOptOut.json +9 -0
  58. package/docs/capabilities/_responses/markAllInboxMessagesAsRead.json +4 -0
  59. package/docs/capabilities/_responses/markInboxMessageAsRead.json +4 -0
  60. package/docs/capabilities/_responses/markUnmarkInboxMessageAsFavorite.json +4 -0
  61. package/docs/capabilities/_responses/miniGameWinAcknowledgeRequest.json +10 -0
  62. package/docs/capabilities/_responses/playMiniGame.json +6 -0
  63. package/docs/capabilities/_responses/playMiniGameBatch.json +9 -0
  64. package/docs/capabilities/_responses/registerInTournament.json +4 -0
  65. package/docs/capabilities/_responses/requestMissionOptIn.json +4 -0
  66. package/docs/capabilities/_responses/setAvatar.json +4 -0
  67. package/docs/capabilities/avatarsCustomize.md +115 -0
  68. package/docs/capabilities/buyStoreItem.md +179 -0
  69. package/docs/capabilities/checkSegmentListMatch.md +69 -0
  70. package/docs/capabilities/checkSegmentMatch.md +74 -0
  71. package/docs/capabilities/claimBonus.md +125 -0
  72. package/docs/capabilities/claimRafflePrize.md +116 -0
  73. package/docs/capabilities/deleteAllInboxMessages.md +66 -0
  74. package/docs/capabilities/deleteInboxMessage.md +60 -0
  75. package/docs/capabilities/gamePickGetActiveRound.md +248 -0
  76. package/docs/capabilities/gamePickGetActiveRounds.md +259 -0
  77. package/docs/capabilities/gamePickGetBoard.md +202 -0
  78. package/docs/capabilities/gamePickGetGameInfo.md +318 -0
  79. package/docs/capabilities/gamePickGetHistory.md +244 -0
  80. package/docs/capabilities/gamePickGetRoundInfoForUser.md +189 -0
  81. package/docs/capabilities/gamePickGetUserInfo.md +91 -0
  82. package/docs/capabilities/gamePickSubmitSelection.md +222 -0
  83. package/docs/capabilities/gamePickSubmitSelectionQuiz.md +198 -0
  84. package/docs/capabilities/getAchCategories.md +119 -0
  85. package/docs/capabilities/getActivityLog.md +108 -0
  86. package/docs/capabilities/getAvatarPrompts.md +81 -0
  87. package/docs/capabilities/getAvatarsCustomized.md +96 -0
  88. package/docs/capabilities/getAvatarsList.md +101 -0
  89. package/docs/capabilities/getBadges.md +237 -0
  90. package/docs/capabilities/getBonuses.md +159 -0
  91. package/docs/capabilities/getClanInfo.md +164 -0
  92. package/docs/capabilities/getClanTournamentPlayers.md +112 -0
  93. package/docs/capabilities/getClans.md +168 -0
  94. package/docs/capabilities/getCurrentLevel.md +123 -0
  95. package/docs/capabilities/getCustomSections.md +96 -0
  96. package/docs/capabilities/getInboxMessageBody.md +87 -0
  97. package/docs/capabilities/getInboxMessages.md +146 -0
  98. package/docs/capabilities/getInboxUnreadCount.md +54 -0
  99. package/docs/capabilities/getJackpotEligibleGames.md +93 -0
  100. package/docs/capabilities/getJackpotWinners.md +113 -0
  101. package/docs/capabilities/getLeaderBoard.md +187 -0
  102. package/docs/capabilities/getLeaderBoards.md +88 -0
  103. package/docs/capabilities/getLevels.md +118 -0
  104. package/docs/capabilities/getMiniGames.md +295 -0
  105. package/docs/capabilities/getMiniGamesHistory.md +183 -0
  106. package/docs/capabilities/getMissions.md +253 -0
  107. package/docs/capabilities/getRaffleDrawRun.md +210 -0
  108. package/docs/capabilities/getRaffleDrawRunsHistory.md +116 -0
  109. package/docs/capabilities/getRaffleWonPrizes.md +153 -0
  110. package/docs/capabilities/getRaffles.md +249 -0
  111. package/docs/capabilities/getRelatedItemsForGame.md +236 -0
  112. package/docs/capabilities/getStoreCategories.md +128 -0
  113. package/docs/capabilities/getStoreItems.md +260 -0
  114. package/docs/capabilities/getStorePurchasedItems.md +280 -0
  115. package/docs/capabilities/getTournamentInstanceInfo.md +301 -0
  116. package/docs/capabilities/getTournamentsList.md +234 -0
  117. package/docs/capabilities/getTranslations.md +95 -0
  118. package/docs/capabilities/getUserLevelExtraCounters.md +92 -0
  119. package/docs/capabilities/getUserProfile.md +184 -0
  120. package/docs/capabilities/jackpotGet.md +173 -0
  121. package/docs/capabilities/jackpotOptIn.md +94 -0
  122. package/docs/capabilities/jackpotOptOut.md +92 -0
  123. package/docs/capabilities/joinClan.md +169 -0
  124. package/docs/capabilities/markAllInboxMessagesAsRead.md +72 -0
  125. package/docs/capabilities/markInboxMessageAsRead.md +69 -0
  126. package/docs/capabilities/markUnmarkInboxMessageAsFavorite.md +75 -0
  127. package/docs/capabilities/miniGameWinAcknowledgeRequest.md +98 -0
  128. package/docs/capabilities/playMiniGame.md +217 -0
  129. package/docs/capabilities/playMiniGameBatch.md +129 -0
  130. package/docs/capabilities/registerInTournament.md +187 -0
  131. package/docs/capabilities/reportClickEvent.md +74 -0
  132. package/docs/capabilities/reportImpressionEvent.md +67 -0
  133. package/docs/capabilities/requestMissionClaimReward.md +117 -0
  134. package/docs/capabilities/requestMissionOptIn.md +98 -0
  135. package/docs/capabilities/requestRaffleOptin.md +108 -0
  136. package/docs/capabilities/setAvatar.md +132 -0
  137. package/docs/capabilities/smarticoCallbacks.md +165 -0
  138. package/docs/capabilities/smarticoGlobal.md +62 -0
  139. package/package.json +3 -2
  140. package/readme-smartico-dev.md +208 -0
  141. package/scripts/capture-responses-browser.mjs +301 -0
  142. package/scripts/gen-capabilities.js +368 -0
  143. package/scripts/run-public-api.mjs +105 -0
  144. package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -0
  145. package/src/MiniGames/SAWTemplate.ts +5 -0
  146. package/src/NodeCache.ts +8 -0
  147. package/src/OCache.ts +17 -0
  148. package/src/SmarticoGlobal.ts +0 -7
  149. package/src/WSAPI/WSAPI.ts +3 -3
  150. package/src/WSAPI/WSAPIJackpots.ts +4 -1
  151. package/src/WSAPI/WSAPIMiniGames.ts +1 -1
  152. package/src/WSAPI/WSAPITypes.ts +44 -0
  153. package/src/WSAPI/WSAPIUser.ts +30 -5
@@ -0,0 +1,118 @@
1
+ # getLevels — API (TLevel)
2
+
3
+ > Returns the full level ladder configured for the current label — one `TLevel` per active level, server-sorted by `required_points` ASC (lowest first; `ordinal_position` is a 1-based index into the returned array).
4
+ > Import: `import { TLevel } from '@smartico/public-api'`
5
+ > Search terms: getLevels, user, getUserLevels, TLevel, id, name, description, image, required_points, visibility_points, required_level_counter_1, required_level_counter_2
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getLevels(): Promise<TLevel[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ _None._
14
+
15
+ ## Returns — `Promise<TLevel[]>`
16
+ Array of `TLevel`. Each item:
17
+ - `id` (number) — Stable ID of the level.
18
+ - `name` (string) — Display name of the level, pre-translated to the user's language.
19
+ - `description` (string) — Display description of the level, pre-translated to the user's language.
20
+ - `image` (string) — URL of the level image (256x256 px source).
21
+ - `required_points` (number) — Total `ach_points_ever` required to reach this level.
22
+ - `visibility_points` (number) — Visibility threshold — clients hide the level from the user until `ach_points_ever >= visibility_points`. `null` means always visible.
23
+ - `required_level_counter_1` (number) — Required value of the first level counter for sliding-window leveling. `null` on points-only labels. See `UserLevelExtraCountersT`.
24
+ - `required_level_counter_2` (number) — Required value of the second level counter for sliding-window leveling. `null` on points-only labels.
25
+ - `custom_data` (string) — Operator-defined custom data. The SDK auto-parses JSON-looking strings, so at runtime this is `any` despite the `string` type.
26
+ - `ordinal_position` (number) — 1-based position in the ladder (matches the order of the returned array, which is sorted by `required_points` ASC).
27
+
28
+ ## Behavioral contract
29
+ **Server-side filtering**
30
+ The server returns ALL active levels for the label. There is NO
31
+ per-user filtering on visibility, level-status, or anything else —
32
+ the response is identical across users of the same label. Apply
33
+ `visibility_points` filtering client-side if you want to hide
34
+ not-yet-reached levels (compare against
35
+ `getUserProfile().ach_points_ever` and exclude levels where
36
+ `visibility_points > ach_points_ever`).
37
+
38
+ **Sort order**
39
+ The returned array is already sorted by `required_points` ASC, and
40
+ `ordinal_position` is a 1-based index into that same sort order —
41
+ client-side re-sorting is not required for the default rendering.
42
+ If your label uses sliding-window leveling logic
43
+ (see `getUserLevelExtraCounters`) and you want to sort by
44
+ a multi-criteria key (`required_points`, then
45
+ `required_level_counter_1`, then `required_level_counter_2`), do
46
+ that client-side.
47
+
48
+ **Cache TTL**: the SDK caches the response for 30 seconds. Cache
49
+ is fully cleared on login / logout. Operator-driven level edits
50
+ surface on the next cache miss.
51
+
52
+ **Idempotency / Side effects**: safe. Read-only metadata. Calls
53
+ within the cache window de-duplicate to the same cached array.
54
+
55
+ **UI guidance**: see [UI Guide — `getLevels`](../../docs/ui/user/UIGuide_getLevels.md).
56
+
57
+ **Visitor mode**: supported. Use `_smartico.vapi(lang).getLevels()`
58
+ to fetch the ladder for anonymous viewers; the level configuration
59
+ is label-scoped static data so the response is meaningful even
60
+ without an authenticated user. Per-user fields (the implicit
61
+ "current level" via `getCurrentLevel`, or the user's progress)
62
+ are not available in visitor mode.
63
+
64
+ ## Example
65
+ ```ts
66
+ const [levels, profile] = await Promise.all([
67
+ window._smartico.api.getLevels(),
68
+ Promise.resolve(window._smartico.api.getUserProfile()),
69
+ ]);
70
+
71
+ // Resolve the user's current level by ID.
72
+ const current = levels.find(l => l.id === profile.ach_level_current_id);
73
+ console.log('[smartico] render header badge — current level:', current?.name,
74
+ '(position', current?.ordinal_position, 'of', levels.length, ')');
75
+
76
+ // Filter to levels the user has unlocked enough to see.
77
+ const visible = levels.filter(l =>
78
+ l.visibility_points == null || l.visibility_points <= profile.ach_points_ever
79
+ );
80
+ console.log('[smartico] render the level map with', visible.length, 'visible tiles');
81
+
82
+ // Visitor-mode equivalent: returns the same ladder; no per-user state.
83
+ // const visitorLevels = await window._smartico.vapi('EN').getLevels();
84
+ ```
85
+
86
+ ### Example response (REAL shape)
87
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
88
+ ```json
89
+ [
90
+ {
91
+ "id": 696,
92
+ "name": "Stone",
93
+ "description": "Your journey begins here! Step into the game and start climbing the ranks.",
94
+ "image": "https://cdn.example/1a4199871dc30acf09374a-1stone.png",
95
+ "required_points": 0,
96
+ "visibility_points": 0,
97
+ "required_level_counter_1": 0,
98
+ "required_level_counter_2": 0,
99
+ "custom_data": {
100
+ "reward": "100 Free Spins",
101
+ "image_inactive": "https://cdn.example/e917989495185e3fed695d-LevelLevel1Enabledfalse.png",
102
+ "image_active": "https://cdn.example/a961023ab3f6441ac19dfc-LevelLevel1Enabledtrue.png",
103
+ "rakeback": 0,
104
+ "has_vip_club": false,
105
+ "cashback": 0
106
+ },
107
+ "ordinal_position": 1
108
+ }
109
+ ]
110
+ ```
111
+
112
+ ## Errors
113
+ See this method's TSDoc / the mutation pages for `err_code` handling.
114
+
115
+ ## Related
116
+ - `getUserProfile`
117
+ - `getUserLevelExtraCounters`
118
+ - `getCurrentLevel`
@@ -0,0 +1,295 @@
1
+ # getMiniGames — API (TMiniGameTemplate)
2
+
3
+ > Returns all mini-game templates ("SAW" = Spin And Win — the umbrella term for wheel-spin, scratch-card, lootbox, gift-box, treasure-hunt, plinko, coin-flip, quiz, and several other formats) configured for the label.
4
+ > Import: `import { TMiniGameTemplate } from '@smartico/public-api'`
5
+ > Search terms: getMiniGames, minigames, getSAW, spins, wheel, SAWPrizeType, TMiniGameTemplate, SAWGameTypeName, SAWBuyInTypeName, TMiniGamePrize, MiniGamePrizeTypeName, SAWAcknowledgeTypeName, PrizeModifiers, AttemptPeriodType, SAWTemplateUI, SAWAskForUsername, SAWGameLayoutName, SAWExposeUserSpinIdName, onUpdate, subscription, id, name, description, thumbnail, visibile_when_can_spin, saw_game_type, saw_buyin_type, jackpot_add_on_attempt
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<
10
+ TMiniGameTemplate[]
11
+ >
12
+ ```
13
+
14
+ ## Parameters
15
+ - `params` — Optional. Omit to fetch without subscribing.
16
+ - `params.onUpdate` — Callback invoked with the full refreshed template array after any spin-count change, spin response, or acknowledge response on this connection.
17
+
18
+ ## Returns — `Promise<
19
+ TMiniGameTemplate[]
20
+ >`
21
+ Array of `TMiniGameTemplate`. Each item:
22
+ - `id` (number) — ID of the mini-game template
23
+ - `name` (string) — Name of the mini-game template, translated to the user language
24
+ - `description` (string) — Description of the mini-game template, translated to the user language
25
+ - `thumbnail` (string) — URL of the icon of the mini-game template, 256x256px
26
+ - `visibile_when_can_spin` (boolean) — Indicates if the mini-game is visible when the user have attempts/points/gems/diamonds to play
27
+ - `saw_game_type` (SAWGameTypeName) — The type of the game, e.g. Spin the Wheel, Gift Box, Scratch card, MatchX etc
28
+ - `saw_buyin_type` (SAWBuyInTypeName) — How the user is charged for each game attempt e.g. Free, Points or Spin attempts
29
+ - `buyin_cost_points` (number) — in case of charging type 'Points', what is the points amount will be deducted from user balance
30
+ - `buyin_cost_gems` (number) — in case of charging type 'Gems', what is the gems amount will be deducted from user balance
31
+ - `buyin_cost_diamonds` (number) — in case of charging type 'Diamonds', what is the diamonds amount will be deducted from user balance
32
+ - `spin_count` (number) — in case of charging type 'Spin attempts', shows the current number of spin attempts that user has
33
+ - `next_available_spin_ts` (number) — if the game is limit to the number of spins that user can do during period of time, this property shows the epoch time in UTC when the next attempt will be available. Note that you need to enable 'Show time to the next available spin' setting on mini-game template in the backoffice Important: this field will not be populated if “Max number of attempts a user can do” is set to value different from 1
34
+ - `earliest_expiration_dt` (number | null) — Soonest-expiring spin's expiration time for the current user, as an epoch-ms timestamp. `null` when the user has no expirable spins for this template — spins only expire when the template defines a spin-expiration rule (Wheel of Fortune, Loot Boxes, etc.). Pair with `latest_expiration_dt` to render a "spins expire between X and Y" window.
35
+ - `latest_expiration_dt` (number | null) — Latest-expiring spin's expiration time for the current user, as an epoch-ms timestamp. `null` when the user has no expirable spins; equals `earliest_expiration_dt` when a single expiration applies.
36
+ - `over_limit_message` (string) — The message that should be shown to the user when he cannot play the game, server rejected attempt with error code SAWSpinErrorCode.SAW_FAILED_MAX_SPINS_REACHED
37
+ - `no_attempts_message` (string) — The message that should be shown to the user when he cannot play the game because he doesn't have spin attempts or points.
38
+ - `jackpot_current` (number) — Current jackpont amount, if jackpot is enabled.
39
+ - `jackpot_add_on_attempt` (number) — The amount that will be added to the jackpot every time when somebody plays the game. Note that the contribution amount is abstract, means that no money or points are deducted from the user balance.
40
+ - `jackpot_symbol` (string) — The symbol of jackpot that is giving the sense to the 'amount' E.g. the symbol could be EUR and connected to the amount it can indicate that amount is monetary, e.g. '100 EUR'. Or the symbol can be 'Free spins' and connected to the amount it can indicate that amount is number of free spins, e.g. '100 Free spins'.
41
+ - `promo_image` (string) — The promo image, 500x240px
42
+ - `promo_text` (string) — The promo text
43
+ - `custom_data` (any) — The custom data of the mini-game defined by operator in the BackOffice. Can be a JSON object, string or number
44
+ - `prizes` (TMiniGamePrize[]) — List of prizes for mini-games
45
+ - `id` (number) — ID of the prize
46
+ - `name` (string) — The visual name of the prize
47
+ - `prize_type` (MiniGamePrizeTypeName) — The type of the prize, no-prize, points, bonus, manual, spin, jackpot
48
+ - `prize_value` (number) — Numeric value of the prize in case it's 'points' or 'spin' type. For other types of prizes this value is not relevant. For example for prize '100 points' the prize_value will be 100. For '100 free spins' the prize_value will be 100.
49
+ - `font_size` (number) — Custom font size for the prize (desktop)
50
+ - `font_size_mobile` (number) — Custom font size for the prize (mobile)
51
+ - `icon` (string) — The URL of the icon of the prize, aspect ratio 1:1
52
+ - `position` (number) — for scratch card defines position of prize in the list
53
+ - `sectors` (number[]) — List of sectors for the prize
54
+ - `acknowledge_type` (SAWAcknowledgeTypeName) — Type of acknowledge message for users
55
+ - `aknowledge_message` (string) — Message that will be shown to user in modal pop-up
56
+ - `acknowledge_dp` (string) — Deep link that will trigger some action in modal pop-up
57
+ - `acknowledge_action_title` (string) — The name of the action button in modal pop-up
58
+ - `acknowledge_dp_additional` (string) — Deep link that will trigger some action in modal pop-up (additional)
59
+ - `acknowledge_action_title_additional` (string) — The name of the action button in modal pop-up (additional)
60
+ - `out_of_stock_message` (string) — Message when the prize pool is empty for that specific prize
61
+ - `pool` (number) — Number of items in stock
62
+ - `pool_initial` (number) — Initial number of items in stock
63
+ - `wins_count` (number) — Number of wins in game
64
+ - `weekdays` (number[]) — Number of days of week, when the prize can be available
65
+ - `active_from_ts` (number) — Holds time from which prize will become available, for the prizes that are targeted to be available from specific time (UNIX timestamp)
66
+ - `active_till_ts` (number) — Holds time till which prize will become available, for the prizes that are targeted to be available from specific time (UNIX timestamp)
67
+ - `relative_period_timezone` (number) — Time zone to ensure each day aligns with your local midnight.
68
+ - `is_surcharge` (boolean) — Flag indicating that the prize is surcharged (available all the time, despite pool numbers)
69
+ - `is_deleted` (boolean) — Flag indicating the state of the prize
70
+ - `custom_data` (any) — The custom data of the mini-game defined by operator in the BackOffice. Can be a JSON object, string or number
71
+ - `prize_modifiers` (PrizeModifiers[]) — Prize modifiers that will multiply by 2x, 5x or 10x the current total. This will not affect the final Prize Amount that will be awarded.
72
+ - `allow_split_decimal` (boolean) — When enabled, you can split prize value by decimal values
73
+ - `hide_prize_from_history` (boolean) — When enabled, you can hide prize from prize history
74
+ - `requirements_to_get_prize` (string) — Requirements to claim the prize (lootbox specific)
75
+ - `max_give_period_type_id` (AttemptPeriodType) — The period type for the prize to be given: Time from last attempt, Calendar days UTC, Calendar days user time zone, Lifetime
76
+ - `expose_game_stat_on_api` (boolean) — When enabled, the number of items in the pool and number of won items will be exposed in the Retention API and in the UI Widgets
77
+ - `relative_period_timezone` (number) — Time zone to ensure each day aligns with your local midnight.
78
+ - `activeFromDate` (number) — Holds time from which template will become available, for the template that are targeted to be available from specific time (UNIX timestamp)
79
+ - `activeTillDate` (number) — Holds time till which template will become available, for the templates that are targeted to be available from specific time (UNIX timestamp)
80
+ - `steps_to_finish_game` (number) — The amount of steps to complete the game and gather the prize
81
+ - `custom_section_id` (number) — Hold the id of the custom section
82
+ - `saw_template_ui_definition` (SAWTemplateUI) — The UI definition of the mini-game
83
+ - `skin` (string)
84
+ - `name` (string)
85
+ - `description` (string)
86
+ - `over_limit_message` (string)
87
+ - `hide_prize_names` (string)
88
+ - `no_attempts_message` (string)
89
+ - `thumbnail` (string)
90
+ - `sectors_count` (number)
91
+ - `priority` (number)
92
+ - `flow_builder_only` (boolean)
93
+ - `background_image` (string)
94
+ - `background_image_mobile` (string)
95
+ - `background_sound` (string)
96
+ - `spin_animation_duration` (number)
97
+ - `scratch_logo` (string)
98
+ - `scratch_cover` (string)
99
+ - `scratch_bg_desktop` (string)
100
+ - `scratch_bg_mobile` (string)
101
+ - `scratch_cursor` (string)
102
+ - `custom_css` (string)
103
+ - `custom_skin_folder` (string)
104
+ - `jackpot_symbol` (string)
105
+ - `promo_image` (string)
106
+ - `promo_text` (string)
107
+ - `matchx_banner` (string)
108
+ - `matchx_seasonal_ranking` (boolean)
109
+ - `matchx_is_completed` (boolean)
110
+ - `matchx_general_board_users_count` (number)
111
+ - `matchx_hide_ranking` (boolean)
112
+ - `prize_pool_image` (string)
113
+ - `ask_for_username` (SAWAskForUsername)
114
+ - `show_prize_board` (boolean)
115
+ - `max_spins_period_ms` (number)
116
+ - `show_countdown_for_next_availability` (boolean)
117
+ - `disable_background_music` (boolean)
118
+ - `custom_section_id` (number)
119
+ - `only_in_custom_section` (boolean)
120
+ - `custom_data` (any)
121
+ - `placeholder1` (string)
122
+ - `placeholder2` (string)
123
+ - `prize_drop_template` ({
124
+ id: string;
125
+ content: string;
126
+ })
127
+ - `game_layout` (SAWGameLayoutName) — The layout of the game
128
+ - `show_prize_history` (boolean) — When enabled the prize history icon is visible on a certain template
129
+ - `max_number_of_attempts` (number) — The maximum number of attempts that user can do during period of time
130
+ - `max_spins_period_ms` (number) — The period of time in milliseconds during which the user can do the maximum number of attempts
131
+ - `expose_user_spin_id` (SAWExposeUserSpinIdName) — The ID of the user spin id to expose on the game
132
+
133
+ ## Behavioral contract
134
+ **Subscription model (`onUpdate`)**
135
+ The callback receives the FULL refreshed template list (never a
136
+ diff/patch). Each subsequent call to `getMiniGames({ onUpdate })`
137
+ REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
138
+ it) to keep the prior callback in place; the callback is never
139
+ auto-cleared.
140
+
141
+ **Update triggers** — the callback fires when:
142
+
143
+ 1. The server pushes a `spin_count` change (campaign award,
144
+ store purchase, BO manual issuance, mission reward).
145
+ 2. Any `playMiniGame` or `playMiniGameBatch`
146
+ resolves on this connection — the cached array refreshes
147
+ with updated `spin_count`, `jackpot_current`, and any new
148
+ `next_available_spin_ts`.
149
+ 3. Acknowledge responses land (via auto-acknowledge or
150
+ `miniGameWinAcknowledgeRequest`).
151
+
152
+ Jackpot growth is observable on the refreshed `jackpot_current`
153
+ field — the SDK inlines the live value into template `name` /
154
+ `promo_text` / prize `name` via a `{{jackpot}}` template
155
+ substitution at fetch time.
156
+
157
+ **Game-type variants**
158
+ All twelve `SAWGameType` values (`SpinAWheel`, `ScratchCard`,
159
+ `MatchX`, `GiftBox`, `PrizeDrop`, `Quiz`, `LootboxWeekdays`,
160
+ `LootboxCalendarDays`, `TreasureHunt`, `Voyager`, `Plinko`,
161
+ `CoinFlip`) surface through the same template shape. Most are
162
+ played via `playMiniGame`; the exceptions are:
163
+ - `PrizeDrop` — server-push only; the consumer does NOT call
164
+ `playMiniGame`. Prizes arrive via the prize-drop push channel.
165
+ - `MatchX` / `Quiz` — predictions are submitted via a separate
166
+ games server (not this SDK); the SAW spin is fired
167
+ server-internally to deduct the buy-in.
168
+
169
+ **Cache TTL**: the SDK caches the response for 30 seconds. Cache
170
+ is fully cleared on login / logout.
171
+
172
+ **Idempotency / Side effects**: safe. Read-only.
173
+
174
+ **UI guidance**: see [UI Guide — `getMiniGames`](../../docs/ui/minigames/UIGuide_getMiniGames.md).
175
+
176
+ **Visitor mode**: supported. Only templates configured with
177
+ `is_visitor_mode = true` in the BO are returned for anonymous
178
+ sessions. Spins from these templates may also be played (visitor
179
+ mode is the one mini-game flow that does support play — see
180
+ `playMiniGame` for the visitor-stop semantics).
181
+
182
+ ## Example
183
+ ```ts
184
+ const games = await window._smartico.api.getMiniGames({
185
+ onUpdate: (refreshed) => {
186
+ console.log('[smartico] mini-game templates refreshed — re-render lobby from this array:', refreshed);
187
+ },
188
+ });
189
+
190
+ // Filter the lobby view per the visibility flag.
191
+ const visible = games.filter(g =>
192
+ !g.visibile_when_can_spin || (g.spin_count && g.spin_count > 0)
193
+ );
194
+
195
+ for (const g of visible) {
196
+ console.log('[smartico] render game card', g.id, '—', g.name,
197
+ '— type:', g.saw_game_type,
198
+ '— buy-in:', g.saw_buyin_type,
199
+ '— spins available:', g.spin_count ?? 0,
200
+ '— jackpot:', g.jackpot_current, g.jackpot_symbol);
201
+ }
202
+ ```
203
+
204
+ ### Example response (REAL shape)
205
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
206
+ ```json
207
+ [
208
+ {
209
+ "id": 656,
210
+ "name": "Scratch & Love",
211
+ "description": "This is demo description of mini game. <br/>\n <hr/>\n\n You can <b>use tags</b> like {{spins_available}}, to show number of spins that us…",
212
+ "thumbnail": "https://cdn.example/00000000-0000-0000-0000-000000000000/ico.png",
213
+ "visibile_when_can_spin": false,
214
+ "saw_game_type": "scratch",
215
+ "saw_buyin_type": "spins",
216
+ "jackpot_add_on_attempt": 1,
217
+ "jackpot_current": 1070,
218
+ "spin_count": 5,
219
+ "promo_image": "https://cdn.example/d3d65f1bc722a8c66a9493-PromoImagefromTinyPNG.png",
220
+ "promo_text": "The Scratch of Love is better than any other scratch!",
221
+ "custom_data": {},
222
+ "expose_game_stat_on_api": false,
223
+ "relative_period_timezone": 0,
224
+ "activeFromDate": -9223372036854776000,
225
+ "activeTillDate": 9223372036854776000,
226
+ "next_available_spin_ts": null,
227
+ "earliest_expiration_dt": 1952155860877,
228
+ "latest_expiration_dt": 1952155860877,
229
+ "custom_section_id": 491,
230
+ "saw_template_ui_definition": {
231
+ "scratch_bg_mobile": "",
232
+ "promo_text": "The Scratch of Love is better than any other scratch!",
233
+ "thumbnail": "",
234
+ "only_in_custom_section": false,
235
+ "scratch_logo": "",
236
+ "description": "This is demo description of mini game. <br/>\n <hr/>\n\n You can <b>use tags</b> like {{spins_available}}, to show number of spins that us…",
237
+ "background_image_mobile": "",
238
+ "custom_css": ".scratch-card-root-mobile .scratch-area .button-area div {\n background-image: linear-gradient(180deg,#BD0A42,50%,#BD0A42);\n}\n.scratch-card-root .scratch-a…",
239
+ "hide_prize_names": false,
240
+ "scratch_bg_desktop": "",
241
+ "priority": 1,
242
+ "scratch_cover": "",
243
+ "background_image": "",
244
+ "sectors_count": 6,
245
+ "show_countdown_for_next_availability": false,
246
+ "promo_image": "https://cdn.example/d3d65f1bc722a8c66a9493-PromoImagefromTinyPNG.png",
247
+ "disable_background_music": true,
248
+ "scratch_cursor": "",
249
+ "background_sound": "",
250
+ "name": "Scratch & Love",
251
+ "spin_animation_duration": 15,
252
+ "flow_builder_only": false,
253
+ "custom_section_id": 491,
254
+ "background_music_volume": 10
255
+ },
256
+ "show_prize_history": true,
257
+ "max_number_of_attempts": 0,
258
+ "prizes": [
259
+ {
260
+ "id": 15589,
261
+ "name": "No luck this time =(",
262
+ "prize_type": "no-prize",
263
+ "prize_value": 1,
264
+ "font_size": null,
265
+ "position": 7,
266
+ "sectors": [
267
+ ""
268
+ ],
269
+ "acknowledge_type": "silent",
270
+ "acknowledge_dp": "dp:ok",
271
+ "acknowledge_action_title": "OK",
272
+ "pool": null,
273
+ "pool_initial": 100,
274
+ "wins_count": null,
275
+ "weekdays": null,
276
+ "active_from_ts": null,
277
+ "active_till_ts": null,
278
+ "relative_period_timezone": 0,
279
+ "is_surcharge": false,
280
+ "is_deleted": false,
281
+ "custom_data": {},
282
+ "max_give_period_type_id": 2
283
+ }
284
+ ]
285
+ }
286
+ ]
287
+ ```
288
+
289
+ ## Errors
290
+ See this method's TSDoc / the mutation pages for `err_code` handling.
291
+
292
+ ## Related
293
+ - `playMiniGame`
294
+ - `playMiniGameBatch`
295
+ - `miniGameWinAcknowledgeRequest`
@@ -0,0 +1,183 @@
1
+ # getMiniGamesHistory — API (TSawHistory)
2
+
3
+ > Returns a paginated, newest-first list of the user's past mini-game spins — each row carries the won prize ID, the client-side `request_id` used for the spin, and a server-recorded `is_claimed` flag (`true` if the spin has been acknowledged).
4
+ > Import: `import { TSawHistory } from '@smartico/public-api'`
5
+ > Search terms: getMiniGamesHistory, minigames, getSAWHistory, TSawHistory, SAWTemplate, SAWGameType, SAWTemplateUI, SAWBuyInType, SAWPrize
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getMiniGamesHistory({
10
+ limit,
11
+ offset,
12
+ saw_template_id,
13
+ }: {
14
+ limit?: number;
15
+ offset?: number;
16
+ saw_template_id?: number;
17
+ }): Promise<TSawHistory[]>
18
+ ```
19
+
20
+ ## Parameters
21
+ - `params` — Optional pagination + filter bag.
22
+ - `params.limit` — Page size. Defaults to 20.
23
+ - `params.offset` — Number of rows to skip. Defaults to 0.
24
+ - `params.saw_template_id` — When set, scopes the history to a single template's spins.
25
+
26
+ ## Returns — `Promise<TSawHistory[]>`
27
+ Array of `TSawHistory`. Each item:
28
+ - `template` (SAWTemplate) — The initial information about mini-game
29
+ - `saw_template_id` (number)
30
+ - `saw_game_type_id` (SAWGameType)
31
+ - `saw_template_ui_definition` (SAWTemplateUI)
32
+ - `skin` (string)
33
+ - `name` (string)
34
+ - `description` (string)
35
+ - `over_limit_message` (string)
36
+ - `hide_prize_names` (string)
37
+ - `no_attempts_message` (string)
38
+ - `thumbnail` (string)
39
+ - `sectors_count` (number)
40
+ - `priority` (number)
41
+ - `flow_builder_only` (boolean)
42
+ - `background_image` (string)
43
+ - `background_image_mobile` (string)
44
+ - `background_sound` (string)
45
+ - `spin_animation_duration` (number)
46
+ - `scratch_logo` (string)
47
+ - `scratch_cover` (string)
48
+ - `scratch_bg_desktop` (string)
49
+ - `scratch_bg_mobile` (string)
50
+ - `scratch_cursor` (string)
51
+ - `custom_css` (string)
52
+ - `custom_skin_folder` (string)
53
+ - `jackpot_symbol` (string)
54
+ - `promo_image` (string)
55
+ - `promo_text` (string)
56
+ - `matchx_banner` (string)
57
+ - `matchx_seasonal_ranking` (boolean)
58
+ - `matchx_is_completed` (boolean)
59
+ - `matchx_general_board_users_count` (number)
60
+ - `matchx_hide_ranking` (boolean)
61
+ - `prize_pool_image` (string)
62
+ - `ask_for_username` (SAWAskForUsername)
63
+ - `show_prize_board` (boolean)
64
+ - `max_spins_period_ms` (number)
65
+ - `show_countdown_for_next_availability` (boolean)
66
+ - `disable_background_music` (boolean)
67
+ - `custom_section_id` (number)
68
+ - `only_in_custom_section` (boolean)
69
+ - `custom_data` (any)
70
+ - `placeholder1` (string)
71
+ - `placeholder2` (string)
72
+ - `prize_drop_template` ({
73
+ id: string;
74
+ content: string;
75
+ })
76
+ - `saw_buyin_type_id` (SAWBuyInType)
77
+ - `buyin_cost_points` (number)
78
+ - `visibile_when_can_spin` (boolean)
79
+ - `spin_count` (number)
80
+ - `prizes` (SAWPrize[])
81
+ - `saw_prize_id` (number)
82
+ - `saw_prize_ui_definition` (SAWPrizeUI)
83
+ - `position` (number)
84
+ - `name` (string)
85
+ - `name_original` (string)
86
+ - `hide_prize_popup` (boolean)
87
+ - `aknowledge_message` (string)
88
+ - `sectors` (number[])
89
+ - `acknowledge_type` (SAWAcknowledgeType)
90
+ - `acknowledge_dp` (string)
91
+ - `font_size` (number)
92
+ - `font_size_mobile` (number)
93
+ - `sound_type` (SAWWinSoundType)
94
+ - `icon` (string)
95
+ - `replace_name_with_image` (boolean)
96
+ - `acknowledge_action_title` (string)
97
+ - `custom_win_sound` (string)
98
+ - `prize_value` (number)
99
+ - `prize_type_id` (SAWPrizeType)
100
+ - `place_from` (number)
101
+ - `place_to` (number)
102
+ - `sawUniqueWinId` (string)
103
+ - `is_visible` (boolean)
104
+ - `jackpot_add_on_attempt` (number)
105
+ - `jackpot_current` (number)
106
+ - `jackpot_guaranteed` (number)
107
+ - `maxActiveSpinsAllowed` (number)
108
+ - `maxSpinsCount` (number)
109
+ - `maxSpinsPediodMs` (number)
110
+ - `next_available_spin_ts` (number)
111
+ - `saw_skin_key` (string)
112
+ - `saw_skin_ui_definition` ({
113
+ skin_folder: string;
114
+ skin_css: string;
115
+ })
116
+ - `saw_template_id` (number) — ID of the mini-game template
117
+ - `saw_prize_id` (number) — The saw_prize_id that user won, details of the prize can be found in the mini-game definition
118
+ - `prize_amount` (number) — Amount of prizes in stock
119
+ - `client_request_id` (string) — Request ID that client is sending to show history
120
+ - `is_claimed` (boolean) — Flag indicating to show whether prize in the mini-game claimed or not
121
+ - `create_date_ts` (number) — Win prize date in milliseconds
122
+ - `acknowledge_date_ts` (number) — Claimed prize date in milliseconds
123
+
124
+ ## Behavioral contract
125
+ **Pagination**
126
+ `limit` defaults to 20, `offset` defaults to 0. Sort order is
127
+ `create_date` DESC (newest first) — no client-side re-sort
128
+ required. For "load more" pagination, advance `offset` by the
129
+ page size on each subsequent call.
130
+
131
+ The underlying protocol carries a `hasMore` boolean on the
132
+ response, but the SDK strips it from the public surface —
133
+ detect end of list when the returned array length is less than
134
+ `limit`.
135
+
136
+ **`is_claimed` semantics**
137
+ Maps directly to the server's "acknowledge_date is non-null"
138
+ state. A spin where the auto-acknowledge fire-and-forget
139
+ succeeded shows `is_claimed: true`; a spin where the
140
+ acknowledge was lost (network drop) or where the user is on an
141
+ explicit-acknowledge flow shows `is_claimed: false` with a
142
+ usable `client_request_id`. A server-side fallback job
143
+ auto-acknowledges stale rows every ~60 seconds — so even
144
+ "lost" prizes are eventually delivered without consumer action.
145
+
146
+ **Cache TTL**: the SDK caches the response for 30 seconds.
147
+ Cache is invalidated implicitly when a new spin or acknowledge
148
+ response lands.
149
+
150
+ **Idempotency / Side effects**: safe. Read-only.
151
+
152
+ **UI guidance**: see [UI Guide — `getMiniGamesHistory`](../../docs/ui/minigames/UIGuide_getMiniGamesHistory.md).
153
+
154
+ **Visitor mode**: not supported.
155
+
156
+ ## Example
157
+ ```ts
158
+ const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
159
+
160
+ // Show unacknowledged spins with a Claim CTA.
161
+ const unacknowledged = history.filter(h => !h.is_claimed);
162
+ console.log('[smartico] surface a "Claim" CTA on these', unacknowledged.length, 'history rows:',
163
+ unacknowledged.map(h => h.client_request_id));
164
+
165
+ // Load-more pagination — advance offset by the prior page size.
166
+ const page2 = await window._smartico.api.getMiniGamesHistory({ limit: 20, offset: 20 });
167
+ console.log('[smartico] page 2 loaded —', page2.length, 'more rows;',
168
+ page2.length < 20 ? 'end of list reached, hide "Load more"' : 'keep "Load more" visible');
169
+ ```
170
+
171
+ ### Example response (REAL shape)
172
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
173
+ ```json
174
+ [
175
+ null
176
+ ]
177
+ ```
178
+
179
+ ## Errors
180
+ See this method's TSDoc / the mutation pages for `err_code` handling.
181
+
182
+ ## Related
183
+ - `miniGameWinAcknowledgeRequest`