@smartico/public-api 0.0.379 → 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.
Files changed (219) hide show
  1. package/.nvmrc +1 -1
  2. package/CLAUDE.md +103 -0
  3. package/README.md +53 -2
  4. package/dist/Base/ClassId.d.ts +2 -0
  5. package/dist/Jackpots/JackpotDetails.d.ts +14 -15
  6. package/dist/Jackpots/JackpotPot.d.ts +10 -6
  7. package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
  8. package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
  9. package/dist/Raffle/index.d.ts +2 -0
  10. package/dist/SmarticoAPI.d.ts +6 -1
  11. package/dist/SmarticoLib/index.d.ts +5 -1
  12. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  13. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  14. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  15. package/dist/WSAPI/WSAPIAvatars.d.ts +296 -0
  16. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  17. package/dist/WSAPI/WSAPIBonuses.d.ts +240 -0
  18. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  19. package/dist/WSAPI/WSAPIGamePick.d.ts +593 -0
  20. package/dist/WSAPI/WSAPIGeneral.d.ts +172 -0
  21. package/dist/WSAPI/WSAPIInbox.d.ts +615 -0
  22. package/dist/WSAPI/WSAPIJackpots.d.ts +344 -0
  23. package/dist/WSAPI/WSAPILeaderBoard.d.ts +139 -0
  24. package/dist/WSAPI/WSAPIMiniGames.d.ts +510 -0
  25. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  26. package/dist/WSAPI/WSAPIRaffles.d.ts +643 -0
  27. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  28. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  29. package/dist/WSAPI/WSAPITypes.d.ts +376 -205
  30. package/dist/WSAPI/WSAPIUser.d.ts +533 -0
  31. package/dist/index.js +6745 -1661
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.modern.mjs +6324 -1342
  34. package/dist/index.modern.mjs.map +1 -1
  35. package/docs/Callbacks.md +162 -0
  36. package/docs/SmarticoObject.md +445 -0
  37. package/docs/Transforms.md +99 -0
  38. package/docs/api/README.md +82 -2
  39. package/docs/api/classes/WSAPIAvatars.md +344 -0
  40. package/docs/api/classes/WSAPIBonuses.md +271 -0
  41. package/docs/api/classes/WSAPIClans.md +436 -0
  42. package/docs/api/classes/WSAPIGamePick.md +710 -0
  43. package/docs/api/classes/WSAPIGeneral.md +212 -0
  44. package/docs/api/classes/WSAPIInbox.md +801 -0
  45. package/docs/api/classes/WSAPIJackpots.md +439 -0
  46. package/docs/api/classes/WSAPILeaderBoard.md +157 -0
  47. package/docs/api/classes/WSAPIMiniGames.md +612 -0
  48. package/docs/api/classes/WSAPIMissions.md +590 -0
  49. package/docs/api/classes/WSAPIRaffles.md +773 -0
  50. package/docs/api/classes/WSAPIStore.md +719 -0
  51. package/docs/api/classes/WSAPITournaments.md +571 -0
  52. package/docs/api/classes/WSAPIUser.md +637 -0
  53. package/docs/api/documents/Callbacks.md +162 -0
  54. package/docs/api/documents/SmarticoObject.md +445 -0
  55. package/docs/api/documents/Transforms.md +99 -0
  56. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  57. package/docs/api/enumerations/BonusStatus-1.md +11 -6
  58. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  59. package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
  60. package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
  61. package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
  62. package/docs/api/interfaces/AvatarCustomized.md +25 -0
  63. package/docs/api/interfaces/AvatarDefinition.md +94 -0
  64. package/docs/api/interfaces/AvatarPrompt.md +45 -0
  65. package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
  66. package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
  67. package/docs/api/interfaces/Clan.md +4 -0
  68. package/docs/api/interfaces/ClanInfo.md +109 -0
  69. package/docs/api/interfaces/ClanMember.md +53 -0
  70. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  71. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  72. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  73. package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
  74. package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
  75. package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
  76. package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
  77. package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
  78. package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
  79. package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
  80. package/docs/api/interfaces/JackpotDetails.md +14 -15
  81. package/docs/api/interfaces/JackpotPot.md +9 -6
  82. package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
  83. package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
  84. package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
  85. package/docs/api/interfaces/PointsLog.md +43 -0
  86. package/docs/api/interfaces/RaffleWonPrize.md +59 -0
  87. package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
  88. package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
  89. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  90. package/docs/api/interfaces/TAchCategory.md +14 -4
  91. package/docs/api/interfaces/TAvatarCustomized.md +4 -4
  92. package/docs/api/interfaces/TAvatarDefinition.md +13 -14
  93. package/docs/api/interfaces/TAvatarPrompt.md +6 -6
  94. package/docs/api/interfaces/TBonus.md +16 -8
  95. package/docs/api/interfaces/TBuyStoreItemResult.md +4 -11
  96. package/docs/api/interfaces/TClaimBonusResult.md +5 -5
  97. package/docs/api/interfaces/TClan.md +8 -4
  98. package/docs/api/interfaces/TClanInfo.md +47 -0
  99. package/docs/api/interfaces/TClanJoinResult.md +11 -1
  100. package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
  101. package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
  102. package/docs/api/interfaces/TClans.md +3 -1
  103. package/docs/api/interfaces/TGetTranslations.md +4 -0
  104. package/docs/api/interfaces/TInboxMessage.md +14 -6
  105. package/docs/api/interfaces/TInboxMessageBody.md +18 -12
  106. package/docs/api/interfaces/TLevel.md +17 -20
  107. package/docs/api/interfaces/TLevelCurrent.md +19 -18
  108. package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
  109. package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
  110. package/docs/api/interfaces/TMissionClaimRewardResult.md +6 -3
  111. package/docs/api/interfaces/TMissionOptInResult.md +6 -3
  112. package/docs/api/interfaces/TMissionOrBadge.md +5 -4
  113. package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
  114. package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
  115. package/docs/api/interfaces/TSetAvatarResult.md +3 -3
  116. package/docs/api/interfaces/TStoreItem.md +11 -1
  117. package/docs/api/interfaces/TTournament.md +1 -1
  118. package/docs/api/interfaces/TTournamentDetailed.md +9 -1
  119. package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
  120. package/docs/api/interfaces/TUICustomSection.md +23 -19
  121. package/docs/api/interfaces/TUserProfile.md +18 -16
  122. package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
  123. package/docs/api/interfaces/UserAchievement.md +1 -1
  124. package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
  125. package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
  126. package/docs/native/ADDING_METHODS.md +7 -2
  127. package/docs/native/PROTOCOL.md +337 -0
  128. package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
  129. package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
  130. package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
  131. package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
  132. package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
  133. package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
  134. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  135. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  136. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  137. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
  138. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
  139. package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
  140. package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
  141. package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
  142. package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
  143. package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
  144. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
  145. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
  146. package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
  147. package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
  148. package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
  149. package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
  150. package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
  151. package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
  152. package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
  153. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
  154. package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
  155. package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
  156. package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
  157. package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
  158. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
  159. package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
  160. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
  161. package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
  162. package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
  163. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  164. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  165. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  166. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  167. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  168. package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
  169. package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
  170. package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
  171. package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
  172. package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
  173. package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
  174. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  175. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  176. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  177. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  178. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  179. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  180. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  181. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  182. package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
  183. package/docs/ui/user/UIGuide_getLevels.md +167 -0
  184. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  185. package/package.json +3 -3
  186. package/scripts/postdoc-cleanup.js +195 -0
  187. package/src/Base/ClassId.ts +2 -0
  188. package/src/Jackpots/JackpotDetails.ts +14 -15
  189. package/src/Jackpots/JackpotPot.ts +10 -6
  190. package/src/Missions/MissionsUtils.ts +5 -2
  191. package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
  192. package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
  193. package/src/Raffle/index.ts +3 -1
  194. package/src/SmarticoAPI.ts +14 -1
  195. package/src/SmarticoLib/index.ts +4 -0
  196. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  197. package/src/Store/StoreItem.ts +1 -0
  198. package/src/Store/StoreItemPurchased.ts +1 -0
  199. package/src/Store/StoreItemType.ts +1 -1
  200. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  201. package/src/WSAPI/WSAPI.ts +27 -2007
  202. package/src/WSAPI/WSAPIAvatars.ts +345 -0
  203. package/src/WSAPI/WSAPIBase.ts +93 -0
  204. package/src/WSAPI/WSAPIBonuses.ts +268 -0
  205. package/src/WSAPI/WSAPIClans.ts +417 -0
  206. package/src/WSAPI/WSAPIGamePick.ts +667 -0
  207. package/src/WSAPI/WSAPIGeneral.ts +199 -0
  208. package/src/WSAPI/WSAPIInbox.ts +711 -0
  209. package/src/WSAPI/WSAPIJackpots.ts +448 -0
  210. package/src/WSAPI/WSAPILeaderBoard.ts +154 -0
  211. package/src/WSAPI/WSAPIMiniGames.ts +597 -0
  212. package/src/WSAPI/WSAPIMissions.ts +572 -0
  213. package/src/WSAPI/WSAPIRaffles.ts +703 -0
  214. package/src/WSAPI/WSAPIStore.ts +732 -0
  215. package/src/WSAPI/WSAPITournaments.ts +541 -0
  216. package/src/WSAPI/WSAPITypes.ts +376 -207
  217. package/src/WSAPI/WSAPIUser.ts +606 -0
  218. package/tsconfig.json +26 -2
  219. package/docs/api/classes/WSAPI.md +0 -1927
