@smartico/public-api 0.0.385 → 0.0.387
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
- package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
- package/dist/Avatars/index.d.ts +1 -0
- package/dist/Clans/JoinClanErrorCode.d.ts +21 -11
- package/dist/Missions/UserAchievementTask.d.ts +4 -0
- package/dist/SmarticoAPI.d.ts +11 -0
- package/dist/Tournaments/TournamentRegistrationError.d.ts +32 -2
- package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
- package/dist/WSAPI/WSAPIClans.d.ts +3 -5
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +3 -11
- package/dist/WSAPI/WSAPIMissions.d.ts +6 -0
- package/dist/WSAPI/WSAPITypes.d.ts +6 -2
- package/dist/WSAPI/WSAPIUser.d.ts +27 -16
- package/dist/index.js +362 -127
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +270 -55
- package/dist/index.modern.mjs.map +1 -1
- package/docs/SmarticoObject.md +15 -0
- package/docs/api/README.md +2 -0
- package/docs/api/classes/WSAPIAvatars.md +135 -0
- package/docs/api/classes/WSAPIClans.md +3 -5
- package/docs/api/classes/WSAPILeaderBoard.md +3 -11
- package/docs/api/classes/WSAPIMissions.md +9 -0
- package/docs/api/classes/WSAPIUser.md +27 -16
- package/docs/api/documents/SmarticoObject.md +15 -0
- package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
- package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
- package/docs/api/enumerations/TournamentRegistrationError.md +47 -2
- package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
- package/docs/api/interfaces/TAvatarPrompt.md +2 -2
- package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
- package/docs/api/interfaces/UserAchievementTask.md +16 -0
- package/docs/native/PROTOCOL.md +3 -1
- package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
- package/docs/ui/clans/UIGuide_joinClan.md +1 -2
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +15 -14
- package/package.json +1 -1
- package/src/Avatars/AvatarCustomizeErrorCode.ts +7 -5
- package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
- package/src/Avatars/index.ts +1 -0
- package/src/Clans/JoinClanErrorCode.ts +20 -14
- package/src/Missions/UserAchievement.ts +2 -0
- package/src/Missions/UserAchievementTask.ts +4 -0
- package/src/SmarticoAPI.ts +53 -0
- package/src/Tournaments/TournamentRegistrationError.ts +32 -4
- package/src/WSAPI/WSAPI.ts +3 -1
- package/src/WSAPI/WSAPIAvatars.ts +121 -0
- package/src/WSAPI/WSAPIClans.ts +3 -5
- package/src/WSAPI/WSAPILeaderBoard.ts +7 -12
- package/src/WSAPI/WSAPIMissions.ts +12 -0
- package/src/WSAPI/WSAPITypes.ts +6 -2
- package/src/WSAPI/WSAPIUser.ts +27 -16
- package/tsconfig.json +3 -1
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ The SDK surface is split across one class per feature area, joined by an interna
|
|
|
74
74
|
| **Jackpots** | [`WSAPIJackpots`](docs/api/classes/WSAPIJackpots.md) | `jackpotGet`, `jackpotOptIn`, `jackpotOptOut`, `getJackpotWinners`, `getJackpotEligibleGames` | [`jackpotGet`](docs/ui/jackpots/UIGuide_jackpotGet.md) · [`jackpotOptIn`](docs/ui/jackpots/UIGuide_jackpotOptIn.md) · [`jackpotOptOut`](docs/ui/jackpots/UIGuide_jackpotOptOut.md) · [`getJackpotWinners`](docs/ui/jackpots/UIGuide_getJackpotWinners.md) · [`getJackpotEligibleGames`](docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md) |
|
|
75
75
|
| **Raffles / Draws** | [`WSAPIRaffles`](docs/api/classes/WSAPIRaffles.md) | `getRaffles`, `getRaffleDrawRun`, `getRaffleDrawRunsHistory`, `claimRafflePrize`, `requestRaffleOptin`, `getRaffleWonPrizes` | [`getRaffles`](docs/ui/raffles/UIGuide_getRaffles.md) · [`getRaffleDrawRun`](docs/ui/raffles/UIGuide_getRaffleDrawRun.md) · [`getRaffleDrawRunsHistory`](docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md) · [`claimRafflePrize`](docs/ui/raffles/UIGuide_claimRafflePrize.md) · [`requestRaffleOptin`](docs/ui/raffles/UIGuide_requestRaffleOptin.md) · [`getRaffleWonPrizes`](docs/ui/raffles/UIGuide_getRaffleWonPrizes.md) |
|
|
76
76
|
| **MiniGames / SAW** | [`WSAPIMiniGames`](docs/api/classes/WSAPIMiniGames.md) | `getMiniGames`, `getMiniGamesHistory`, `playMiniGame`, `miniGameWinAcknowledgeRequest`, `playMiniGameBatch` | [`getMiniGames`](docs/ui/minigames/UIGuide_getMiniGames.md) · [`getMiniGamesHistory`](docs/ui/minigames/UIGuide_getMiniGamesHistory.md) · [`playMiniGame`](docs/ui/minigames/UIGuide_playMiniGame.md) · [`playMiniGameBatch`](docs/ui/minigames/UIGuide_playMiniGameBatch.md) |
|
|
77
|
-
| **Avatars** | [`WSAPIAvatars`](docs/api/classes/WSAPIAvatars.md) | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar` | [`getAvatarsList`](docs/ui/avatars/UIGuide_getAvatarsList.md) · [`getAvatarsCustomized`](docs/ui/avatars/UIGuide_getAvatarsCustomized.md) · [`getAvatarPrompts`](docs/ui/avatars/UIGuide_getAvatarPrompts.md) · [`setAvatar`](docs/ui/avatars/UIGuide_setAvatar.md) |
|
|
77
|
+
| **Avatars** | [`WSAPIAvatars`](docs/api/classes/WSAPIAvatars.md) | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar`, `avatarsCustomize` | [`getAvatarsList`](docs/ui/avatars/UIGuide_getAvatarsList.md) · [`getAvatarsCustomized`](docs/ui/avatars/UIGuide_getAvatarsCustomized.md) · [`getAvatarPrompts`](docs/ui/avatars/UIGuide_getAvatarPrompts.md) · [`setAvatar`](docs/ui/avatars/UIGuide_setAvatar.md) · [`avatarsCustomize`](docs/ui/avatars/UIGuide_avatarsCustomize.md) |
|
|
78
78
|
| **Game Pick (sports / quiz)** | [`WSAPIGamePick`](docs/api/classes/WSAPIGamePick.md) | `gamePickGet*`, `gamePickSubmit*` (9 methods) | [`gamePickGetActiveRounds`](docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md) · [`gamePickGetActiveRound`](docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md) · [`gamePickGetHistory`](docs/ui/gamepick/UIGuide_gamePickGetHistory.md) · [`gamePickGetBoard`](docs/ui/gamepick/UIGuide_gamePickGetBoard.md) · [`gamePickSubmitSelection`](docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md) · [`gamePickSubmitSelectionQuiz`](docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md) · [`gamePickGetUserInfo`](docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md) · [`gamePickGetGameInfo`](docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md) · [`gamePickGetRoundInfoForUser`](docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md) |
|
|
79
79
|
| **Leaderboard** | [`WSAPILeaderBoard`](docs/api/classes/WSAPILeaderBoard.md) | `getLeaderBoard` | [`getLeaderBoard`](docs/ui/leaderboard/UIGuide_getLeaderBoard.md) |
|
|
80
80
|
| **Inbox / Messages / Engagement** | [`WSAPIInbox`](docs/api/classes/WSAPIInbox.md) | `getInboxMessages`, `getInboxUnreadCount`, `getInboxMessageBody`, `markInboxMessageAsRead`, `markAllInboxMessagesAsRead`, `markUnmarkInboxMessageAsFavorite`, `deleteInboxMessage`, `deleteAllInboxMessages`, `reportImpressionEvent`, `reportClickEvent` | [`getInboxMessages`](docs/ui/inbox/UIGuide_getInboxMessages.md) · [`getInboxMessageBody`](docs/ui/inbox/UIGuide_getInboxMessageBody.md) · [`markInboxMessageAsRead`](docs/ui/inbox/UIGuide_markInboxMessageAsRead.md) · [`markUnmarkInboxMessageAsFavorite`](docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md) · [`deleteInboxMessage`](docs/ui/inbox/UIGuide_deleteInboxMessage.md) |
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limit error codes returned in `errCode` by the `avatarsCustomize` method.
|
|
3
|
+
* See the `avatarsCustomize` TSDoc for the full table (including the generic
|
|
4
|
+
* `-1` failure, which has no named member here).
|
|
5
|
+
*/
|
|
1
6
|
export declare enum AvatarCustomizeErrorCode {
|
|
7
|
+
/** The user has reached the operator-configured per-user monthly cap on custom-avatar generations. */
|
|
2
8
|
AVATAR_USER_LIMIT = 12001,
|
|
9
|
+
/** The brand's operator-configured shared monthly pool of custom-avatar generations is exhausted. */
|
|
3
10
|
AVATAR_LABEL_LIMIT = 12002
|
|
4
11
|
}
|
|
5
|
-
export declare const AvatarCustomizeErrorMessage: Record<AvatarCustomizeErrorCode, string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AvatarCustomizeErrorCode } from './AvatarCustomizeErrorCode';
|
|
2
|
+
/**
|
|
3
|
+
* Result of `_smartico.api.avatarsCustomize()`. On success only `cdn_url` is
|
|
4
|
+
* set; on failure only `errCode` / `errMessage`.
|
|
5
|
+
*/
|
|
6
|
+
export interface AvatarCustomizeResponse {
|
|
7
|
+
/** CDN URL of the generated avatar variant. Present on success. */
|
|
8
|
+
cdn_url?: string;
|
|
9
|
+
/** Error code. Present on failure. Typed values are members of
|
|
10
|
+
* {@link AvatarCustomizeErrorCode}; `-1` is a generic failure. See the
|
|
11
|
+
* `avatarsCustomize` TSDoc for the full table. */
|
|
12
|
+
errCode?: AvatarCustomizeErrorCode | number;
|
|
13
|
+
/** Optional error message. Present on failure; the generic (`-1`) message
|
|
14
|
+
* is fixed text, so branch on `errCode`, not this string. */
|
|
15
|
+
errMessage?: string;
|
|
16
|
+
}
|
package/dist/Avatars/index.d.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes returned in `errCode` by the `joinClan` method (also carried
|
|
3
|
+
* on `TClanJoinResult`). These are terse value definitions for lookup; the
|
|
4
|
+
* full per-code narrative and UI handling lives in the `joinClan` method
|
|
5
|
+
* TSDoc, which owns the error table.
|
|
6
|
+
*/
|
|
1
7
|
export declare enum JoinClanErrorCode {
|
|
2
|
-
/**
|
|
8
|
+
/** Success — join completed; entry fee (if any) deducted. */
|
|
3
9
|
JOIN_CLAN_OK = 0,
|
|
4
|
-
/**
|
|
10
|
+
/** Request was malformed (missing or invalid parameters). */
|
|
5
11
|
JOIN_CLAN_INVALID_PARAMETERS = 1000,
|
|
6
|
-
/**
|
|
12
|
+
/** Clan doesn't exist for this label. Archived clans are also reported as `1001`. */
|
|
7
13
|
JOIN_CLAN_NOT_FOUND = 1001,
|
|
8
|
-
/**
|
|
14
|
+
/** Clan is full — member capacity reached. */
|
|
9
15
|
JOIN_CLAN_FULL = 1002,
|
|
10
|
-
/**
|
|
16
|
+
/** Insufficient balance for the entry fee (points / gems / diamonds). */
|
|
11
17
|
JOIN_CLAN_INSUFFICIENT_FUNDS = 1003,
|
|
12
|
-
/** User doesn't
|
|
18
|
+
/** User doesn't meet the clan's entry segment or conditions. */
|
|
13
19
|
JOIN_CLAN_SEGMENT_MISMATCH = 1004,
|
|
14
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* User is not in a clan. Note: a `registerInTournament` response code
|
|
22
|
+
* that shares this enum — never returned by `joinClan`.
|
|
23
|
+
*/
|
|
15
24
|
JOIN_CLAN_USER_IS_NOT_IN_CLAN = 1005,
|
|
16
|
-
/** User is within the
|
|
25
|
+
/** User is within the clan-switch cooldown window (switch only). */
|
|
17
26
|
JOIN_CLAN_COOLDOWN_ACTIVE = 1006,
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Clan joined after tournament start. Note: a `registerInTournament`
|
|
29
|
+
* response code that shares this enum — never returned by `joinClan`.
|
|
30
|
+
*/
|
|
21
31
|
JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START = 1011
|
|
22
32
|
}
|
|
@@ -5,6 +5,10 @@ export interface UserAchievementTask {
|
|
|
5
5
|
task_id?: number;
|
|
6
6
|
task_public_meta?: AchievementTaskPublicMeta;
|
|
7
7
|
points_reward?: number;
|
|
8
|
+
/** Gems awarded when this task is completed. */
|
|
9
|
+
gems_reward?: number;
|
|
10
|
+
/** Diamonds awarded when this task is completed. */
|
|
11
|
+
diamonds_reward?: number;
|
|
8
12
|
task_type_id: AchievementTaskType;
|
|
9
13
|
isCompleted?: boolean;
|
|
10
14
|
userExecutedCount?: number;
|
package/dist/SmarticoAPI.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { GetAvatarsListResponse } from './Avatars/GetAvatarsListResponse';
|
|
|
28
28
|
import { GetAvatarsCustomizedResponse } from './Avatars/GetAvatarsCustomizedResponse';
|
|
29
29
|
import { GetAvatarPromptsResponse } from './Avatars/GetAvatarPromptsResponse';
|
|
30
30
|
import { SetAvatarResponse } from './Avatars';
|
|
31
|
+
import { AvatarCustomizeResponse } from './Avatars/AvatarCustomizeResponse';
|
|
31
32
|
import { GetJackpotWinnersResponse, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
|
|
32
33
|
import { GetJackpotEligibleGamesResponse, TGetJackpotEligibleGamesResponse } from './Jackpots/GetJackpotEligibleGamesResponse';
|
|
33
34
|
import { GamePickGameInfo, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamesApiResponse } from './GamePick';
|
|
@@ -61,6 +62,7 @@ declare class SmarticoAPI {
|
|
|
61
62
|
private gamesApiUrl;
|
|
62
63
|
private baseRgApiParams;
|
|
63
64
|
avatarDomain: string;
|
|
65
|
+
private avatarOriginDomain;
|
|
64
66
|
private envId;
|
|
65
67
|
private logger;
|
|
66
68
|
private logCIDs;
|
|
@@ -76,6 +78,7 @@ declare class SmarticoAPI {
|
|
|
76
78
|
static getPublicUrl(label_api_key: string): string;
|
|
77
79
|
static getPublicWsUrl(label_api_key: string): string;
|
|
78
80
|
static getAvatarUrl(label_api_key: string): string;
|
|
81
|
+
static getAvatarOriginUrl(label_api_key: string): string;
|
|
79
82
|
private send;
|
|
80
83
|
private buildMessage;
|
|
81
84
|
coreReportCustomEvent(user_ext_id: string, eventType: string, payload?: any): Promise<any>;
|
|
@@ -175,6 +178,7 @@ declare class SmarticoAPI {
|
|
|
175
178
|
deleteAllInboxMessages(user_ext_id: string): Promise<MarkInboxMessageDeletedResponse>;
|
|
176
179
|
private buildGamesApiParams;
|
|
177
180
|
private sendGamesApi;
|
|
181
|
+
private sendAvatarApi;
|
|
178
182
|
gpGetActiveRounds(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>>;
|
|
179
183
|
gpGetActiveRound(saw_template_id: number, round_id?: number): Promise<GamesApiResponse<GamePickRound>>;
|
|
180
184
|
gpGetGamesHistory(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>>;
|
|
@@ -188,6 +192,13 @@ declare class SmarticoAPI {
|
|
|
188
192
|
avatarsGetCustomized(user_ext_id: string): Promise<GetAvatarsCustomizedResponse>;
|
|
189
193
|
avatarsGetPrompts(user_ext_id: string): Promise<GetAvatarPromptsResponse>;
|
|
190
194
|
avatarSetAvatar(user_ext_id: string, avatar_id: string, avatar_real_id: number): Promise<SetAvatarResponse>;
|
|
195
|
+
avatarsCustomize(params: {
|
|
196
|
+
label_id: number;
|
|
197
|
+
user_id: number;
|
|
198
|
+
prompt_id: number;
|
|
199
|
+
avatar_url: string;
|
|
200
|
+
avatar_real_id: number;
|
|
201
|
+
}): Promise<AvatarCustomizeResponse>;
|
|
191
202
|
avatarsGetListT(user_ext_id: string): Promise<TAvatarDefinition[]>;
|
|
192
203
|
avatarsGetCustomizedT(user_ext_id: string): Promise<TAvatarCustomized[]>;
|
|
193
204
|
avatarsGetPromptsT(user_ext_id: string): Promise<TAvatarPrompt[]>;
|
|
@@ -1,14 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes returned in `err_code` by the `registerInTournament` method.
|
|
3
|
+
*
|
|
4
|
+
* These are terse value definitions for lookup. The full per-code narrative —
|
|
5
|
+
* when each fires and how the consumer's UI should react — lives in the
|
|
6
|
+
* `registerInTournament` method TSDoc, which owns the error table.
|
|
7
|
+
*
|
|
8
|
+
* Note the numbering break: the gems / diamonds codes are 6-digit
|
|
9
|
+
* (`300010` / `300011`) while the rest of the tournament block is 5-digit;
|
|
10
|
+
* they were appended after the original `30001`–`30009` range was occupied.
|
|
11
|
+
* Branch on the exact numeric value, not on digit count.
|
|
12
|
+
*/
|
|
1
13
|
export declare enum TournamentRegistrationError {
|
|
14
|
+
/** Success — registration persisted; buy-in (if any) deducted. */
|
|
2
15
|
NO_ERROR = 0,
|
|
16
|
+
/** Clan-based tournament and the user does not belong to a clan yet. */
|
|
3
17
|
TOURNAMENT_USER_CANNOT_JOIN_WITHOUT_CLAN = 1010,
|
|
18
|
+
/** Instance id is invalid or the tournament was deleted. */
|
|
4
19
|
TOURNAMENT_INSTANCE_NOT_FOUND = 30001,
|
|
20
|
+
/** Insufficient points balance for a points-priced buy-in. */
|
|
5
21
|
TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS = 30002,
|
|
22
|
+
/** Tournament is no longer in a registerable state (finished, cancelled, finalizing, or not yet open). */
|
|
6
23
|
TOURNAMENT_INSTANCE_NOT_IN_STATE = 30003,
|
|
24
|
+
/** User is already registered; treat as an idempotent success. */
|
|
7
25
|
TOURNAMENT_ALREADY_REGISTERED = 30004,
|
|
26
|
+
/** User does not satisfy the tournament's segment / entry conditions. */
|
|
8
27
|
TOURNAMENT_USER_DONT_MATCH_CONDITIONS = 30005,
|
|
28
|
+
/** User is not registered; anomalous on a register call (usually a server-side race). */
|
|
9
29
|
TOURNAMENT_USER_NOT_REGISTERED = 30006,
|
|
30
|
+
/** Registration status transition is not allowed (e.g. re-registering a finished tournament). */
|
|
10
31
|
TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS = 30007,
|
|
32
|
+
/** Tournament filled up — maximum registrations reached. */
|
|
11
33
|
TOURNAMENT_MAX_REGISTRATIONS_REACHED = 30008,
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The user's wallet currency could not be resolved. Emitted server-side
|
|
36
|
+
* during tournament score processing, NOT during registration — it is
|
|
37
|
+
* never returned by `registerInTournament`. Included for completeness.
|
|
38
|
+
*/
|
|
39
|
+
TOURNAMENT_INVALID_USER_CURRENCY = 30009,
|
|
40
|
+
/** Insufficient gems balance for a gems-priced buy-in. */
|
|
41
|
+
TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS = 300010,
|
|
42
|
+
/** Insufficient diamonds balance for a diamonds-priced buy-in. */
|
|
43
|
+
TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS = 300011
|
|
14
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TAvatarDefinition, TAvatarCustomized, TAvatarPrompt, TSetAvatarResult } from './WSAPITypes';
|
|
2
2
|
import { WSAPIMiniGames } from './WSAPIMiniGames';
|
|
3
|
+
import { AvatarCustomizeResponse } from '../Avatars/AvatarCustomizeResponse';
|
|
3
4
|
/** @group Avatars */
|
|
4
5
|
export declare class WSAPIAvatars extends WSAPIMiniGames {
|
|
5
6
|
/**
|
|
@@ -293,4 +294,106 @@ export declare class WSAPIAvatars extends WSAPIMiniGames {
|
|
|
293
294
|
avatar_url: string;
|
|
294
295
|
avatar_real_id: number;
|
|
295
296
|
}): Promise<TSetAvatarResult>;
|
|
297
|
+
/**
|
|
298
|
+
* Generates an AI-customized variant of a base avatar by applying an
|
|
299
|
+
* operator-defined style prompt, returning the CDN URL of the result.
|
|
300
|
+
* This is a paid, generate-only step: it does NOT change the user's
|
|
301
|
+
* active avatar — pass the returned `cdn_url` to {@link setAvatar} to
|
|
302
|
+
* activate it.
|
|
303
|
+
*
|
|
304
|
+
* @remarks
|
|
305
|
+
* **Preconditions**
|
|
306
|
+
* - Authenticated session required; not available in visitor mode (throws).
|
|
307
|
+
* - All five fields are mandatory — the SDK throws synchronously
|
|
308
|
+
* (`Error("<field> is required")`) if any is missing or zero.
|
|
309
|
+
* - `prompt_id` must be one of the prompts from {@link getAvatarPrompts};
|
|
310
|
+
* `avatar_url` / `avatar_real_id` identify the base avatar to style.
|
|
311
|
+
*
|
|
312
|
+
* **Cost**
|
|
313
|
+
* Each generation costs the currency the operator configured on the
|
|
314
|
+
* chosen prompt (points, gems, or diamonds — some prompts are free; read
|
|
315
|
+
* `cost_currency_type_id` / `cost_value` from the {@link getAvatarPrompts}
|
|
316
|
+
* entry to gate the UI before calling). The cost is charged only on
|
|
317
|
+
* success; if the user can't afford it the call fails with `errCode -1`
|
|
318
|
+
* and nothing is generated or charged.
|
|
319
|
+
*
|
|
320
|
+
* **Latency**
|
|
321
|
+
* Generation runs server-side AI image synthesis and is synchronous from
|
|
322
|
+
* the caller's side — expect several seconds (roughly 5–20 s) before the
|
|
323
|
+
* promise resolves. There is no SDK cache and no push/subscription; show
|
|
324
|
+
* a loading state for the full duration and disable the trigger to
|
|
325
|
+
* prevent duplicate submissions.
|
|
326
|
+
*
|
|
327
|
+
* **Result & error codes**
|
|
328
|
+
* On success the result has `cdn_url` set; on failure it has `errCode` /
|
|
329
|
+
* `errMessage` set and no `cdn_url`. Branch on `errCode` — the generic
|
|
330
|
+
* message is fixed text, not cause-specific:
|
|
331
|
+
* - `12001` (`AvatarCustomizeErrorCode.AVATAR_USER_LIMIT`) — the user hit
|
|
332
|
+
* their monthly per-user generation cap. Nothing is generated or charged.
|
|
333
|
+
* - `12002` (`AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT`) — the brand's
|
|
334
|
+
* shared monthly pool is exhausted. Nothing is generated or charged;
|
|
335
|
+
* surface a "try again later" message.
|
|
336
|
+
* - `-1` — generic failure: insufficient balance, an unavailable prompt,
|
|
337
|
+
* or a generation error. Nothing is charged. Allow the user to retry.
|
|
338
|
+
*
|
|
339
|
+
* Both monthly caps are operator-configured and reset at the start of
|
|
340
|
+
* each calendar month.
|
|
341
|
+
*
|
|
342
|
+
* **Side effects (on success)**
|
|
343
|
+
* The generated variant is persisted to the user's customization history
|
|
344
|
+
* and counts toward the monthly caps **whether or not** it is later
|
|
345
|
+
* activated — generation is not reversible. The SDK clears the
|
|
346
|
+
* {@link getAvatarsCustomized} cache so the next call surfaces the new
|
|
347
|
+
* variant. The user's active avatar is unchanged until you call
|
|
348
|
+
* {@link setAvatar} with the returned `cdn_url`.
|
|
349
|
+
*
|
|
350
|
+
* **Idempotency**: not idempotent — each successful call generates (and
|
|
351
|
+
* charges for) a new variant. Guard the call site against double-clicks.
|
|
352
|
+
*
|
|
353
|
+
* **UI guidance**: see [UI Guide — `avatarsCustomize`](../../docs/ui/avatars/UIGuide_avatarsCustomize.md).
|
|
354
|
+
*
|
|
355
|
+
* **Visitor mode**: not supported (throws).
|
|
356
|
+
*
|
|
357
|
+
* @param props.label_id Numeric Smartico label (brand) ID the user belongs to.
|
|
358
|
+
* @param props.user_id Numeric Smartico user ID.
|
|
359
|
+
* @param props.prompt_id Style-prompt ID (`prompt_id`) from {@link getAvatarPrompts}.
|
|
360
|
+
* @param props.avatar_url CDN URL of the base avatar to customize.
|
|
361
|
+
* @param props.avatar_real_id `avatar_real_id` of the base avatar.
|
|
362
|
+
* @returns {@link AvatarCustomizeResponse} — `cdn_url` set on success;
|
|
363
|
+
* `errCode` / `errMessage` set on failure.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* // label_id / user_id identify the Smartico user being customized.
|
|
368
|
+
* const prompts = await window._smartico.api.getAvatarPrompts();
|
|
369
|
+
* const prompt = prompts[0];
|
|
370
|
+
*
|
|
371
|
+
* console.log('[smartico] generating avatar — show a spinner for ~5-20s and disable the Generate button');
|
|
372
|
+
* const result = await window._smartico.api.avatarsCustomize({
|
|
373
|
+
* label_id,
|
|
374
|
+
* user_id,
|
|
375
|
+
* prompt_id: prompt.prompt_id,
|
|
376
|
+
* avatar_url: baseAvatar.avatar_url,
|
|
377
|
+
* avatar_real_id: baseAvatar.avatar_real_id,
|
|
378
|
+
* });
|
|
379
|
+
*
|
|
380
|
+
* if (result.cdn_url) {
|
|
381
|
+
* console.log('[smartico] generation succeeded — preview this URL, then call setAvatar to apply it:', result.cdn_url);
|
|
382
|
+
* // await window._smartico.api.setAvatar({ avatar_url: result.cdn_url, avatar_real_id: baseAvatar.avatar_real_id });
|
|
383
|
+
* } else if (result.errCode === 12001) {
|
|
384
|
+
* console.error('[smartico] user monthly limit reached — show "you have used all your custom avatars this month"');
|
|
385
|
+
* } else if (result.errCode === 12002) {
|
|
386
|
+
* console.error('[smartico] brand monthly pool exhausted — show "custom avatars are unavailable right now, try later"');
|
|
387
|
+
* } else {
|
|
388
|
+
* console.error('[smartico] generation failed (e.g. not enough balance) — let the user retry:', result.errMessage);
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
avatarsCustomize(props: {
|
|
393
|
+
label_id: number;
|
|
394
|
+
user_id: number;
|
|
395
|
+
prompt_id: number;
|
|
396
|
+
avatar_url: string;
|
|
397
|
+
avatar_real_id: number;
|
|
398
|
+
}): Promise<AvatarCustomizeResponse>;
|
|
296
399
|
}
|
|
@@ -280,12 +280,10 @@ export declare class WSAPIClans extends WSAPITournaments {
|
|
|
280
280
|
* tournament requires the user to be in a clan first.
|
|
281
281
|
* - `1006` (`JOIN_CLAN_COOLDOWN_ACTIVE`) — user is inside the
|
|
282
282
|
* switch-cooldown window from a previous clan join (default
|
|
283
|
-
* 7 days, configurable per label).
|
|
283
|
+
* 7 days, configurable per label). Only reachable when the user is
|
|
284
|
+
* already in a *different* clan (this call is then a clan switch);
|
|
285
|
+
* a first-time join never returns `1006`. Surface the
|
|
284
286
|
* `TClans.cooldown_until` expiry in the disabled CTA.
|
|
285
|
-
* - `1007` (`JOIN_CLAN_ARCHIVED`) — defined on the public enum but
|
|
286
|
-
* the server does NOT emit this code in practice (archived clans
|
|
287
|
-
* are reported as `1001`). Handle it as a synonym for `1001`
|
|
288
|
-
* defensively, but do not rely on it.
|
|
289
287
|
* - `1011` (`JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START`) — this
|
|
290
288
|
* method does NOT return `1011` directly. The code fires on
|
|
291
289
|
* {@link registerInTournament} responses when the user joined
|
|
@@ -48,15 +48,8 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
48
48
|
* the array is the prize for place 1, the second for place 2, and
|
|
49
49
|
* so on. The array length is the number of paid places.
|
|
50
50
|
*
|
|
51
|
-
* **Cache TTL
|
|
52
|
-
* The SDK caches
|
|
53
|
-
* key — calling `getLeaderBoard(DAILY)` followed by
|
|
54
|
-
* `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
|
|
55
|
-
* cached DAILY result for the WEEKLY call. Same applies to
|
|
56
|
-
* switching `getPreviousPeriod`. To force a fresh fetch when
|
|
57
|
-
* switching periods or current/previous, call
|
|
58
|
-
* `_smartico.api.clearCaches()` before the second call, or simply
|
|
59
|
-
* wait out the TTL.
|
|
51
|
+
* **Cache TTL**
|
|
52
|
+
* The SDK caches each response for 30 seconds.
|
|
60
53
|
*
|
|
61
54
|
* **Period boundaries**
|
|
62
55
|
* The server finalizes each period on a server-configurable
|
|
@@ -126,8 +119,7 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
126
119
|
* }
|
|
127
120
|
* }
|
|
128
121
|
*
|
|
129
|
-
* // Switch to previous period view —
|
|
130
|
-
* await window._smartico.api.clearCaches();
|
|
122
|
+
* // Switch to previous period view — cached separately from the current period.
|
|
131
123
|
* const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
|
|
132
124
|
* console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
|
|
133
125
|
*
|
|
@@ -177,8 +177,14 @@ export declare class WSAPIMissions extends WSAPIGeneral {
|
|
|
177
177
|
* **Idempotency / Side effects**: fetch-only; safe to call repeatedly.
|
|
178
178
|
* The cache layer deduplicates concurrent calls within the TTL window.
|
|
179
179
|
*
|
|
180
|
+
* **Visitor mode**: not supported. Badges are an authenticated-only
|
|
181
|
+
* feature; calling this on the visitor-mode handle (`_smartico.vapi`)
|
|
182
|
+
* throws synchronously rather than silently returning an empty list.
|
|
183
|
+
*
|
|
180
184
|
* **UI guidance**: see [UI Guide — `getBadges`](../../docs/ui/missions/UIGuide_getBadges.md).
|
|
181
185
|
*
|
|
186
|
+
* @throws `Error("getBadges is not available in visitor mode")` when
|
|
187
|
+
* called from a visitor-mode session.
|
|
182
188
|
* @returns Promise resolving to `TMissionOrBadge[]`. Every item has
|
|
183
189
|
* `type === 'badge'`. Cached for 30 s under the `Badges` key.
|
|
184
190
|
*
|
|
@@ -899,6 +899,10 @@ export interface TMissionOrBadgeTask {
|
|
|
899
899
|
progress: number;
|
|
900
900
|
/** Reward for completing the task in points */
|
|
901
901
|
points_reward: number;
|
|
902
|
+
/** Reward for completing the task in gems */
|
|
903
|
+
gems_reward?: number;
|
|
904
|
+
/** Reward for completing the task in diamonds */
|
|
905
|
+
diamonds_reward?: number;
|
|
902
906
|
/** This is the total number of times the user needs to execute to complete task. e.g. he needs to bet 100 times. Here will be 100 */
|
|
903
907
|
execution_count_expected?: number;
|
|
904
908
|
/** This is the number of times the user has executed 'activity' of the task. e.g. he bet 5 times out of 100. Here will be 5 */
|
|
@@ -1675,9 +1679,9 @@ export interface TAvatarPrompt {
|
|
|
1675
1679
|
name: string;
|
|
1676
1680
|
/** Absolute CDN URL of the prompt's preview icon. */
|
|
1677
1681
|
icon_url: string;
|
|
1678
|
-
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds. */
|
|
1682
|
+
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds, `3` = free. A `cost_value` of `0` is also free. */
|
|
1679
1683
|
cost_currency_type_id: number;
|
|
1680
|
-
/** Cost amount in the currency named by `cost_currency_type_id`. */
|
|
1684
|
+
/** Cost amount in the currency named by `cost_currency_type_id`. `0` = free. */
|
|
1681
1685
|
cost_value: number;
|
|
1682
1686
|
}
|
|
1683
1687
|
/**
|
|
@@ -334,12 +334,25 @@ export declare class WSAPIUser extends WSAPIBase {
|
|
|
334
334
|
* `ach_points_ever` and {@link getLevels} would also work, but
|
|
335
335
|
* `progress` saves the math.
|
|
336
336
|
*
|
|
337
|
-
* **Cache TTL
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
337
|
+
* **Cache TTL & freshness**
|
|
338
|
+
* The response is cached for 30 seconds, but the SDK automatically
|
|
339
|
+
* drops that cache whenever a user-properties update arrives — the
|
|
340
|
+
* same live channel that backs {@link getUserProfile}. The practical
|
|
341
|
+
* effect depends on the label's leveling logic:
|
|
342
|
+
* - **Points-based or operator-manual leveling**: a points or level
|
|
343
|
+
* change flows through the user-properties channel, so the cache is
|
|
344
|
+
* busted at that moment and the next `getCurrentLevel()` call
|
|
345
|
+
* returns up-to-date data without waiting out the TTL.
|
|
346
|
+
* - **Counter-based leveling** (level driven by sliding-window
|
|
347
|
+
* counters such as deposit or wagering totals over a recent window —
|
|
348
|
+
* see {@link getUserLevelExtraCounters}): ordinary progress changes
|
|
349
|
+
* are recomputed by a periodic server job and do NOT emit a
|
|
350
|
+
* user-properties update, so they become visible on this method only
|
|
351
|
+
* after the 30 s TTL expires (or after `_smartico.api.clearCaches()`).
|
|
352
|
+
*
|
|
353
|
+
* Avoid calling `clearCaches()` on the points/manual path — it's
|
|
354
|
+
* unnecessary there (the cache is already refreshed on the property
|
|
355
|
+
* update) and forces a slower extra round-trip.
|
|
343
356
|
*
|
|
344
357
|
* **Leveling logic**
|
|
345
358
|
* The semantics of how a user advances depends on the label's
|
|
@@ -367,10 +380,10 @@ export declare class WSAPIUser extends WSAPIBase {
|
|
|
367
380
|
* console.log('[smartico] render level badge — name:', level.name,
|
|
368
381
|
* 'progress:', Math.round(level.progress), '%');
|
|
369
382
|
*
|
|
370
|
-
* // Detect level-up via getUserProfile's push channel.
|
|
383
|
+
* // Detect level-up via getUserProfile's push channel. No clearCaches()
|
|
384
|
+
* // needed — the SDK already drops the level cache on this update.
|
|
371
385
|
* window._smartico.on('props_change', async (changed) => {
|
|
372
386
|
* if ('ach_level_current_id' in changed) {
|
|
373
|
-
* await window._smartico.api.clearCaches(); // bust the 30 s cache
|
|
374
387
|
* const fresh = await window._smartico.api.getCurrentLevel();
|
|
375
388
|
* console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
|
|
376
389
|
* }
|
|
@@ -403,14 +416,12 @@ export declare class WSAPIUser extends WSAPIBase {
|
|
|
403
416
|
* `levelsCounter2Name`.
|
|
404
417
|
*
|
|
405
418
|
* **Refresh cadence**
|
|
406
|
-
* Sliding-window counters are recomputed by a server-side
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
* {@link getUserProfile}'s `ach_level_current_id`, call
|
|
413
|
-
* `_smartico.api.clearCaches()` to force a fresh fetch.
|
|
419
|
+
* Sliding-window counters are recomputed by a periodic server-side
|
|
420
|
+
* job. Its rebuild cadence is operator-configured per brand —
|
|
421
|
+
* commonly daily, though it can be set more frequent — so level
|
|
422
|
+
* transitions driven by counter changes surface with a latency tied
|
|
423
|
+
* to that rebuild schedule after the underlying activity (e.g. a
|
|
424
|
+
* deposit), not in real time.
|
|
414
425
|
*
|
|
415
426
|
* **Idempotency**: safe. Read-only. Repeated calls within the cache
|
|
416
427
|
* window return a deep-cloned cached value without a network
|