@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,169 @@
1
+ # joinClan — API (TClanJoinResult)
2
+
3
+ > Joins (or switches into) a clan on behalf of the current user.
4
+ > Import: `import { TClanJoinResult } from '@smartico/public-api'`
5
+ > Search terms: joinClan, clans, TClanJoinResult
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.joinClan(clanId: number): Promise<TClanJoinResult>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `clanId` — The clan ID from `TClans.clans[i].clan_id` (or `TClanInfo.clan_id`).
14
+
15
+ ## Returns — `Promise<TClanJoinResult>`
16
+ `TClanJoinResult`:
17
+ - `errCode` (number) — Error code. `0` = success. Typed values are members of `JoinClanErrorCode`. See `joinClan` TSDoc for the full table and per-code UI guidance.
18
+ - `errMsg` (string) — Optional server-side error message. Present only on non-zero `errCode`; may be empty even then.
19
+
20
+ ## Behavioral contract
21
+ **Result shape note**: `TClanJoinResult` uses `errCode` / `errMsg`
22
+ (camelCase) — different from most other SDK result types in this
23
+ library which use `err_code` / `err_message` (snake_case). Branch
24
+ on the camelCase keys when reading this method's result.
25
+
26
+ **Preconditions**
27
+ Read the candidate from `getClans` and gate the call on
28
+ `clan.member_count < clan.capacity_limit`, `cooldown_until == null`
29
+ (on the `TClans` payload — the cooldown is user-level, not
30
+ per-clan), and the user's balance for `entry_fee_currency_type_id`
31
+ being at least `entry_fee_amount` (free clans bypass this check).
32
+ The SDK forwards the call unconditionally — calling without
33
+ satisfying these will most likely return one of the error codes
34
+ below.
35
+
36
+
37
+
38
+ **Idempotency**: NOT safe — and notably dangerous. Calling
39
+ `joinClan` with the user's CURRENT `clanId` does NOT short-circuit
40
+ server-side; the call is treated as a clan-switch to the same
41
+ clan. If the label's cooldown is non-zero (the default), the
42
+ second call returns `1006`. If the cooldown is configured to
43
+ zero, the second call will deduct the entry fee AGAIN, deactivate
44
+ the membership, and re-insert it. The SDK does NOT enforce an
45
+ in-flight lock. Consumers MUST guard the call site against
46
+ double-clicks (set a local "joining" flag on click, clear it on
47
+ response) AND short-circuit when the user is already in the
48
+ target clan.
49
+
50
+ **Refresh after success (and after failure)**
51
+ The SDK does NOT automatically refresh the `getClans` cache
52
+ after a join. Manually re-call `getClans()` on success to pick up
53
+ the new `user_clan_id`, refreshed `member_count`, and the new
54
+ `cooldown_until` value. Until you do, the cached `TClans` payload
55
+ is stale.
56
+
57
+ **Side effects** (consumer-observable on success)
58
+ - Entry-fee currency balance decreases by `entry_fee_amount`
59
+ (visible on the next `getUserProfile` refresh / via the
60
+ user-properties update channel).
61
+ - The user's clan membership row is created (or replaced, on a
62
+ switch). `member_count` on the new clan increments by 1; on a
63
+ switch, the old clan's `member_count` decrements by 1 in the
64
+ same transaction.
65
+ - The user's switch-cooldown restarts at the join time (the
66
+ `TClans.cooldown_until` field on the next list fetch reflects
67
+ the new expiry).
68
+ - Server-side CRM analytics fire (clan-joined event, currency-
69
+ deducted event for paid clans). These surface only as
70
+ server-side traces; the SDK consumer observes them indirectly
71
+ via balance / membership refresh.
72
+
73
+ **UI guidance**: see [UI Guide — `joinClan`](../../docs/ui/clans/UIGuide_joinClan.md).
74
+
75
+ **Visitor mode**: not supported. The server rejects the request
76
+ for unauthenticated sessions.
77
+
78
+ ## Example
79
+ ```ts
80
+ const result = await window._smartico.api.getClans();
81
+ const target = result.clans.find(c => c.clan_id === clanId);
82
+
83
+ if (!target) {
84
+ console.log('[smartico] clan not in current list — refresh getClans and retry');
85
+ return;
86
+ }
87
+ if (target.clan_id === result.user_clan_id) {
88
+ console.log('[smartico] user is already in this clan — short-circuit; do NOT call joinClan again, the server will treat it as a switch and may re-deduct the fee');
89
+ return;
90
+ }
91
+ if (result.cooldown_until) {
92
+ console.log('[smartico] user is in cooldown — disable Join until', new Date(result.cooldown_until + 'Z').toLocaleString());
93
+ return;
94
+ }
95
+ if (target.member_count >= target.capacity_limit) {
96
+ console.log('[smartico] clan is full — disable Join');
97
+ return;
98
+ }
99
+
100
+ console.log('[smartico] join starting — set in-flight flag, show loading dots on Join button, keep modal open');
101
+ const r = await window._smartico.api.joinClan(target.clan_id);
102
+ console.log('[smartico] join response received — clear in-flight flag');
103
+
104
+ if (r.errCode === 0) {
105
+ console.log('[smartico] joined successfully — refresh getClans to pick up the new user_clan_id, member_count, and cooldown_until');
106
+ await window._smartico.api.getClans();
107
+ } else if (r.errCode === 1002) {
108
+ console.error('[smartico] clan is full — refresh list, hide the Join CTA on the now-full clan');
109
+ } else if (r.errCode === 1003) {
110
+ const currencyLabel = ['points', 'gems', 'diamonds'][target.entry_fee_currency_type_id] ?? 'currency';
111
+ console.error('[smartico] insufficient', currencyLabel, '— need', target.entry_fee_amount);
112
+ } else if (r.errCode === 1004) {
113
+ console.error('[smartico] user does not meet segment / entry conditions — show a gating message');
114
+ } else if (r.errCode === 1006) {
115
+ console.error('[smartico] cooldown active — surface the cooldown_until from getClans:', result.cooldown_until);
116
+ } else if (r.errCode === 1001) {
117
+ console.error('[smartico] clan not found or archived — refresh list and remove from UI');
118
+ } else {
119
+ console.error('[smartico] join failed — show a generic error toast with this message:', r.errMsg);
120
+ }
121
+ ```
122
+
123
+ ## Errors
124
+ **Error codes** (in `errCode`, typed as `JoinClanErrorCode`)
125
+ - `0` (`JOIN_CLAN_OK`) — success; membership persisted, fee
126
+ debited, cooldown restarted.
127
+ - `1000` (`JOIN_CLAN_INVALID_PARAMETERS`) — request body missing
128
+ `clan_id`. Should not occur via the SDK; treat as a programming
129
+ error.
130
+ - `1001` (`JOIN_CLAN_NOT_FOUND`) — clan doesn't exist for this
131
+ label, OR the clan is archived / in draft state. The server
132
+ merges "missing" and "archived" into this single code. Refresh
133
+ `getClans()` and remove the entry from the UI.
134
+ - `1002` (`JOIN_CLAN_FULL`) — capacity reached between the list
135
+ fetch and the join click (`member_count >= capacity_limit` at
136
+ the server's atomic check). Refresh the list — the button will
137
+ become "Clan is full".
138
+ - `1003` (`JOIN_CLAN_INSUFFICIENT_FUNDS`) — insufficient balance
139
+ for the clan's entry fee. A single code covers all three
140
+ currencies (points / gems / diamonds); read
141
+ `clan.entry_fee_currency_type_id` to identify which currency
142
+ the user is short on. Show an insufficient-balance UI naming
143
+ the deficit.
144
+ - `1004` (`JOIN_CLAN_SEGMENT_MISMATCH`) — user does not meet the
145
+ clan's entry segment or numeric conditions. There is no
146
+ client-side pre-guard for this — surface a gating message.
147
+ - `1005` (`JOIN_CLAN_USER_IS_NOT_IN_CLAN`) — this method NEVER
148
+ returns `1005`. The code is shared with the tournament
149
+ registration error space and fires only on
150
+ `registerInTournament` responses when a clan-based
151
+ tournament requires the user to be in a clan first.
152
+ - `1006` (`JOIN_CLAN_COOLDOWN_ACTIVE`) — user is inside the
153
+ switch-cooldown window from a previous clan join (default
154
+ 7 days, configurable per label). Only reachable when the user is
155
+ already in a *different* clan (this call is then a clan switch);
156
+ a first-time join never returns `1006`. Surface the
157
+ `TClans.cooldown_until` expiry in the disabled CTA.
158
+ - `1011` (`JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START`) — this
159
+ method does NOT return `1011` directly. The code fires on
160
+ `registerInTournament` responses when the user joined
161
+ their current clan after the tournament started AND already
162
+ has tournament scores.
163
+ - other non-zero — generic server error. Surface `errMsg` if any.
164
+
165
+ ## Related
166
+ - `getClans`
167
+ - `JoinClanErrorCode`
168
+ - `registerInTournament`
169
+ - `getUserProfile`
@@ -0,0 +1,72 @@
1
+ # markAllInboxMessagesAsRead — API (InboxMarkMessageAction)
2
+
3
+ > Marks ALL of the user's inbox messages as read in one server round-trip — typically wired to a "Mark all as read" CTA in the inbox header.
4
+ > Import: `import { InboxMarkMessageAction } from '@smartico/public-api'`
5
+ > Search terms: markAllInboxMessagesAsRead, inbox, InboxMarkMessageAction, err_code, err_message
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction>
10
+ ```
11
+
12
+ ## Parameters
13
+ _None._
14
+
15
+ ## Returns — `Promise<InboxMarkMessageAction>`
16
+ `InboxMarkMessageAction`:
17
+ - `err_code` (number) — Error code. `0` = success. See the calling method's TSDoc for the full error semantics (server returns generic codes; the five inbox mutations share the same shape).
18
+ - `err_message` (string) — Optional server-side error message. Present only on non-zero `err_code`; may be empty even then.
19
+
20
+ ## Behavioral contract
21
+ **Race condition note**: a new message arriving server-side
22
+ between the call and its processing remains unread (the
23
+ server's mark-all operation is a snapshot in time). Subsequent
24
+ `getInboxMessages` calls show the new message as unread.
25
+
26
+ **Refresh after success**
27
+ Same as `markInboxMessageAsRead` — `getInboxMessages`
28
+ `onUpdate` does NOT fire automatically, but the unread-count
29
+ channel does (the badge will drop to 0, or to the count of any
30
+ new messages that arrived during processing).
31
+
32
+ **Idempotency**: safe. A second call on an already-all-read
33
+ inbox returns `err_code === 0` with no-op effect.
34
+
35
+ **Side effects** (on success)
36
+ - Every unread message flipped to read.
37
+ - `core_inbox_unread_count` drops to 0 (or near 0 if races).
38
+
39
+ **UI guidance**: included in the
40
+ [UI Guide — `markInboxMessageAsRead`](../../docs/ui/inbox/UIGuide_markInboxMessageAsRead.md)
41
+ (Bulk variant section).
42
+
43
+ **Visitor mode**: not supported.
44
+
45
+ ## Example
46
+ ```ts
47
+ console.log('[smartico] mark-all-read starting — set in-flight flag on the "Mark all read" button, show loading dots');
48
+ const r = await window._smartico.api.markAllInboxMessagesAsRead();
49
+ console.log('[smartico] mark-all-read response — clear in-flight flag');
50
+ if (r.err_code === 0) {
51
+ console.log('[smartico] all messages marked read — optimistically flip every local read indicator; badge auto-drops via user-properties channel');
52
+ } else {
53
+ console.error('[smartico] mark-all failed — surface a non-blocking error:', r.err_message);
54
+ }
55
+ ```
56
+
57
+ ### Example response (REAL shape)
58
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
59
+ ```json
60
+ {
61
+ "err_code": 0,
62
+ "err_message": ""
63
+ }
64
+ ```
65
+
66
+ ## Errors
67
+ **Error codes** (in `err_code`)
68
+ - `0` — success; all currently-unread messages flipped to read.
69
+ - other non-zero — server error. Surface `err_message` if any.
70
+
71
+ ## Related
72
+ - `markInboxMessageAsRead`
@@ -0,0 +1,69 @@
1
+ # markInboxMessageAsRead — API (InboxMarkMessageAction)
2
+
3
+ > Marks a single inbox message as read.
4
+ > Import: `import { InboxMarkMessageAction } from '@smartico/public-api'`
5
+ > Search terms: markInboxMessageAsRead, inbox, InboxMarkMessageAction, err_code, err_message
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `messageGuid` — The `message_guid` from a `TInboxMessage`.
14
+
15
+ ## Returns — `Promise<InboxMarkMessageAction>`
16
+ `InboxMarkMessageAction`:
17
+ - `err_code` (number) — Error code. `0` = success. See the calling method's TSDoc for the full error semantics (server returns generic codes; the five inbox mutations share the same shape).
18
+ - `err_message` (string) — Optional server-side error message. Present only on non-zero `err_code`; may be empty even then.
19
+
20
+ ## Behavioral contract
21
+ **Refresh after success**
22
+ The SDK does NOT auto-refresh `getInboxMessages` (no
23
+ `onUpdate` callback fires after this mutation). The unread-count
24
+ channel (`getInboxUnreadCount`, `core_inbox_unread_count`)
25
+ DOES auto-update — subscribers to it see the new count
26
+ automatically. If your inbox list UI shows the `read` field, you
27
+ have two options: re-call `getInboxMessages` after the mutation,
28
+ or update the local copy optimistically.
29
+
30
+ **Idempotency**: safe. Repeated calls return `err_code === 0`.
31
+
32
+ **Side effects** (on success)
33
+ - Server-side `is_read` flag set to true.
34
+ - Server-side `core_inbox_unread_count` decremented (if the
35
+ message was previously unread).
36
+
37
+ **UI guidance**: see [UI Guide — `markInboxMessageAsRead`](../../docs/ui/inbox/UIGuide_markInboxMessageAsRead.md).
38
+
39
+ **Visitor mode**: not supported.
40
+
41
+ ## Example
42
+ ```ts
43
+ const r = await window._smartico.api.markInboxMessageAsRead(message.message_guid);
44
+ if (r.err_code === 0) {
45
+ console.log('[smartico] marked as read — optimistically flip the local read indicator; the inbox badge auto-decrements via the user-properties channel');
46
+ } else {
47
+ console.error('[smartico] mark-as-read failed — keep the local state as-is and show a non-blocking error if appropriate:', r.err_message);
48
+ }
49
+ ```
50
+
51
+ ### Example response (REAL shape)
52
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
53
+ ```json
54
+ {
55
+ "err_code": 0,
56
+ "err_message": ""
57
+ }
58
+ ```
59
+
60
+ ## Errors
61
+ **Error codes** (in `err_code`)
62
+ - `0` — success; the message is now marked read. Idempotent — a
63
+ second call on the same `messageGuid` also returns `0`.
64
+ - other non-zero — server error. Surface `err_message` if any.
65
+
66
+ ## Related
67
+ - `getInboxUnreadCount`
68
+ - `getUserProfile`
69
+ - `getInboxMessages`
@@ -0,0 +1,75 @@
1
+ # markUnmarkInboxMessageAsFavorite — API (InboxMarkMessageAction)
2
+
3
+ > Toggles a message's favorite (starred) state — pass `mark: true` to favorite, `mark: false` to unfavorite.
4
+ > Import: `import { InboxMarkMessageAction } from '@smartico/public-api'`
5
+ > Search terms: markUnmarkInboxMessageAsFavorite, inbox, InboxMarkMessageAction, err_code, err_message
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `messageGuid` — The `message_guid` from a `TInboxMessage`.
14
+ - `mark` — `true` to favorite, `false` to unfavorite.
15
+
16
+ ## Returns — `Promise<InboxMarkMessageAction>`
17
+ `InboxMarkMessageAction`:
18
+ - `err_code` (number) — Error code. `0` = success. See the calling method's TSDoc for the full error semantics (server returns generic codes; the five inbox mutations share the same shape).
19
+ - `err_message` (string) — Optional server-side error message. Present only on non-zero `err_code`; may be empty even then.
20
+
21
+ ## Behavioral contract
22
+ **Refresh after success**
23
+ The SDK does NOT auto-refresh `getInboxMessages`. To
24
+ reflect the new state in the UI, update the local copy of the
25
+ affected `TInboxMessage` (set `favorite` to the new value) or
26
+ re-call `getInboxMessages`.
27
+
28
+ **Idempotency**: safe. `mark: true` on an already-favorite
29
+ message returns `err_code === 0` (no-op). Same for `mark: false`
30
+ on a non-favorite.
31
+
32
+ **Side effects** (on success)
33
+ - Server-side `is_starred` flag set to the requested value.
34
+ - No effect on read state, unread count, or other fields.
35
+
36
+ **UI guidance**: see [UI Guide — `markUnmarkInboxMessageAsFavorite`](../../docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md).
37
+
38
+ **Visitor mode**: not supported.
39
+
40
+ ## Example
41
+ ```ts
42
+ // Toggle handler — flip the local state optimistically, then
43
+ // call the server, and revert if the call fails.
44
+ const target = !message.favorite;
45
+ console.log('[smartico] optimistically flip the star to', target, '— it will revert if the server rejects');
46
+
47
+ const r = await window._smartico.api.markUnmarkInboxMessageAsFavorite(
48
+ message.message_guid,
49
+ target,
50
+ );
51
+
52
+ if (r.err_code === 0) {
53
+ console.log('[smartico] favorite toggled — keep the local state and show a brief "Added to favorites" / "Removed from favorites" toast');
54
+ } else {
55
+ console.error('[smartico] favorite toggle failed — revert the local state and show an error toast:', r.err_message);
56
+ }
57
+ ```
58
+
59
+ ### Example response (REAL shape)
60
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
61
+ ```json
62
+ {
63
+ "err_code": 0,
64
+ "err_message": ""
65
+ }
66
+ ```
67
+
68
+ ## Errors
69
+ **Error codes** (in `err_code`)
70
+ - `0` — success; the message's favorite state flipped to the
71
+ requested value.
72
+ - other non-zero — server error. Surface `err_message` if any.
73
+
74
+ ## Related
75
+ - `getInboxMessages`
@@ -0,0 +1,98 @@
1
+ # miniGameWinAcknowledgeRequest — API
2
+
3
+ > Manually acknowledges a mini-game spin — marks the win delivered server-side.
4
+ > Import: `import { /* types */ } from '@smartico/public-api'`
5
+ > Search terms: miniGameWinAcknowledgeRequest, minigames, doSAWAcknowledge, SAWAcknowledge, acknowledge, SAWAcknowledgeType, request_id, errCode, errMsg, cid, ts, uuid, payload, duration
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.miniGameWinAcknowledgeRequest(request_id: string): void
10
+ ```
11
+
12
+ ## Parameters
13
+ - `request_id` — Correlation id of the spin to finalise: the `request_id` from a `playMiniGame` result (played with `acknowledge: false`), or the `client_request_id` of a `getMiniGamesHistory` row.
14
+
15
+ ## Returns
16
+ _No return value._
17
+
18
+ ## Behavioral contract
19
+ **When to call**
20
+ - **Primary — after `playMiniGame(..., { acknowledge: false })`.**
21
+ You opted out of the automatic acknowledge to finalise the win
22
+ on your own schedule (e.g. on a user "Claim" tap). Pass the
23
+ `request_id` from that call's result here when ready. This is
24
+ REQUIRED for operator-configured "explicit claim" prizes — they
25
+ are not covered by the server-side fallback, so without this
26
+ call their prize is never credited.
27
+ - **Recovery — a lost acknowledge.** `playMiniGameBatch`
28
+ acknowledges on a fire-and-forget basis; if one is lost (network
29
+ drop) the spin shows `is_claimed: false` in
30
+ `getMiniGamesHistory`. Pass that row's `client_request_id`
31
+ to deliver it.
32
+
33
+ The `request_id` on a `playMiniGame` result and the
34
+ `client_request_id` on a `getMiniGamesHistory` row are the
35
+ same correlation id — this method accepts either.
36
+
37
+ **Idempotency**: safe. Acknowledging a spin that is already
38
+ finalised — by you, by the automatic acknowledge, or by the
39
+ fallback — is a no-op with no double credit. Acknowledging a
40
+ failed spin's id is likewise a no-op.
41
+
42
+ **Server-side fallback**
43
+ Even if you never call this, a server-side job finalises ordinary
44
+ un-acknowledged spins automatically after a short delay (about 1–3
45
+ minutes), flipping `is_claimed` to `true` on the next
46
+ `getMiniGamesHistory` fetch. "Explicit claim" prizes are the
47
+ exception — excluded from the fallback, they require an explicit
48
+ call here.
49
+
50
+ **Side effects** (first successful call for an un-acknowledged spin)
51
+ - For "explicit claim" prizes, the prize value is credited on this
52
+ call. For standard prizes the value was already credited at spin
53
+ time (see `playMiniGame` "Prize handling"); this call only
54
+ marks the win delivered.
55
+ - The spin's `is_claimed` flips to `true` on the next
56
+ `getMiniGamesHistory` fetch.
57
+
58
+ **Visitor mode**: not supported.
59
+
60
+ ## Example
61
+ ```ts
62
+ // Primary — finalise a win you played with acknowledge: false.
63
+ const r = await window._smartico.api.playMiniGame(templateId, { acknowledge: false });
64
+ if (r.err_code === 0) {
65
+ console.log('[smartico] show the prize / Claim CTA; on Claim, finalise the win');
66
+ await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
67
+ }
68
+
69
+ // Recovery — re-acknowledge any spins a batch acknowledge missed.
70
+ const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
71
+ for (const row of history.filter(h => !h.is_claimed)) {
72
+ console.log('[smartico] re-acknowledging stale spin', row.client_request_id);
73
+ await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
74
+ }
75
+ ```
76
+
77
+ ### Example response (REAL shape)
78
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
79
+ ```json
80
+ {
81
+ "request_id": "00000000-0000-0000-0000-000000000000",
82
+ "errCode": 0,
83
+ "errMsg": "",
84
+ "cid": 705,
85
+ "ts": 1782287011139,
86
+ "uuid": "00000000-0000-0000-0000-000000000000",
87
+ "payload": null,
88
+ "duration": null
89
+ }
90
+ ```
91
+
92
+ ## Errors
93
+ See this method's TSDoc / the mutation pages for `err_code` handling.
94
+
95
+ ## Related
96
+ - `playMiniGame`
97
+ - `playMiniGameBatch`
98
+ - `getMiniGamesHistory`