@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,34 @@
1
+ {
2
+ "core_public_tags": [
3
+ "SMARTICO.DEV"
4
+ ],
5
+ "ach_points_ever": 690,
6
+ "core_clan_is_kicked": null,
7
+ "user_last_session_push_state": "BLOCKED",
8
+ "aff_referred_by_friend_ext_user_id": null,
9
+ "core_inbox_unread_count": 0,
10
+ "core_user_language": "EN",
11
+ "ach_level_current": "Silver",
12
+ "ach_gems_balance": 10,
13
+ "ach_level_current_id": 698,
14
+ "user_country": "BG",
15
+ "ach_points_balance": 326,
16
+ "core_registration_date": 0,
17
+ "core_recommended_deposit_amount": 0,
18
+ "core_recommended_casino_bet_amount": 0,
19
+ "ach_gamification_in_control_group": false,
20
+ "core_avatar_real_id": null,
21
+ "core_wallet_currency": "UNKNOWN",
22
+ "ach_diamonds_balance": 1,
23
+ "aff_refer_friend_url": null,
24
+ "acc_bonus_abuser": false,
25
+ "aff_refered_friends_count": 0,
26
+ "core_clan_kicked_out_id": null,
27
+ "core_clan_id": "",
28
+ "core_is_test_account": false,
29
+ "user_id": 361368543,
30
+ "avatar_id": "https://cdn.example/avatars/12/00000000-0000-0000-0000-000000000000.png",
31
+ "avatar_real_id": 12,
32
+ "public_username": "Antonio",
33
+ "avatar_url": "https://cdn.example/avatars/12/00000000-0000-0000-0000-000000000000.png"
34
+ }
@@ -0,0 +1,113 @@
1
+ [
2
+ {
3
+ "jp_template_id": 6,
4
+ "jp_type_id": 1,
5
+ "jp_public_meta": {
6
+ "image_url": "https://cdn.example/f8b68a18473c437e32a860-Jackpot1.jpg",
7
+ "placeholder1": null,
8
+ "placeholder2": null,
9
+ "name": "Minor",
10
+ "description": "1% on top of your bet amount will be contributed to the Jackpot",
11
+ "not_winner_template": {
12
+ "id": "0",
13
+ "content": ""
14
+ },
15
+ "priority": "1",
16
+ "winner_template": {
17
+ "id": "0",
18
+ "content": ""
19
+ },
20
+ "custom_data": {}
21
+ },
22
+ "jp_currency": "EUR",
23
+ "user_currency": "EUR",
24
+ "related_games": [],
25
+ "contribution_type": 2,
26
+ "contribution_value": 0.2,
27
+ "pot": {
28
+ "jp_template_id": 6,
29
+ "jp_pot_id": 306140,
30
+ "user_id": null,
31
+ "current_pot_amount": 12.28367028,
32
+ "current_pot_amount_user_currency": 12.28367028,
33
+ "explode_date_ts": null,
34
+ "current_pot_temperature": 2
35
+ },
36
+ "is_opted_in": false,
37
+ "is_auto_opt_in": true,
38
+ "ach_related_game_allow_all": true,
39
+ "registration_count": 17262,
40
+ "contribution_rules": [
41
+ {
42
+ "ruleId": 1,
43
+ "jpTemplateId": 6,
44
+ "type": 2,
45
+ "extEntityIds": [
46
+ "1111"
47
+ ],
48
+ "contributionValue": 4
49
+ },
50
+ {
51
+ "ruleId": 2,
52
+ "jpTemplateId": 6,
53
+ "type": 1,
54
+ "extEntityIds": [
55
+ "666666"
56
+ ],
57
+ "contributionValue": 3
58
+ }
59
+ ],
60
+ "expose_winners_over_api": false
61
+ },
62
+ {
63
+ "jp_template_id": 4,
64
+ "jp_type_id": 1,
65
+ "jp_public_meta": {
66
+ "image_url": "https://cdn.example/f8b68a18473c437e32a860-Jackpot1.jpg",
67
+ "placeholder1": null,
68
+ "placeholder2": null,
69
+ "name": "Major",
70
+ "description": "1% on top of your bet amount will be contributed to the Jackpot",
71
+ "not_winner_template": {
72
+ "id": "0",
73
+ "content": ""
74
+ },
75
+ "priority": "2",
76
+ "winner_template": {
77
+ "id": "0",
78
+ "content": ""
79
+ },
80
+ "custom_data": {}
81
+ },
82
+ "jp_currency": "EUR",
83
+ "user_currency": "EUR",
84
+ "related_games": [],
85
+ "contribution_type": 2,
86
+ "contribution_value": 6.7,
87
+ "pot": {
88
+ "jp_template_id": 4,
89
+ "jp_pot_id": 306164,
90
+ "user_id": null,
91
+ "current_pot_amount": 780.319207992,
92
+ "current_pot_amount_user_currency": 780.319207992,
93
+ "explode_date_ts": null,
94
+ "current_pot_temperature": 2
95
+ },
96
+ "is_opted_in": true,
97
+ "is_auto_opt_in": true,
98
+ "ach_related_game_allow_all": true,
99
+ "registration_count": 32971,
100
+ "contribution_rules": [
101
+ {
102
+ "ruleId": 3,
103
+ "jpTemplateId": 4,
104
+ "type": 2,
105
+ "extEntityIds": [
106
+ "999"
107
+ ],
108
+ "contributionValue": 8
109
+ }
110
+ ],
111
+ "expose_winners_over_api": false
112
+ }
113
+ ]
@@ -0,0 +1,9 @@
1
+ {
2
+ "errCode": 1,
3
+ "errMsg": "JP User already opted in to Jackpot",
4
+ "cid": 805,
5
+ "ts": 1782287009179,
6
+ "uuid": "00000000-0000-0000-0000-000000000000",
7
+ "payload": null,
8
+ "duration": null
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "errCode": 0,
3
+ "errMsg": "",
4
+ "cid": 807,
5
+ "ts": 1782229816688,
6
+ "uuid": "00000000-0000-0000-0000-000000000000",
7
+ "payload": null,
8
+ "duration": null
9
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": ""
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": ""
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": ""
4
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "request_id": "00000000-0000-0000-0000-000000000000",
3
+ "errCode": 0,
4
+ "errMsg": "",
5
+ "cid": 705,
6
+ "ts": 1782287011139,
7
+ "uuid": "00000000-0000-0000-0000-000000000000",
8
+ "payload": null,
9
+ "duration": null
10
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": "",
4
+ "prize_id": 37373,
5
+ "request_id": "00000000-0000-0000-0000-000000000000"
6
+ }
@@ -0,0 +1,9 @@
1
+ [
2
+ {
3
+ "errCode": 40004,
4
+ "errMessage": "Failed to spin. Max spins reached",
5
+ "saw_prize_id": null,
6
+ "jackpot_amount": null,
7
+ "first_spin_in_period": 1782287011000
8
+ }
9
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": ""
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 0,
3
+ "err_message": ""
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "err_code": 4,
3
+ "err_message": "Avatar is not available"
4
+ }
@@ -0,0 +1,115 @@
1
+ # avatarsCustomize — API (AvatarCustomizeResponse)
2
+
3
+ > Generates an AI-customized variant of a base avatar by applying an operator-defined style prompt, returning the CDN URL of the result.
4
+ > Import: `import { AvatarCustomizeResponse } from '@smartico/public-api'`
5
+ > Search terms: avatarsCustomize, avatars, AvatarCustomizeResponse, AvatarCustomizeErrorCode
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.avatarsCustomize(props: {
10
+ user_id: number;
11
+ prompt_id: number;
12
+ avatar_url: string;
13
+ avatar_real_id: number;
14
+ }): Promise<AvatarCustomizeResponse>
15
+ ```
16
+
17
+ ## Parameters
18
+ - `props.user_id` — Numeric Smartico user ID.
19
+ - `props.prompt_id` — Style-prompt ID (`prompt_id`) from `getAvatarPrompts`.
20
+ - `props.avatar_url` — CDN URL of the base avatar to customize.
21
+ - `props.avatar_real_id` — `avatar_real_id` of the base avatar.
22
+
23
+ ## Returns — `Promise<AvatarCustomizeResponse>`
24
+ `AvatarCustomizeResponse`:
25
+ - `cdn_url` (string) — CDN URL of the generated avatar variant. Present on success.
26
+ - `errCode` (AvatarCustomizeErrorCode | number) — Error code. Present on failure. Typed values are members of `AvatarCustomizeErrorCode`; `-1` is a generic failure. See the `avatarsCustomize` TSDoc for the full table.
27
+ - `errMessage` (string) — Optional error message. Present on failure; the generic (`-1`) message is fixed text, so branch on `errCode`, not this string.
28
+
29
+ ## Behavioral contract
30
+ **Preconditions**
31
+ - Authenticated session required; not available in visitor mode (throws).
32
+ - All five fields are mandatory — the SDK throws synchronously
33
+ (`Error("<field> is required")`) if any is missing or zero.
34
+ - `prompt_id` must be one of the prompts from `getAvatarPrompts`;
35
+ `avatar_url` / `avatar_real_id` identify the base avatar to style.
36
+
37
+ **Cost**
38
+ Each generation costs the currency the operator configured on the
39
+ chosen prompt (points, gems, or diamonds — some prompts are free; read
40
+ `cost_currency_type_id` / `cost_value` from the `getAvatarPrompts`
41
+ entry to gate the UI before calling). The cost is charged only on
42
+ success; if the user can't afford it the call fails with `errCode -1`
43
+ and nothing is generated or charged.
44
+
45
+ **Latency**
46
+ Generation runs server-side AI image synthesis and is synchronous from
47
+ the caller's side — expect several seconds (roughly 5–20 s) before the
48
+ promise resolves. There is no SDK cache and no push/subscription; show
49
+ a loading state for the full duration and disable the trigger to
50
+ prevent duplicate submissions.
51
+
52
+ **Result & error codes**
53
+ On success the result has `cdn_url` set; on failure it has `errCode` /
54
+ `errMessage` set and no `cdn_url`. Branch on `errCode` — the generic
55
+ message is fixed text, not cause-specific:
56
+ - `12001` (`AvatarCustomizeErrorCode.AVATAR_USER_LIMIT`) — the user hit
57
+ their monthly per-user generation cap. Nothing is generated or charged.
58
+ - `12002` (`AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT`) — the brand's
59
+ shared monthly pool is exhausted. Nothing is generated or charged;
60
+ surface a "try again later" message.
61
+ - `-1` — generic failure: insufficient balance, an unavailable prompt,
62
+ or a generation error. Nothing is charged. Allow the user to retry.
63
+
64
+ Both monthly caps are operator-configured and reset at the start of
65
+ each calendar month.
66
+
67
+ **Side effects (on success)**
68
+ The generated variant is persisted to the user's customization history
69
+ and counts toward the monthly caps **whether or not** it is later
70
+ activated — generation is not reversible. The SDK clears the
71
+ `getAvatarsCustomized` cache so the next call surfaces the new
72
+ variant. The user's active avatar is unchanged until you call
73
+ `setAvatar` with the returned `cdn_url`.
74
+
75
+ **Idempotency**: not idempotent — each successful call generates (and
76
+ charges for) a new variant. Guard the call site against double-clicks.
77
+
78
+ **UI guidance**: see [UI Guide — `avatarsCustomize`](../../docs/ui/avatars/UIGuide_avatarsCustomize.md).
79
+
80
+ **Visitor mode**: not supported (throws).
81
+
82
+ ## Example
83
+ ```ts
84
+ // user_id identifies the Smartico user being customized.
85
+ const prompts = await window._smartico.api.getAvatarPrompts();
86
+ const prompt = prompts[0];
87
+
88
+ console.log('[smartico] generating avatar — show a spinner for ~5-20s and disable the Generate button');
89
+ const result = await window._smartico.api.avatarsCustomize({
90
+ user_id,
91
+ prompt_id: prompt.prompt_id,
92
+ avatar_url: baseAvatar.avatar_url,
93
+ avatar_real_id: baseAvatar.avatar_real_id,
94
+ });
95
+
96
+ if (result.cdn_url) {
97
+ console.log('[smartico] generation succeeded — preview this URL, then call setAvatar to apply it:', result.cdn_url);
98
+ // await window._smartico.api.setAvatar({ avatar_url: result.cdn_url, avatar_real_id: baseAvatar.avatar_real_id });
99
+ } else if (result.errCode === 12001) {
100
+ console.error('[smartico] user monthly limit reached — show "you have used all your custom avatars this month"');
101
+ } else if (result.errCode === 12002) {
102
+ console.error('[smartico] brand monthly pool exhausted — show "custom avatars are unavailable right now, try later"');
103
+ } else {
104
+ console.error('[smartico] generation failed (e.g. not enough balance) — let the user retry:', result.errMessage);
105
+ }
106
+ ```
107
+
108
+ ## Errors
109
+ See this method's TSDoc / the mutation pages for `err_code` handling.
110
+
111
+ ## Related
112
+ - `setAvatar`
113
+ - `getAvatarPrompts`
114
+ - `getAvatarsCustomized`
115
+ - `AvatarCustomizeResponse`
@@ -0,0 +1,179 @@
1
+ # buyStoreItem — API (TBuyStoreItemResult)
2
+
3
+ > Purchase a specific store item on behalf of the current user.
4
+ > Import: `import { TBuyStoreItemResult } from '@smartico/public-api'`
5
+ > Search terms: buyStoreItem, store, TBuyStoreItemResult, BuyStoreItemErrorCode, err_code, err_message
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.buyStoreItem(item_id: number): Promise<TBuyStoreItemResult>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `item_id` — The store item `id` (from `getStoreItems()`).
14
+
15
+ ## Returns — `Promise<TBuyStoreItemResult>`
16
+ `TBuyStoreItemResult`:
17
+ - `err_code` (BuyStoreItemErrorCode) — Error code. `0` = success. See `buyStoreItem` TSDoc for the full table.
18
+ - `err_message` (string) — Optional error message; populated on non-zero `err_code`.
19
+
20
+ ## Behavioral contract
21
+ **Preconditions**
22
+ Read the candidate item from `getStoreItems()` first and gate the call
23
+ on these fields:
24
+ - `can_buy === true` — server-derived; combines segment / visibility
25
+ conditions and any operator-set restrictions.
26
+ - `pool == null || pool > 0` — `null` means unlimited stock; a positive
27
+ number means N units remain.
28
+ - User's balance for the item's `purchase_type`
29
+ (`'points'` / `'gems'` / `'diamonds'`) is `>= price` (or
30
+ `>= discounted_price` if set). Balances are not on `TStoreItem` —
31
+ read them from the user properties returned by `getUserState()`.
32
+ - If `active_till_date` is set, it is in the future.
33
+
34
+ Calling without satisfying these will most likely return a non-zero
35
+ `err_code` (one of the codes below). The SDK does not pre-validate
36
+ — it forwards the request to the server unconditionally.
37
+
38
+
39
+
40
+ **Idempotency**: NOT idempotent. The server performs no de-duplication —
41
+ a second successful call deducts funds again and grants the reward
42
+ again (subject to per-user purchase caps). The SDK itself does **not**
43
+ enforce a single in-flight call. The consumer MUST guard the call site
44
+ against double-clicks (set a local "buying" flag on click, clear it on
45
+ response).
46
+
47
+ **Refresh after success (and after failure)**
48
+ The SDK automatically re-fetches the store item list and the
49
+ purchased-items history on every response (success or error). Any
50
+ `onUpdate` callback registered via `getStoreItems({ onUpdate })` (or
51
+ the purchased-items equivalent) fires shortly after with the updated
52
+ arrays — reflecting the new `pool`, `can_buy`, and any `purchased_*`
53
+ flags. The user's balance (points / gems / diamonds) is exposed on the
54
+ user-properties channel and updates independently; if the UI displays
55
+ the balance, subscribe to user-property updates separately (it does
56
+ NOT flow through `getStoreItems`).
57
+
58
+ **Side effects** (consumer-observable on success)
59
+ - User's points / gems / diamonds balance decreases by `price`
60
+ (or `discounted_price` if set).
61
+ - Item's `pool` decrements by 1 (when `pool != null`).
62
+ - Per-user purchase counters update — `purchased_today`,
63
+ `purchased_this_week`, `purchased_this_month` on the next
64
+ `getStoreItems()` refresh.
65
+ - The reward is delivered: bonus issuance, mini-game spin grant,
66
+ level change, prize drop, raffle ticket, or tangible-item record.
67
+ Each reward type pushes its own follow-up update (e.g. a new
68
+ bonus appears in `getBonuses()`, the spin shows up in
69
+ `getMiniGames()`). Subscribe to each relevant channel separately.
70
+ - A purchase row is appended to the user's purchase history,
71
+ surfaced via the purchased-items list.
72
+
73
+ **UI guidance**: see [UI Guide — `buyStoreItem`](../../docs/ui/store/UIGuide_buyStoreItem.md).
74
+
75
+ ## Example
76
+ ```ts
77
+ const items = await window._smartico.api.getStoreItems({
78
+ onUpdate: (next) => console.log('[smartico] store items updated — re-render store grid with this fresh array', next),
79
+ });
80
+ const item = items.find(i => i.id === itemId);
81
+
82
+ if (!item) {
83
+ console.log('[smartico] item not in current store list — keep UI as-is, possibly refresh getStoreItems');
84
+ return;
85
+ }
86
+
87
+ // Local pre-checks: keep these aligned with the Buy-button decision matrix above.
88
+ const effectivePrice = item.discounted_price ?? item.price;
89
+ const inStock = item.pool == null || item.pool > 0;
90
+ const inWindow = !item.active_till_date || Date.now() < item.active_till_date;
91
+ if (!item.can_buy || !inStock || !inWindow) {
92
+ console.log('[smartico] buy not applicable — show disabled state with operator copy if any:', item.cant_buy_message);
93
+ return;
94
+ }
95
+
96
+ console.log('[smartico] buy starting — set in-flight flag, show loading dots on Buy button, keep detail modal open');
97
+ const r = await window._smartico.api.buyStoreItem(item.id);
98
+ console.log('[smartico] buy response received — clear in-flight flag');
99
+
100
+ if (r.err_code === 0) {
101
+ console.log('[smartico] purchase successful — close the detail modal, show a success toast; getStoreItems onUpdate above will fire with the refreshed list (do NOT manually re-fetch)');
102
+ } else if (r.err_code === 11000 || r.err_code === 11011 || r.err_code === 11012) {
103
+ console.error('[smartico] insufficient balance for this purchase_type — show insufficient-balance UI and how many units are missing:', item.purchase_type, effectivePrice);
104
+ } else if (r.err_code === 11009) {
105
+ console.error('[smartico] item sold out — show a dedicated "Sold out" message; the auto-refresh will mark the card as such shortly');
106
+ } else if (r.err_code === 11006) {
107
+ console.error('[smartico] per-user purchase cap reached — surface the operator-defined limit message:', item.limit_message || r.err_message);
108
+ } else if (r.err_code === 11014) {
109
+ console.error('[smartico] outside purchase window — surface the operator-defined purchase-limit message:', item.purchase_limit_message || r.err_message);
110
+ } else if (r.err_code === 11004 || r.err_code === 11003) {
111
+ console.error('[smartico] user not eligible / stale visibility — show a localized "try again later" message and let auto-refresh reconcile');
112
+ } else {
113
+ console.error('[smartico] buy failed — show a generic error toast/modal with this message:', r.err_message);
114
+ }
115
+ ```
116
+
117
+ ### Example response (REAL shape)
118
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
119
+ ```json
120
+ {
121
+ "err_code": 11002,
122
+ "err_message": "This bonus cannot be redeemed.You must make at least one real money deposit between redemption of consecutive free bonuses.Please contact support for more in…"
123
+ }
124
+ ```
125
+
126
+ ## Errors
127
+ **Error codes** (in `err_code`)
128
+ - `0` — success; funds debited and reward delivered.
129
+ - `1` — generic server error / control-group rejection. Treat as a
130
+ transient failure; show a "try again later" message.
131
+ - `106` — label mismatch detected before the purchase transaction
132
+ (e.g. cross-label item id). From a consumer perspective: the item is
133
+ not purchasable by this user.
134
+ - `11000` (`SHOP_NO_BALANCE`) — insufficient **points** balance.
135
+ Show an insufficient-balance message that names how many points are
136
+ missing (`price - current_points_balance`). The Buy button on the
137
+ item should already be disabled when this is the case; this code
138
+ normally fires only on a stale local balance.
139
+ - `11001` (`SHOP_WRONG_LABEL`) — user-vs-item label mismatch detected
140
+ inside the purchase transaction. Distinct from `106`; both mean
141
+ "not purchasable by this user" from the consumer's perspective.
142
+ Surface as a generic "item not available" message.
143
+ - `11002` (`SHOP_FAILED_TO_BUY_BONUS`) — the bonus configured on the
144
+ store item couldn't be issued (bad / disabled bonus config on the
145
+ operator side). Funds are NOT debited. Surface a generic error and
146
+ advise the user to contact support if it persists.
147
+ - `11003` (`SHOP_FAILED_TO_BUY_SHOP_ITEM_CONDITION`) — the item's
148
+ **visibility** segment condition is not satisfied. Shouldn't be
149
+ reachable through a correctly-rendered UI (the item shouldn't be
150
+ shown in the first place); usually indicates a stale local store
151
+ list. Re-fetch via `getStoreItems()`.
152
+ - `11004` (`SHOP_FAILED_TO_BUY_SHOP_ITEM_CONDITION_PURSHASE`) — the
153
+ item's **purchase** segment condition is not satisfied (the item is
154
+ visible but the user is not in the buyable segment). Surface a
155
+ localized "try again later" / "you're not eligible" message; do not
156
+ retry automatically.
157
+ - `11005` (`SHOP_FAILED_TO_BUY_MATCHING_BONUS`) — matching-bonus
158
+ coupon issuance failed (variant of `11002` for matching-deposit
159
+ bonuses). Funds are NOT debited. Surface a generic error.
160
+ - `11006` (`SHOP_FAILED_MAX_BOUGHT_ITEMS_REACHED`) — per-user purchase
161
+ cap reached (e.g. "max 1 per day"). Surface the item's
162
+ `limit_message` if set, otherwise `err_message`. Do not retry.
163
+ - `11007` — bonus was issued but a follow-up redemption step failed
164
+ server-side. Funds **are** debited and the purchase event is recorded;
165
+ the consumer's UI should refresh the store list (auto-refresh will
166
+ fire) and surface a soft warning rather than a hard error.
167
+ - `11009` (`SHOP_FAILED_POOL_EMPTY`) — stock pool is empty / sold out.
168
+ Show a "sold out" message; auto-refresh will mark the item as such
169
+ in subsequent `getStoreItems()` updates.
170
+ - `11011` (`SHOP_NO_BALANCE_GEMS`) — insufficient **gems** balance.
171
+ Same handling as `11000` but for the gems currency.
172
+ - `11012` (`SHOP_NO_BALANCE_DIAMONDS`) — insufficient **diamonds**
173
+ balance. Same handling as `11000` but for the diamonds currency.
174
+ - `11014` (`SHOP_FAILED_PURCHASE_LIMITATION`) — outside the configured
175
+ purchase window (purchase weekday / time-of-day / window). Surface
176
+ the item's `purchase_limit_message` if set, otherwise `err_message`.
177
+ - `9999` — uncaught server exception. Treat as a transient failure;
178
+ surface a generic error and allow retry.
179
+ - other non-zero — generic server error. Surface `err_message` if any.
@@ -0,0 +1,69 @@
1
+ # checkSegmentListMatch — API (TSegmentCheckResult)
2
+
3
+ > Checks the current user's membership in multiple segments in a single server round-trip — returns a `TSegmentCheckResult[]` with one entry per *unique* segment ID.
4
+ > Import: `import { TSegmentCheckResult } from '@smartico/public-api'`
5
+ > Search terms: checkSegmentListMatch, user, TSegmentCheckResult
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `segment_ids` — Array of segment IDs to check. Duplicates are silently de-duplicated server-side. Segment IDs are label-scoped — use the IDs configured for your label.
14
+
15
+ ## Returns — `Promise<TSegmentCheckResult[]>`
16
+ Array of `TSegmentCheckResult`. Each item:
17
+ - `segment_id` (number) — The segment ID this result refers to (label-scoped).
18
+ - `is_matching` (boolean) — `true` if the user currently matches this segment. `false` also covers the case where the segment doesn't exist for the label — the two are not distinguishable.
19
+
20
+ ## Behavioral contract
21
+ **Response order is NOT guaranteed**
22
+ The server returns results in an unspecified order — different
23
+ from the input array. Always correlate by the `segment_id` field on
24
+ each `TSegmentCheckResult` rather than by array position. The
25
+ returned array length may also be smaller than the input array
26
+ (duplicate IDs are silently de-duplicated server-side).
27
+
28
+ **Single round-trip**
29
+ The entire `segment_ids` array is sent in one request. Two segments
30
+ cost the same as one in terms of network latency and rate-limit
31
+ consumption (one call = one rate-limit slot, regardless of how many
32
+ segments).
33
+
34
+ **Shared semantics with `checkSegmentMatch`**
35
+ Both methods wrap the same underlying server endpoint and share
36
+ the same caching, refresh, rate-limit, and ambiguity behavior. See
37
+ `checkSegmentMatch` for: no client cache · no push event for
38
+ membership changes · behavioral segments have batch lag · rate
39
+ limit (10 requests / 60 s, ~5 s minimum gap between calls) ·
40
+ `is_matching: false` doesn't distinguish "not in segment" from
41
+ "segment doesn't exist for this label".
42
+
43
+ **Idempotency**: safe. Read-only. No side effects.
44
+
45
+ **Visitor mode**: not supported.
46
+
47
+ ## Example
48
+ ```ts
49
+ const segmentIds = [vipSegmentId, newPlayerSegmentId, freeRollSegmentId];
50
+ const results = await window._smartico.api.checkSegmentListMatch(segmentIds);
51
+
52
+ // Always correlate by segment_id — the response order is unspecified.
53
+ const byId = new Map(results.map(r => [r.segment_id, r.is_matching]));
54
+
55
+ if (byId.get(vipSegmentId)) {
56
+ console.log('[smartico] user is in VIP segment — render VIP surface');
57
+ }
58
+ if (byId.get(newPlayerSegmentId) && byId.get(freeRollSegmentId)) {
59
+ console.log('[smartico] new player AND eligible for free roll — show the welcome promo');
60
+ }
61
+
62
+ // Cache the result map for the session; refresh on material state changes.
63
+ ```
64
+
65
+ ## Errors
66
+ See this method's TSDoc / the mutation pages for `err_code` handling.
67
+
68
+ ## Related
69
+ - `checkSegmentMatch`
@@ -0,0 +1,74 @@
1
+ # checkSegmentMatch — API
2
+
3
+ > Checks whether the current user matches a single segment, returning `true` / `false` directly.
4
+ > Import: `import { /* types */ } from '@smartico/public-api'`
5
+ > Search terms: checkSegmentMatch, user
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.checkSegmentMatch(segment_id: number): Promise<boolean>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `segment_id` — The segment ID. Segment IDs are label-scoped; the same numeric ID can refer to different segments under different labels. Use the IDs configured for your label.
14
+
15
+ ## Returns
16
+ Resolves to `boolean`.
17
+
18
+ ## Behavioral contract
19
+ **Refresh model**
20
+ - **No client cache.** Every call sends a request; the SDK does not
21
+ memoize results.
22
+ - **No push event** notifies the consumer when segment membership
23
+ flips (the user crosses a qualification threshold, or the
24
+ operator changes the segment definition). Membership changes
25
+ become visible only on the next `checkSegmentMatch` call.
26
+ - **Behavioral segments (configured against BigQuery) have batch
27
+ lag** — even if the user's activity has changed (deposit, wager,
28
+ etc.), the segment-membership result may not reflect that change
29
+ until the next batch evaluation run (typically up to several
30
+ hours).
31
+
32
+ **Rate limit** (important)
33
+ The server caps `checkSegment*` calls at **10 requests per
34
+ 60-second window**, with a minimum gap of **~5 seconds between
35
+ consecutive calls**. Avoid calling on every render — cache the
36
+ result client-side for the session, or until you have a reason to
37
+ believe the user's state changed (e.g. after a deposit completes,
38
+ a level changes via `getUserProfile`'s `props_change`, or a
39
+ specific custom event fires).
40
+
41
+ **`is_matching: false` is ambiguous on the server** — both "the
42
+ segment doesn't exist for this label" and "the user doesn't
43
+ qualify" return `false` with no distinguishing signal. Pass IDs
44
+ you've verified are valid for your label.
45
+
46
+ **Idempotency**: safe. Read-only. No side effects (no analytics
47
+ events, no DB writes).
48
+
49
+ **Visitor mode**: not supported.
50
+
51
+ ## Example
52
+ ```ts
53
+ const isVip = await window._smartico.api.checkSegmentMatch(vipSegmentId);
54
+ if (isVip) {
55
+ console.log('[smartico] user is in VIP segment — render the VIP-only widget surface');
56
+ } else {
57
+ console.log('[smartico] user not in VIP segment (or segment id misconfigured) — hide the VIP surface');
58
+ }
59
+
60
+ // Cache the result for the session; re-check after material user-state changes.
61
+ window._smartico.on('props_change', async (changed) => {
62
+ if ('ach_points_ever' in changed || 'ach_level_current_id' in changed) {
63
+ const fresh = await window._smartico.api.checkSegmentMatch(vipSegmentId);
64
+ console.log('[smartico] user state changed — VIP membership now:', fresh);
65
+ }
66
+ });
67
+ ```
68
+
69
+ ## Errors
70
+ See this method's TSDoc / the mutation pages for `err_code` handling.
71
+
72
+ ## Related
73
+ - `checkSegmentListMatch`
74
+ - `getUserProfile`