@@ -0,0 +1,117 @@
1
+ # UI Guide — `getRaffleDrawRun`
2
+
3
+ ## Overview
4
+ - Powers the **draw detail / winners screen** for a single raffle
5
+ draw run. Adds paginated `prizes[].winners[]` rows (usernames +
6
+ avatars) to the same `TRaffleDraw` shape already embedded in
7
+ [`getRaffles`](../../api/classes/WSAPIRaffles.md#getraffles).
8
+ - One-shot fetch. No cache, no subscription. Re-call to refresh —
9
+ the default Smartico UI polls on a variable cadence depending on
10
+ the draw's `current_state`.
11
+
12
+ ## Detail view layout
13
+
14
+ Top-to-bottom layout:
15
+
16
+ 1. **Header** — `image_url` / `image_url_mobile` as background.
17
+ 2. **Title + state chip** — `name` + a chip driven by
18
+ `current_state` (Open / Drawing / Finished).
19
+ 3. **Countdown ticker** — `DD : HH : MM : SS` to `execution_ts`
20
+ while Open; not rendered during WinnerSelection or after
21
+ Executed (replaced by drawing animation / winner list).
22
+ 4. **Prize cards** — one per `prizes[]` entry. Each shows
23
+ `name`, `description`, `image_url`, `prizes_per_run_actual`,
24
+ and (if `current_state === Executed`) the paginated
25
+ `winners[]` rows.
26
+ 5. **My tickets** — `my_tickets_count` / `my_last_tickets` for
27
+ Open draws.
28
+ 6. **Opt-in / claim CTAs** — see the
29
+ [`requestRaffleOptin`](../../api/classes/WSAPIRaffles.md#requestraffleoptin)
30
+ and [`claimRafflePrize`](../../api/classes/WSAPIRaffles.md#claimraffleprize)
31
+ UI guides.
32
+
33
+ ## Winners list (paginated)
34
+
35
+ When `current_state === Executed`, each prize card carries a
36
+ `winners[]` array (type `TRafflePrizeWinner`). Render as a table:
37
+
38
+ | Column | Source |
39
+ |---|---|
40
+ | Position | Computed from list order (the server-sorted result places the current user's wins at the top). |
41
+ | Avatar | `winner.avatar_url`. Fallback to a letter avatar when missing. |
42
+ | Username | `winner.username`. Fallback to "Anonymous" if empty. |
43
+ | Ticket | `winner.ticket.ticket_id_string` (use the string form for display). |
44
+ | Claimed | If `winner.claimed_date` is set, show "Claimed"; otherwise show "Pending" (or a Claim CTA if `should_claim === true` and the row matches the current user). |
45
+
46
+ **Pagination** via `winners_from` / `winners_to`:
47
+
48
+ - Default window per call: `0 – 20`.
49
+ - Server cap per call: 50 rows. Passing a larger window silently
50
+ truncates.
51
+ - Total count: `winners_total` on the returned `TRaffleDraw`.
52
+ - The default Smartico UI uses page size 7 internally with a
53
+ custom pagination component — your UI can choose any size up to
54
+ 50.
55
+
56
+ For load-more pagination: advance `winners_from` by the prior page
57
+ size on each subsequent call; reuse the same response transform.
58
+
59
+ ## Refresh / polling
60
+
61
+ `getRaffleDrawRun` has no cache and no push refresh. Poll manually
62
+ when the consumer is viewing a live draw. Recommended cadence
63
+ keyed to `current_state` + remaining time:
64
+
65
+ | State / Time | Poll interval |
66
+ |---|---|
67
+ | `WinnerSelection` (drawing) | 3 s |
68
+ | `Open`, `< 5 minutes` to execution | 10 s |
69
+ | `Open`, `> 5 minutes` to execution | 30 s |
70
+ | `Executed` | No polling needed (state is terminal) |
71
+
72
+ Stop polling when the detail view unmounts.
73
+
74
+ ## Image / asset specs
75
+
76
+ Inherits from [`getRaffles`](./UIGuide_getRaffles.md#image--asset-specs):
77
+
78
+ - Draw promo: 365×175 px (desktop), 300×145 px (mobile)
79
+ - Background image: 900×85 px (desktop), 1328×240 px (mobile)
80
+ - Prize image: 256×256 px (1:1 square)
81
+ - Avatar: serve via CDN; letter-avatar fallback when empty
82
+
83
+ ## Empty / loading / error states
84
+
85
+ - **Loading**: render the modal frame + countdown immediately
86
+ (driven by the caller-side `TRaffleDraw` from `getRaffles`);
87
+ show a winners-list skeleton while the call is in flight.
88
+ - **`winners[]` empty** (Executed draw with no winners): render
89
+ "No winners yet" placeholder. Rare — the server should have
90
+ selected at least one winner per `prizes_per_run_actual`.
91
+ - **Error**: keep the prior snapshot if any; show a non-blocking
92
+ error banner; retry on next poll tick.
93
+
94
+ ## Animations / transitions
95
+
96
+ - **WinnerSelection**: full-screen Lottie drawing animation; the
97
+ winners list area is hidden until state transitions to Executed.
98
+ - **Winners-list page change**: cross-fade rows on pagination.
99
+ - **No confetti / celebration animation** on the user's win row —
100
+ surface a "You won!" pill on rows where `should_claim` is true
101
+ for the current user.
102
+
103
+ ## Mobile vs desktop
104
+
105
+ - **Modal style**: desktop centered with backdrop dim; mobile
106
+ full-screen slide-up sheet.
107
+ - **Image source**: desktop fields vs `*_mobile` fields.
108
+ - **Winners-list layout**: desktop 4 columns; mobile may collapse
109
+ the position column or compact the row.
110
+
111
+ ## Performance
112
+
113
+ - Each call is a fresh network round-trip. During live drawing
114
+ (3 s polling), this is the active surface; `getRaffles` is not
115
+ polled in parallel.
116
+ - Pagination is server-side — don't over-fetch by passing a large
117
+ window; reuse smaller windows.
@@ -0,0 +1,92 @@
1
+ # UI Guide — `getRaffleDrawRunsHistory`
2
+
3
+ ## Overview
4
+ - Powers a **draw-history modal / page** showing past-executed runs
5
+ for a raffle (optionally scoped to a single recurring draw
6
+ schedule).
7
+ - Use to surface unclaimed-prize CTAs across the user's history,
8
+ let the user revisit completed draws, or build a "my wins"
9
+ surface.
10
+ - One-shot fetch, no cache. Re-call to refresh — typically only
11
+ needed after a new execution lands or after a
12
+ [`claimRafflePrize`](../../api/classes/WSAPIRaffles.md#claimraffleprize)
13
+ call resolves.
14
+
15
+ ## List view organization
16
+
17
+ Server-sorted by `execution_ts` DESC (newest first). No client-side
18
+ sort required.
19
+
20
+ If `props.draw_id` is omitted, the list interleaves history across
21
+ all draws of the raffle. The default Smartico UI shows them in
22
+ their server order — no per-draw grouping. To group by draw, key on
23
+ `row.id` (the schedule_id) client-side.
24
+
25
+ If `props.draw_id` is set, the list scopes to one draw's recurring
26
+ history.
27
+
28
+ ## Item row
29
+
30
+ Fields rendered per row:
31
+
32
+ | Field | Source | Notes |
33
+ |---|---|---|
34
+ | Image | `image_url` (or `image_url_mobile` on mobile); fallback to `icon_url` | Same specs as in `getRaffles` UI guide. |
35
+ | Name | `name` | |
36
+ | Description | `description` | Optional; the default UI may omit it on dense lists. |
37
+ | Grand badge | If `is_grand === true`, render a "Grand" pill | |
38
+ | Scheduled date | `execution_ts` formatted as user-local date/time | |
39
+ | Actual date | `actual_execution_ts` — typically same as scheduled, but may differ slightly on recovery paths | |
40
+ | User won? | If `is_winner === true`, surface a "You won!" pill | |
41
+ | Claim CTA | If `has_unclaimed_prize === true`, show a "Claim" button that opens the prize detail via [`getRaffleDrawRun`](../../api/classes/WSAPIRaffles.md#getraffledrawrun) | |
42
+
43
+ Row click target: opens the executed draw's detail view (winner
44
+ list) by calling `getRaffleDrawRun({ raffle_id, run_id })`.
45
+
46
+ ## Claim CTA on history rows
47
+
48
+ When `row.has_unclaimed_prize === true`, surface a Claim button.
49
+ Clicking it should:
50
+
51
+ 1. Fetch the run detail via
52
+ [`getRaffleDrawRun`](../../api/classes/WSAPIRaffles.md#getraffledrawrun)
53
+ to locate the user's winning row(s).
54
+ 2. Pass each winner row's `raf_won_id` to
55
+ [`claimRafflePrize`](../../api/classes/WSAPIRaffles.md#claimraffleprize).
56
+
57
+ The default Smartico UI renders the Claim button inline on the
58
+ history row and opens a confirmation flow when clicked.
59
+
60
+ ## Empty / loading / error states
61
+
62
+ - **Loading (cold fetch)**: render a skeleton list (3–5
63
+ placeholder rows) sized to the eventual layout.
64
+ - **Empty result**: `[]` means no executed runs yet. Render a
65
+ neutral empty-state ("No history yet").
66
+ - **Error**: keep prior state if any; show a non-blocking error
67
+ banner; retry on next user-driven action.
68
+
69
+ ## Refresh
70
+
71
+ No subscription, no cache, no push. Call manually:
72
+
73
+ - After a `claimRafflePrize` resolves (to refresh
74
+ `has_unclaimed_prize`).
75
+ - After a new run executes on the server side (the user observes
76
+ the new history row).
77
+ - On a periodic poll if your UI wants to show new executions
78
+ promptly — typically not necessary for history surfaces.
79
+
80
+ ## Mobile vs desktop
81
+
82
+ - **Image source**: `image_url_mobile` / `background_image_url_mobile`
83
+ on mobile.
84
+ - **Row density**: mobile may collapse description and date columns
85
+ to save horizontal space.
86
+
87
+ ## Performance
88
+
89
+ - Each call is a fresh network round-trip. Scope with `draw_id` when
90
+ possible to keep response size manageable.
91
+ - Don't poll the history surface in real time — re-fetch
92
+ on user-initiated actions only.
@@ -0,0 +1,120 @@
1
+ # UI Guide — `getRaffleWonPrizes`
2
+
3
+ ## Overview
4
+ - Powers a **"my prizes" screen** for a single raffle — the flat list of
5
+ every prize the current user has won across all of that raffle's draws,
6
+ newest-won first.
7
+ - One-shot, paginated fetch. No cache, no subscription. Re-call to refresh
8
+ (e.g. after a [`claimRafflePrize`](../../api/classes/WSAPIRaffles.md#claimraffleprize)).
9
+ - Each row already carries `public_meta.name` + `public_meta.image_url`, so
10
+ you can render full prize cards without a follow-up
11
+ [`getRaffleDrawRun`](../../api/classes/WSAPIRaffles.md#getraffledrawrun) call.
12
+
13
+ ## List view organization
14
+
15
+ - Single flat list (no per-draw grouping), ordered newest-win first.
16
+ - There is **no** server-side "unclaimed first" ordering. If your design
17
+ surfaces actionable prizes at the top, sort client-side by
18
+ `requires_claim && !claimed_date`, then keep the server order within each
19
+ group.
20
+ - Drive "load more" off `total` (the full win count across all draws), not
21
+ off the page length:
22
+
23
+ ```ts
24
+ const hasMore = page.offset + page.won_prizes.length < page.total;
25
+ console.log('[smartico] more pages?', hasMore);
26
+ ```
27
+
28
+ ## Item card / tile
29
+
30
+ One card per `won_prizes[]` row:
31
+
32
+ | Element | Source | Notes |
33
+ |---|---|---|
34
+ | Prize image | `public_meta.name` → `public_meta.image_url` | Square artwork; the default Smartico UI renders it as a circular icon. |
35
+ | Prize name | `public_meta.name` | Localised. Truncate long names (~30 chars) with an ellipsis. |
36
+ | Claimed / Claim CTA | `requires_claim` + `claimed_date` | See the action matrix below. |
37
+ | Won-by attribution | `user.public_username` / `user.avatar_id` | The list belongs to one user; usually shown once in the header, not per card. |
38
+
39
+ ## Action button decision matrix
40
+
41
+ Per row:
42
+
43
+ | `requires_claim` | `claimed_date` | Render |
44
+ |---|---|---|
45
+ | `false` | (any) | No CTA — prize was auto-delivered. Optionally show a "Delivered" tag. |
46
+ | `true` | `null` | **Claim** button. On click call `claimRafflePrize({ won_id: prize.raf_won_id })` — `raf_won_id` IS the `won_id`. |
47
+ | `true` | epoch ms | No CTA — show a "Claimed" tag (optionally with the claimed date). |
48
+
49
+ ```ts
50
+ const canClaim = prize.requires_claim && !prize.claimed_date;
51
+ if (canClaim) {
52
+ console.log('[smartico] show Claim — on click: claimRafflePrize({ won_id:', prize.raf_won_id, '})');
53
+ }
54
+ ```
55
+
56
+ Guard the Claim button against double-clicks (set an in-flight flag on click).
57
+ A second claim of an already-claimed prize is rejected server-side. After a
58
+ successful claim, re-call `getRaffleWonPrizes` to pick up the new
59
+ `claimed_date` (this method has no `onUpdate`).
60
+
61
+ ## User attribution (avatar + username)
62
+
63
+ The `user` object describes whose prizes these are.
64
+
65
+ - **Null-check `user` first** — it is `null` when `won_prizes` is empty.
66
+ - **Avatar**: use `user.avatar_id`. If it already starts with `http`, use it
67
+ directly as the `<img src>`. Otherwise it is an avatar token — prepend the
68
+ widget's configured avatar domain (`{avatarDomain}/avatar/{avatar_id}`).
69
+ `user.avatar_url` is always `null`; ignore it. `user.avatar_real_id`
70
+ identifies the avatar definition internally and is not used for rendering.
71
+ - **Username**: `user.public_username` is server-masked for privacy (e.g.
72
+ `"32:r*****"`). Render it verbatim. For the current user, show a localised
73
+ "You" label instead of the masked string.
74
+
75
+ ## Image / asset specs
76
+
77
+ - Prize image (`public_meta.image_url`): square (1:1) CDN artwork. The default
78
+ Smartico UI renders it at 40×40 px with `border-radius: 50%`.
79
+ - Provide a letter/placeholder fallback when `image_url` is empty.
80
+
81
+ ## Empty / loading / error states
82
+
83
+ - **Loading**: show a card skeleton grid while the call is in flight.
84
+ - **Empty** (`errCode === 0` and `won_prizes.length === 0`): render an empty
85
+ state ("No prizes won yet"). Note this is *also* the response when the user
86
+ is not eligible to see the raffle — the two are indistinguishable, so keep
87
+ the copy neutral.
88
+ - **Error** (`errCode !== 0`): keep any prior snapshot; show a non-blocking
89
+ error banner with a retry. `errCode` is `1` for all server errors —
90
+ surface `errMsg` if present.
91
+
92
+ ## Refresh / polling
93
+
94
+ - One-shot promise; no client cache; no push refresh.
95
+ - Re-call on screen open, on explicit "load more", and after a successful
96
+ `claimRafflePrize`.
97
+ - **Do not poll on a timer** — the server rate-limits this call (~30/min, with
98
+ a ~5 s minimum gap between calls). Tight polling will start failing.
99
+
100
+ ## Pagination
101
+
102
+ - `offset` / `limit` page the rows; the SDK defaults to `0` / `20`.
103
+ - The server does **not** clamp `limit` — pass an explicit, sane page size.
104
+ - An `offset` past the end returns an empty page with the real `total` and
105
+ `errCode 0` (not an error).
106
+ - For "load more": advance `offset` by your page size each call.
107
+
108
+ ## Mobile vs desktop
109
+
110
+ - Desktop: multi-column card grid. Mobile: single-column list or compact
111
+ 2-column grid.
112
+ - The response shape is identical across viewports; only layout density
113
+ differs.
114
+
115
+ ## Performance
116
+
117
+ - Each call is a fresh network round-trip. Fetch one page at a time and append
118
+ on "load more" rather than pre-fetching all pages.
119
+ - The server caches responses briefly, so a quick re-open is cheap — but the
120
+ rate limit still applies; debounce rapid re-fetches.
@@ -0,0 +1,175 @@
1
+ # UI Guide — `getRaffles`
2
+
3
+ ## Overview
4
+ - Returns the user's visible raffles, each carrying an embedded
5
+ `draws[]` array with full per-draw state. Use as the source-of-truth
6
+ for the raffles lobby + draw cards.
7
+ - The list refreshes automatically after
8
+ [`claimRafflePrize`](../../api/classes/WSAPIRaffles.md#claimraffleprize)
9
+ or
10
+ [`requestRaffleOptin`](../../api/classes/WSAPIRaffles.md#requestraffleoptin)
11
+ resolves. Server-side draw executions invalidate the SDK cache too.
12
+ - Winner detail (usernames, avatars) requires a follow-up call to
13
+ [`getRaffleDrawRun`](../../api/classes/WSAPIRaffles.md#getraffledrawrun)
14
+ — the embedded `draws[]` carry only pagination metadata.
15
+
16
+ ## List view organization
17
+
18
+ The default Smartico UI renders raffles as a vertical list with each
19
+ raffle expanding to show its draws. There are no top-level tabs.
20
+
21
+ Per-raffle, draws are bucketed within the detail panel:
22
+
23
+ 1. **Active / Upcoming** — `draws.filter(d => d.current_state !== 3)`
24
+ (1 = Open, 2 = WinnerSelection); sort by `execution_ts` ASC.
25
+ 2. **Executed** — `draws.filter(d => d.current_state === 3)`;
26
+ rendered after the active draws.
27
+
28
+ ## Ticket-cap banner
29
+
30
+ Drive from `TRaffle.ticket_cap_visualization` (enum):
31
+
32
+ | Value | Banner |
33
+ |---|---|
34
+ | `Empty` (0) | No banner. |
35
+ | `Counter` (1) | "X tickets remaining" where X = `max_tickets_count - current_tickets_count`. Format large numbers with locale separators. |
36
+ | `Message` (2) | "All tickets have been distributed" (when 0 remaining). |
37
+
38
+ ## Raffle card (top-level)
39
+
40
+ Fields rendered on each raffle row:
41
+
42
+ - `image_url` (890×193 px desktop) / `image_url_mobile` (300×142 px).
43
+ - `name`, `description`.
44
+ - `start_date` / `end_date` — formatted as user-local dates.
45
+ - Total tickets banner (see above).
46
+ - Draw count or active-draw summary.
47
+
48
+ `custom_section_id` lets the consumer place the raffle into an
49
+ operator-defined custom section. `custom_data` is operator-defined
50
+ JSON / string for custom UI extensions.
51
+
52
+ ## Draw card (per-raffle children)
53
+
54
+ Fields rendered on each `draws[i]`:
55
+
56
+ | Field | Notes |
57
+ |---|---|
58
+ | Card image | `background_image_url` (900×85 px desktop) / `background_image_url_mobile` (1328×240 px). Falls back to `icon_url` (256×256). |
59
+ | Title | `name`. |
60
+ | Description | `description`. |
61
+ | Grand badge | If `is_grand === true`, render a "Grand draw" pill. |
62
+ | Countdown | To `execution_ts`. See "Countdown / timing format". |
63
+ | State chip | Drive from `current_state` ({@link RaffleDrawInstanceState}): Open / Drawing / Finished. |
64
+ | My-tickets | `my_tickets_count` if > 0. |
65
+ | Last tickets preview | `my_last_tickets[]` (capped at ~5; newest first). Note the SDK field is spelled `ticekt_id` (typo). |
66
+ | Total tickets | `total_tickets_count`. |
67
+ | Prize summary | Top-priority prize from `prizes[]`. |
68
+ | Opt-in / Opted-in chip | See "Action button decision matrix". |
69
+
70
+ The draw card click target opens the draw detail (which fetches
71
+ winners via `getRaffleDrawRun`).
72
+
73
+ ## Action button decision matrix
74
+
75
+ Per-draw CTA (evaluate in priority order):
76
+
77
+ | Condition | CTA |
78
+ |---|---|
79
+ | `current_state === WinnerSelection` (2) | "Drawing now…" (informational) — show the Lottie drawing animation |
80
+ | `current_state === Executed` (3) | "View winners" — opens detail via `getRaffleDrawRun` |
81
+ | `requires_optin && user_opted_in && current_state !== Executed` | "Fully opted in" (informational pill, no click) |
82
+ | `requires_optin && !user_opted_in && is_active && current_state !== Executed` | "Opt in" — invokes `requestRaffleOptin` |
83
+ | `!requires_optin && is_active && current_state === Open` | "View prizes" (or no CTA — the user is automatically participating) |
84
+ | `!is_active` and other terminal states | No CTA |
85
+
86
+ Opt-in is per-run — when a recurring draw advances to a new run,
87
+ `user_opted_in` resets to `false` on the new run. The Opt-in CTA
88
+ returns even for users who opted in to the previous run.
89
+
90
+ ## Image / asset specs
91
+
92
+ | Field | Documented source | Aspect | Used where |
93
+ |---|---|---|---|
94
+ | `TRaffle.image_url` | 890×193 px | ~4.6:1 | Raffle row header (desktop) |
95
+ | `TRaffle.image_url_mobile` | 300×142 px | ~2.1:1 | Raffle row header (mobile) |
96
+ | `TRaffleDraw.image_url` | 365×175 px | ~2:1 | Draw promo |
97
+ | `TRaffleDraw.image_url_mobile` | 300×145 px | ~2:1 | Draw promo (mobile) |
98
+ | `TRaffleDraw.icon_url` | 256×256 px | 1:1 | Draw icon (compact contexts) |
99
+ | `TRaffleDraw.background_image_url` | 900×85 px | ~10.6:1 | Draw row background (desktop) |
100
+ | `TRaffleDraw.background_image_url_mobile` | 1328×240 px | ~5.5:1 | Draw row background (mobile) |
101
+ | `TRafflePrize.image_url` | 256×256 px | 1:1 | Prize card |
102
+
103
+ Fallback chain (per element): brand-supplied placeholder if the
104
+ field is empty. The SDK doesn't ship default images.
105
+
106
+ ## Status-specific visual treatments
107
+
108
+ - **Open** (`current_state === 1`): full-color card with active
109
+ countdown. Show My-tickets / prizes prominently.
110
+ - **WinnerSelection** (`current_state === 2`): show Lottie drawing
111
+ animation (full-screen overlay in the default Smartico UI). The
112
+ default UI polls every 3 s during this state.
113
+ - **Executed** (`current_state === 3`): subtle desaturation; show
114
+ "View winners" CTA; surface "You won!" badge if any prize matches
115
+ the user.
116
+ - **Grand** draws (`is_grand: true`): larger card, distinct accent
117
+ color, grand badge. Otherwise identical fields.
118
+ - **Sold out** (ticket cap reached): banner + no opt-in CTA.
119
+
120
+ ## Countdown / timing format
121
+
122
+ The default Smartico UI uses a hard-stamped `DD : HH : MM : SS`
123
+ ticker counting down to `execution_ts`. CSS state classes:
124
+
125
+ - Normal — default styling
126
+ - `alert` — applied when < 5 minutes remain (yellow/amber accent)
127
+ - `alarm` — applied when < 1 minute remains (red accent)
128
+
129
+ **Polling escalation**: the widget polls
130
+ [`getRaffleDrawRun`](../../api/classes/WSAPIRaffles.md#getraffledrawrun)
131
+ at a variable rate keyed to remaining time:
132
+
133
+ - 30 s default
134
+ - 10 s when < 5 minutes remain
135
+ - 3 s when in `WinnerSelection` state
136
+
137
+ For non-default UIs, mirror this pattern or use a constant 30 s
138
+ poll — the cost is one network round-trip per poll tick.
139
+
140
+ ## Empty / loading / error states
141
+
142
+ - **Loading (cold fetch)**: render a skeleton grid sized to the
143
+ eventual layout.
144
+ - **Loading (cache hit)**: do not render a loading state — the
145
+ promise resolves within a microtask.
146
+ - **Empty result**: `[]` means no visible raffles. Render a neutral
147
+ empty-state illustration.
148
+ - **Error**: keep the prior list if any; show a non-blocking error
149
+ banner; retry on next user-driven action.
150
+
151
+ ## Animations / transitions
152
+
153
+ - **List entry**: cards fade-in on first render.
154
+ - **WinnerSelection state**: full-screen Lottie animation while the
155
+ server selects winners.
156
+ - **No celebration animation on claim** — the winner row updates
157
+ in-place. See `claimRafflePrize` UI guide.
158
+ - **Opt-in success**: ~500 ms delay then UI state flip via
159
+ `onUpdate` refresh.
160
+
161
+ ## Mobile vs desktop
162
+
163
+ - **Image source**: `*_url` for desktop, `*_url_mobile` for mobile.
164
+ - **Draw row background**: desktop 900×85 px (wide strip); mobile
165
+ 1328×240 px (taller hero treatment).
166
+ - **Detail modal**: desktop centered modal with backdrop dim; mobile
167
+ full-screen slide-up sheet.
168
+
169
+ ## Performance
170
+
171
+ - The 30 s cache deduplicates rapid refetches.
172
+ - During an in-flight draw (WinnerSelection), polling
173
+ `getRaffleDrawRun` instead of `getRaffles` is cheaper — the latter
174
+ is a larger payload.
175
+ - Image assets are CDN-served; lazy-load images below the fold.
@@ -0,0 +1,114 @@
1
+ # UI Guide — `requestRaffleOptin`
2
+
3
+ ## Overview
4
+ - Action-focused mutation. The user is on a draw card / detail
5
+ page for a draw with `requires_optin === true`, and they click
6
+ "Opt in".
7
+ - Success (`err_code === 0`) means the user is registered for this
8
+ run. Tickets earned within the run's eligibility window will
9
+ participate in the draw.
10
+ - Opt-in is **per-run** — recurring draws require a fresh opt-in
11
+ for each new run.
12
+
13
+ ## Argument mapping
14
+
15
+ The three IDs come from different fields on the embedded draw:
16
+
17
+ | Argument | Source |
18
+ |---|---|
19
+ | `raffle_id` | `TRaffle.id` (the parent raffle) |
20
+ | `draw_id` | `TRaffleDraw.id` (schedule_id, **stable** across recurring runs) |
21
+ | `raffle_run_id` | `TRaffleDraw.run_id` (per-execution instance ID) |
22
+
23
+ Don't confuse `draw.id` with `draw.run_id` — both are needed.
24
+
25
+ ## Loading state
26
+
27
+ - **Trigger**: set an in-flight flag (`optingIn = true`)
28
+ immediately on click.
29
+ - **Visual**: replace the button label with animated dots; disable
30
+ the button.
31
+ - **Reset**: clear the flag on response.
32
+
33
+ ## Idempotency UI guard
34
+
35
+ The SDK does NOT prevent double-clicks. A second call on the same
36
+ `raffle_run_id` returns `err_code === 1` with `err_message`
37
+ indicating the user is already opted in. Guard the call site:
38
+
39
+ ```ts
40
+ const [optingIn, setOptingIn] = useState(false);
41
+
42
+ const onOptIn = async (draw: TRaffleDraw) => {
43
+ if (optingIn) return; // in-flight guard
44
+ if (draw.user_opted_in) return; // already opted in
45
+ setOptingIn(true);
46
+ const r = await window._smartico.api.requestRaffleOptin({
47
+ raffle_id: raffleId,
48
+ draw_id: draw.id, // schedule_id, NOT run_id
49
+ raffle_run_id: draw.run_id,
50
+ });
51
+ setOptingIn(false);
52
+ handleResponse(r);
53
+ };
54
+ ```
55
+
56
+ Treat `err_code === 1` with an "already opted in" message as
57
+ **idempotent success** in the UI.
58
+
59
+ ## Action button decision matrix
60
+
61
+ CTA label per state on the draw card (evaluate in priority order):
62
+
63
+ | Condition | CTA |
64
+ |---|---|
65
+ | `current_state === Executed` (3) | No opt-in CTA (draw is finished) |
66
+ | `current_state === WinnerSelection` (2) | No opt-in CTA (drawing in progress) |
67
+ | `!requires_optin` | No opt-in CTA (tickets participate automatically) |
68
+ | `requires_optin && user_opted_in` | Disabled "Fully opted in" pill (informational) |
69
+ | `requires_optin && !user_opted_in && is_active && current_state !== Executed` | Enabled "Opt in" button |
70
+ | `requires_optin && !is_active` | No opt-in CTA (draw is inactive) |
71
+
72
+ After opt-in success, `user_opted_in` flips to `true` on the next
73
+ `getRaffles` refresh (which fires automatically via `onUpdate`).
74
+
75
+ ## Per-error-code handling
76
+
77
+ | `err_code` | Action |
78
+ |---|---|
79
+ | `0` (success) | Show "Fully opted in" pill; success toast optional |
80
+ | `1` + "already opted in" | Treat as success — same UI as above |
81
+ | `1` + "no need to opt-in" | Hide the opt-in CTA — the draw doesn't actually require it |
82
+ | `1` + "raffle id does not match" | Show a generic error toast; this is a programming bug — verify the IDs being passed |
83
+ | `1` + control-group message | Show a gating message ("Not eligible") |
84
+ | Other non-zero | Generic error toast with `err_message`. Allow retry. |
85
+
86
+ ## Refresh after response
87
+
88
+ The SDK auto-refreshes the raffles cache on every opt-in response
89
+ (success OR failure). The `onUpdate` callback registered via
90
+ [`getRaffles`](../../api/classes/WSAPIRaffles.md#getraffles) fires
91
+ with the refreshed list — `user_opted_in` reflects the new state.
92
+ **Don't manually call `getRaffles()` after the opt-in response.**
93
+
94
+ ## Animations / transitions
95
+
96
+ - **Loading dots**: 3-dot animation on the button while in flight.
97
+ - **Success state flip**: button transitions from "Opt in" to
98
+ "Fully opted in" (~150 ms ease-out). The default Smartico UI
99
+ uses a 500 ms delay before re-fetching, then the state flip is
100
+ observed on the refreshed list.
101
+ - **No celebration animation** — opt-in is a quiet success.
102
+
103
+ ## Mobile vs desktop
104
+
105
+ - **Loading state**: identical (dots).
106
+ - **CTA placement**: desktop usually inline on the draw row; mobile
107
+ may use a sticky CTA at the bottom of the draw detail.
108
+
109
+ ## Performance
110
+
111
+ - Single round-trip per click.
112
+ - The `getRaffles` auto-refresh after the response is a separate
113
+ network call (the cache is invalidated). For UIs that already
114
+ have fresh state, this is redundant but harmless.