@smartico/public-api 0.0.158 → 0.0.160
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/.prettierrc +10 -10
- package/dist/Bonuses/Bonus.d.ts +20 -0
- package/dist/Bonuses/BonusMetaMap.d.ts +3 -0
- package/dist/Bonuses/BonusStatus.d.ts +8 -0
- package/dist/Bonuses/BonusTemplateMetaMap.d.ts +5 -0
- package/dist/Bonuses/ClaimBonusRequest.d.ts +4 -0
- package/dist/Bonuses/ClaimBonusResponse.d.ts +4 -0
- package/dist/Bonuses/GetBonusesRequest.d.ts +3 -0
- package/dist/Bonuses/GetBonusesResponse.d.ts +5 -0
- package/dist/Bonuses/index.d.ts +7 -0
- package/dist/SmarticoAPI.d.ts +5 -1
- package/dist/SmarticoLib/index.d.ts +58 -2
- package/dist/WSAPI/WSAPI.d.ts +18 -3
- package/dist/WSAPI/WSAPITypes.d.ts +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +254 -147
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +72 -2
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +2 -0
- package/docs/classes/WSAPI.md +109 -72
- package/docs/interfaces/TBonus.md +65 -0
- package/docs/interfaces/TClaimBonusResult.md +27 -0
- package/docs/interfaces/TInboxMessageBody.md +2 -2
- package/docs/interfaces/TLevel.md +2 -2
- package/docs/interfaces/TMissionOrBadgeTask.md +1 -10
- package/docs/interfaces/TTournament.md +1 -1
- package/docs/interfaces/TTournamentDetailed.md +2 -2
- package/docs/interfaces/TUserProfile.md +2 -2
- package/package.json +41 -41
- package/src/Base/AchRelatedGame.ts +10 -10
- package/src/Base/ProtocolMessage.ts +4 -4
- package/src/Base/ProtocolRequest.ts +4 -4
- package/src/Base/ProtocolResponse.ts +3 -3
- package/src/Bonuses/Bonus.ts +40 -0
- package/src/Bonuses/BonusMetaMap.ts +3 -0
- package/src/Bonuses/BonusStatus.ts +8 -0
- package/src/Bonuses/BonusTemplateMetaMap.ts +6 -0
- package/src/Bonuses/ClaimBonusRequest.ts +5 -0
- package/src/Bonuses/ClaimBonusResponse.ts +5 -0
- package/src/Bonuses/GetBonusesRequest.ts +3 -0
- package/src/Bonuses/GetBonusesResponse.ts +6 -0
- package/src/Bonuses/index.ts +7 -0
- package/src/CookieStore.ts +6 -6
- package/src/Core/CheckSegmentMatchRequest.ts +2 -2
- package/src/Core/CheckSegmentMatchResponse.ts +4 -4
- package/src/Core/CoreUtils.ts +12 -7
- package/src/Core/GetAchievementsUserInfoRequest.ts +1 -1
- package/src/Core/GetAchievementsUserInfoResponse.ts +3 -3
- package/src/Core/GetLabelInfoRequest.ts +1 -1
- package/src/Core/GetLabelInfoResponse.ts +3 -3
- package/src/Core/GetTranslationsRequest.ts +5 -5
- package/src/Core/GetTranslationsResponse.ts +3 -3
- package/src/Core/PublicProperties.ts +7 -7
- package/src/Core/ResponseIdentify.ts +10 -10
- package/src/Core/TranslationArea.ts +1 -1
- package/src/Core/index.ts +9 -9
- package/src/CustomSections/GetCustomSectionsRequest.ts +1 -1
- package/src/CustomSections/GetCustomSectionsResponse.ts +3 -3
- package/src/CustomSections/UICustomSection.ts +21 -16
- package/src/CustomSections/index.ts +4 -4
- package/src/ErrorCodes.ts +2 -2
- package/src/GResponse.ts +5 -5
- package/src/ILogger.ts +5 -5
- package/src/Inbox/GetInboxMessagesRequest.ts +4 -4
- package/src/Inbox/GetInboxMessagesResponse.ts +8 -8
- package/src/Inbox/InboxMessage.ts +20 -20
- package/src/Inbox/MarkInboxMessageDeletedRequest.ts +3 -3
- package/src/Inbox/MarkInboxMessageDeletedResponse.ts +3 -3
- package/src/Inbox/MarkInboxMessageReadRequest.ts +3 -3
- package/src/Inbox/MarkInboxMessageReadResponse.ts +3 -3
- package/src/Inbox/MarkInboxMessageStarredRequest.ts +3 -3
- package/src/Inbox/MarkInboxMessageStarredResponse.ts +3 -3
- package/src/Inbox/index.ts +10 -10
- package/src/IntUtils.ts +36 -28
- package/src/Jackpots/GetJackpotsPotsRequest.ts +2 -2
- package/src/Jackpots/GetJackpotsPotsResponse.ts +3 -3
- package/src/Jackpots/GetJackpotsRequest.ts +3 -3
- package/src/Jackpots/GetJackpotsResponse.ts +4 -4
- package/src/Jackpots/JackPotWinner.ts +6 -6
- package/src/Jackpots/JackpotContributionType.ts +1 -1
- package/src/Jackpots/JackpotDetails.ts +18 -18
- package/src/Jackpots/JackpotHtmlTemplate.ts +3 -3
- package/src/Jackpots/JackpotPot.ts +6 -6
- package/src/Jackpots/JackpotPublicMeta.ts +9 -9
- package/src/Jackpots/JackpotType.ts +1 -1
- package/src/Jackpots/JackpotWinPush.ts +5 -5
- package/src/Jackpots/JackpotsOptinRequest.ts +2 -2
- package/src/Jackpots/JackpotsOptinResponse.ts +1 -1
- package/src/Jackpots/JackpotsOptoutRequest.ts +2 -2
- package/src/Jackpots/JackpotsOptoutResponse.ts +1 -1
- package/src/Jackpots/index.ts +16 -16
- package/src/Leaderboard/GetLeaderBoardsRequest.ts +5 -5
- package/src/Leaderboard/GetLeaderBoardsResponse.ts +3 -3
- package/src/Leaderboard/LeaderBoardDetails.ts +11 -11
- package/src/Leaderboard/LeaderBoardPosition.ts +8 -8
- package/src/Leaderboard/LeaderBoardPublicMeta.ts +3 -3
- package/src/Leaderboard/LeaderBoards.ts +16 -16
- package/src/Leaderboard/index.ts +6 -6
- package/src/Level/GetLevelMapResponse.ts +7 -7
- package/src/Level/Level.ts +9 -9
- package/src/Level/LevelPublicMeta.ts +10 -10
- package/src/Level/index.ts +3 -3
- package/src/MiniGames/SAWAcknowledgeSpinPushRequest.ts +3 -3
- package/src/MiniGames/SAWBuyInType.ts +2 -2
- package/src/MiniGames/SAWDoAknowledgeRequest.ts +2 -2
- package/src/MiniGames/SAWDoAknowledgeResponse.ts +2 -2
- package/src/MiniGames/SAWDoSpinRequest.ts +3 -3
- package/src/MiniGames/SAWDoSpinResponse.ts +9 -9
- package/src/MiniGames/SAWEventSawPush.ts +3 -3
- package/src/MiniGames/SAWGameType.ts +2 -2
- package/src/MiniGames/SAWGetTemplatesRequest.ts +3 -3
- package/src/MiniGames/SAWGetTemplatesResponse.ts +18 -16
- package/src/MiniGames/SAWPrize.ts +11 -11
- package/src/MiniGames/SAWPrizeDropAknowledgeRequest.ts +4 -4
- package/src/MiniGames/SAWPrizeDropAknowledgeResponse.ts +2 -2
- package/src/MiniGames/SAWPrizeDropWinPush.ts +8 -8
- package/src/MiniGames/SAWPrizeType.ts +2 -2
- package/src/MiniGames/SAWPrizeUI.ts +16 -16
- package/src/MiniGames/SAWSpinsCountPush.ts +3 -3
- package/src/MiniGames/SAWTemplate.ts +26 -26
- package/src/MiniGames/SAWTemplateUI.ts +42 -42
- package/src/MiniGames/SAWUtils.ts +10 -10
- package/src/MiniGames/SAWWinSoundType.ts +1 -1
- package/src/MiniGames/index.ts +24 -24
- package/src/Missions/AchCategoryPublicMeta.ts +2 -2
- package/src/Missions/AchClaimPrizeRequest.ts +3 -3
- package/src/Missions/AchClaimPrizeResponse.ts +1 -1
- package/src/Missions/AchievementCategory.ts +8 -8
- package/src/Missions/AchievementOptinRequest.ts +2 -2
- package/src/Missions/AchievementOptinResponse.ts +1 -1
- package/src/Missions/AchievementPublicMeta.ts +19 -19
- package/src/Missions/AchievementTaskPublicMeta.ts +2 -2
- package/src/Missions/GetAchCategoriesRequest.ts +1 -1
- package/src/Missions/GetAchCategoriesResponse.ts +3 -3
- package/src/Missions/GetAchievementMapRequest.ts +1 -1
- package/src/Missions/GetAchievementMapResponse.ts +3 -3
- package/src/Missions/GetRelatedAchTourRequest.ts +2 -2
- package/src/Missions/GetRelatedAchTourResponse.ts +5 -5
- package/src/Missions/ReloadAchievementsEvent.ts +3 -3
- package/src/Missions/UserAchievement.ts +48 -46
- package/src/Missions/UserAchievementTask.ts +13 -13
- package/src/Missions/index.ts +19 -19
- package/src/NodeCache.ts +12 -12
- package/src/OCache.ts +22 -22
- package/src/Quiz/MarketsAnswers.ts +9 -9
- package/src/Quiz/MarketsInfo.ts +62 -23
- package/src/Quiz/MarketsPerSport.ts +11 -4
- package/src/Quiz/ScoreResultTypes.ts +22 -22
- package/src/Quiz/SportTypes.ts +1 -1
- package/src/Quiz/index.ts +6 -6
- package/src/SmarticoAPI.ts +556 -303
- package/src/SmarticoLib/index.ts +956 -840
- package/src/Store/BuyStoreItemRequest.ts +2 -2
- package/src/Store/BuyStoreItemResponse.ts +2 -2
- package/src/Store/GetCategoriesStoreResponse.ts +3 -3
- package/src/Store/GetStoreHistoryRequest.ts +3 -3
- package/src/Store/GetStoreHistoryResponse.ts +4 -4
- package/src/Store/GetStoreItemsResponse.ts +3 -3
- package/src/Store/StoreCategory.ts +8 -8
- package/src/Store/StoreCategoryPublicMeta.ts +2 -2
- package/src/Store/StoreItem.ts +13 -13
- package/src/Store/StoreItemPublicMeta.ts +10 -10
- package/src/Store/StoreItemPurchased.ts +17 -17
- package/src/Store/StoreItemType.ts +2 -2
- package/src/Store/index.ts +13 -13
- package/src/Tournaments/GetTournamentInfoRequest.ts +2 -2
- package/src/Tournaments/GetTournamentInfoResponse.ts +18 -18
- package/src/Tournaments/GetTournamentsRequest.ts +1 -1
- package/src/Tournaments/GetTournamentsResponse.ts +6 -6
- package/src/Tournaments/Tournament.ts +43 -39
- package/src/Tournaments/TournamentInstanceStatus.ts +2 -2
- package/src/Tournaments/TournamentPlayer.ts +7 -7
- package/src/Tournaments/TournamentPrize.ts +8 -8
- package/src/Tournaments/TournamentPublicMeta.ts +16 -16
- package/src/Tournaments/TournamentRegisterRequest.ts +2 -2
- package/src/Tournaments/TournamentRegisterResponse.ts +3 -3
- package/src/Tournaments/TournamentRegistrationStatus.ts +6 -4
- package/src/Tournaments/TournamentRegistrationType.ts +9 -3
- package/src/Tournaments/TournamentUtils.ts +44 -38
- package/src/Tournaments/index.ts +16 -16
- package/src/WSAPI/WSAPI.ts +244 -132
- package/src/WSAPI/WSAPITypes.ts +287 -250
- package/src/index.ts +16 -15
- package/tsconfig.json +41 -43
package/src/SmarticoAPI.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import { ClassId } from './Base/ClassId'
|
|
2
|
-
import { ProtocolRequest } from './Base/ProtocolRequest'
|
|
3
|
-
import { ProtocolResponse } from './Base/ProtocolResponse'
|
|
4
|
-
import { SAWGetTemplatesResponse } from './MiniGames/SAWGetTemplatesResponse'
|
|
5
|
-
import { SAWGetTemplatesRequest } from './MiniGames/SAWGetTemplatesRequest'
|
|
6
|
-
import { IntUtils } from './IntUtils'
|
|
7
|
-
import { ILogger } from './ILogger'
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { ClassId } from './Base/ClassId';
|
|
2
|
+
import { ProtocolRequest } from './Base/ProtocolRequest';
|
|
3
|
+
import { ProtocolResponse } from './Base/ProtocolResponse';
|
|
4
|
+
import { SAWGetTemplatesResponse } from './MiniGames/SAWGetTemplatesResponse';
|
|
5
|
+
import { SAWGetTemplatesRequest } from './MiniGames/SAWGetTemplatesRequest';
|
|
6
|
+
import { IntUtils } from './IntUtils';
|
|
7
|
+
import { ILogger } from './ILogger';
|
|
8
|
+
import {
|
|
9
|
+
SAWDoAknowledgeRequest,
|
|
10
|
+
SAWDoAknowledgeResponse,
|
|
11
|
+
SAWDoSpinRequest,
|
|
12
|
+
SAWDoSpinResponse,
|
|
13
|
+
SAWSpinErrorCode,
|
|
14
|
+
SAWTemplatesTransform,
|
|
15
|
+
} from './MiniGames';
|
|
16
|
+
import { ECacheContext, OCache } from './OCache';
|
|
17
|
+
import {
|
|
18
|
+
CoreUtils,
|
|
19
|
+
GetTranslationsRequest,
|
|
20
|
+
GetTranslationsResponse,
|
|
21
|
+
PublicLabelSettings,
|
|
22
|
+
ResponseIdentify,
|
|
23
|
+
TranslationArea,
|
|
24
|
+
} from './Core';
|
|
25
|
+
import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
|
|
26
|
+
import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
|
|
13
27
|
import {
|
|
14
28
|
GetInboxMessagesRequest,
|
|
15
29
|
GetInboxMessagesResponse,
|
|
@@ -22,7 +36,7 @@ import {
|
|
|
22
36
|
MarkInboxMessageReadResponse,
|
|
23
37
|
MarkInboxMessageStarredRequest,
|
|
24
38
|
MarkInboxMessageStarredResponse,
|
|
25
|
-
} from './Inbox'
|
|
39
|
+
} from './Inbox';
|
|
26
40
|
import {
|
|
27
41
|
BuyStoreItemRequest,
|
|
28
42
|
BuyStoreItemResponse,
|
|
@@ -33,7 +47,7 @@ import {
|
|
|
33
47
|
StoreCategoryTransform,
|
|
34
48
|
StoreItemPurchasedTransform,
|
|
35
49
|
StoreItemTransform,
|
|
36
|
-
} from './Store'
|
|
50
|
+
} from './Store';
|
|
37
51
|
import {
|
|
38
52
|
AchCategoryTransform,
|
|
39
53
|
AchClaimPrizeRequest,
|
|
@@ -45,7 +59,7 @@ import {
|
|
|
45
59
|
GetAchievementMapRequest,
|
|
46
60
|
GetAchievementMapResponse,
|
|
47
61
|
UserAchievementTransform,
|
|
48
|
-
} from './Missions'
|
|
62
|
+
} from './Missions';
|
|
49
63
|
import {
|
|
50
64
|
GetTournamentInfoRequest,
|
|
51
65
|
GetTournamentInfoResponse,
|
|
@@ -55,10 +69,10 @@ import {
|
|
|
55
69
|
TournamentRegisterRequest,
|
|
56
70
|
TournamentRegisterResponse,
|
|
57
71
|
tournamentInfoItemTransform,
|
|
58
|
-
} from './Tournaments'
|
|
59
|
-
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from './Leaderboard'
|
|
60
|
-
import { GetLevelMapResponse, GetLevelMapResponseTransform } from './Level'
|
|
61
|
-
import { WSAPI } from './WSAPI/WSAPI'
|
|
72
|
+
} from './Tournaments';
|
|
73
|
+
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from './Leaderboard';
|
|
74
|
+
import { GetLevelMapResponse, GetLevelMapResponseTransform } from './Level';
|
|
75
|
+
import { WSAPI } from './WSAPI/WSAPI';
|
|
62
76
|
import {
|
|
63
77
|
TInboxMessage,
|
|
64
78
|
TInboxMessageBody,
|
|
@@ -74,11 +88,12 @@ import {
|
|
|
74
88
|
UserLevelExtraCountersT,
|
|
75
89
|
TSegmentCheckResult,
|
|
76
90
|
TUICustomSection,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
91
|
+
TBonus,
|
|
92
|
+
} from './WSAPI/WSAPITypes';
|
|
93
|
+
import { getLeaderBoardTransform } from './Leaderboard/LeaderBoards';
|
|
94
|
+
import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
|
|
95
|
+
import { CheckSegmentMatchResponse } from './Core/CheckSegmentMatchResponse';
|
|
96
|
+
import { CheckSegmentMatchRequest } from './Core/CheckSegmentMatchRequest';
|
|
82
97
|
import {
|
|
83
98
|
GetJackpotsPotsRequest,
|
|
84
99
|
GetJackpotsPotsResponse,
|
|
@@ -90,40 +105,42 @@ import {
|
|
|
90
105
|
JackpotsOptinResponse,
|
|
91
106
|
JackpotsOptoutRequest,
|
|
92
107
|
JackpotsOptoutResponse,
|
|
93
|
-
} from './Jackpots'
|
|
94
|
-
import { GetCustomSectionsRequest, GetCustomSectionsResponse, UICustomSectionTransform } from './CustomSections'
|
|
108
|
+
} from './Jackpots';
|
|
109
|
+
import { GetCustomSectionsRequest, GetCustomSectionsResponse, UICustomSectionTransform } from './CustomSections';
|
|
110
|
+
import { BonusItemsTransform, ClaimBonusRequest, ClaimBonusResponse, GetBonusesResponse } from './Bonuses';
|
|
111
|
+
import { GetBonusesRequest } from './Bonuses/GetBonusesRequest';
|
|
95
112
|
|
|
96
|
-
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public'
|
|
97
|
-
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services'
|
|
98
|
-
const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc'
|
|
99
|
-
const DEFAULT_LANG_EN = 'EN'
|
|
113
|
+
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
114
|
+
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
|
|
115
|
+
const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
|
|
116
|
+
const DEFAULT_LANG_EN = 'EN';
|
|
100
117
|
|
|
101
118
|
interface Tracker {
|
|
102
|
-
label_api_key: string
|
|
103
|
-
userPublicProps: any
|
|
104
|
-
on: (callBackKey: ClassId, func: (data: any) => void) => void
|
|
105
|
-
getLabelSetting: (key: PublicLabelSettings) => any
|
|
119
|
+
label_api_key: string;
|
|
120
|
+
userPublicProps: any;
|
|
121
|
+
on: (callBackKey: ClassId, func: (data: any) => void) => void;
|
|
122
|
+
getLabelSetting: (key: PublicLabelSettings) => any;
|
|
106
123
|
}
|
|
107
124
|
interface IOptions {
|
|
108
|
-
logger?: ILogger
|
|
109
|
-
logCIDs?: ClassId[]
|
|
110
|
-
logHTTPTiming?: boolean
|
|
111
|
-
tracker?: Tracker
|
|
125
|
+
logger?: ILogger;
|
|
126
|
+
logCIDs?: ClassId[];
|
|
127
|
+
logHTTPTiming?: boolean;
|
|
128
|
+
tracker?: Tracker;
|
|
112
129
|
}
|
|
113
130
|
|
|
114
|
-
type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any
|
|
131
|
+
type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any>;
|
|
115
132
|
|
|
116
133
|
class SmarticoAPI {
|
|
117
|
-
private publicUrl: string
|
|
118
|
-
private wsUrl: string
|
|
119
|
-
private inboxCdnUrl: string
|
|
120
|
-
private partnerUrl: string
|
|
121
|
-
public avatarDomain: string
|
|
134
|
+
private publicUrl: string;
|
|
135
|
+
private wsUrl: string;
|
|
136
|
+
private inboxCdnUrl: string;
|
|
137
|
+
private partnerUrl: string;
|
|
138
|
+
public avatarDomain: string;
|
|
122
139
|
|
|
123
|
-
private logger: ILogger
|
|
124
|
-
private logCIDs: ClassId[]
|
|
125
|
-
private logHTTPTiming: boolean
|
|
126
|
-
public tracker?: Tracker
|
|
140
|
+
private logger: ILogger;
|
|
141
|
+
private logCIDs: ClassId[];
|
|
142
|
+
private logHTTPTiming: boolean;
|
|
143
|
+
public tracker?: Tracker;
|
|
127
144
|
|
|
128
145
|
public constructor(
|
|
129
146
|
private label_api_key: string,
|
|
@@ -131,109 +148,116 @@ class SmarticoAPI {
|
|
|
131
148
|
private messageSender: MessageSender,
|
|
132
149
|
options: IOptions = {},
|
|
133
150
|
) {
|
|
134
|
-
this.logger = options.logger || (console as any)
|
|
151
|
+
this.logger = options.logger || (console as any);
|
|
135
152
|
|
|
136
153
|
if (this.logger.always === undefined) {
|
|
137
|
-
this.logger.always = this.logger.info
|
|
154
|
+
this.logger.always = this.logger.info;
|
|
138
155
|
}
|
|
139
156
|
|
|
140
|
-
this.logCIDs = options.logCIDs || []
|
|
141
|
-
this.logHTTPTiming = options.logHTTPTiming || false
|
|
142
|
-
this.tracker = options.tracker
|
|
157
|
+
this.logCIDs = options.logCIDs || [];
|
|
158
|
+
this.logHTTPTiming = options.logHTTPTiming || false;
|
|
159
|
+
this.tracker = options.tracker;
|
|
143
160
|
|
|
144
|
-
this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key)
|
|
145
|
-
this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key)
|
|
161
|
+
this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
|
|
162
|
+
this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
|
|
146
163
|
|
|
147
|
-
this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || options.tracker?.label_api_key)
|
|
164
|
+
this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || options.tracker?.label_api_key);
|
|
148
165
|
|
|
149
|
-
this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key)
|
|
166
|
+
this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key);
|
|
150
167
|
}
|
|
151
168
|
|
|
152
169
|
public static getEnvDnsSuffix(label_api_key: string): string {
|
|
153
|
-
let ENV_ID = label_api_key.length === 38 ? label_api_key.substring(37, 38) : ''
|
|
170
|
+
let ENV_ID = label_api_key.length === 38 ? label_api_key.substring(37, 38) : '';
|
|
154
171
|
|
|
155
172
|
if (ENV_ID === '1' || ENV_ID === '2') {
|
|
156
|
-
ENV_ID = ''
|
|
173
|
+
ENV_ID = '';
|
|
157
174
|
}
|
|
158
|
-
return ENV_ID
|
|
175
|
+
return ENV_ID;
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
public static getEnvId(label_api_key: string): number {
|
|
162
|
-
return label_api_key.length === 38 ? parseInt(label_api_key.substring(37, 38), 10) : 2
|
|
179
|
+
return label_api_key.length === 38 ? parseInt(label_api_key.substring(37, 38), 10) : 2;
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
public static getCleanLabelApiKey(label_api_key: string): string {
|
|
166
|
-
return label_api_key.substring(0, 36)
|
|
183
|
+
return label_api_key.substring(0, 36);
|
|
167
184
|
}
|
|
168
185
|
|
|
169
186
|
public static getPublicUrl(label_api_key: string): string {
|
|
170
|
-
return PUBLIC_API_URL.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key))
|
|
187
|
+
return PUBLIC_API_URL.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
171
188
|
}
|
|
172
189
|
|
|
173
190
|
public static getPublicWsUrl(label_api_key: string): string {
|
|
174
|
-
return C_SOCKET_PROD.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key))
|
|
191
|
+
return C_SOCKET_PROD.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
public static getAvatarUrl(label_api_key: string): string {
|
|
178
|
-
return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key))
|
|
195
|
+
return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
179
196
|
}
|
|
180
197
|
|
|
181
198
|
private async send<T>(message: any, expectCID?: ClassId, force_language?: string): Promise<T> {
|
|
182
199
|
if (this.logCIDs.includes(message.cid)) {
|
|
183
|
-
this.logger.info('REQ', message)
|
|
200
|
+
this.logger.info('REQ', message);
|
|
184
201
|
}
|
|
185
202
|
|
|
186
203
|
if (force_language) {
|
|
187
|
-
message.force_language = force_language
|
|
204
|
+
message.force_language = force_language;
|
|
188
205
|
}
|
|
189
206
|
|
|
190
|
-
let result: any
|
|
207
|
+
let result: any;
|
|
191
208
|
|
|
192
209
|
try {
|
|
193
|
-
const timeStart = new Date().getTime()
|
|
194
|
-
result = await this.messageSender(message, this.publicUrl, expectCID)
|
|
195
|
-
const timeEnd = new Date().getTime()
|
|
210
|
+
const timeStart = new Date().getTime();
|
|
211
|
+
result = await this.messageSender(message, this.publicUrl, expectCID);
|
|
212
|
+
const timeEnd = new Date().getTime();
|
|
196
213
|
|
|
197
214
|
if (this.logHTTPTiming) {
|
|
198
|
-
this.logger.always('HTTP time, ms:' + (timeEnd - timeStart))
|
|
215
|
+
this.logger.always('HTTP time, ms:' + (timeEnd - timeStart));
|
|
199
216
|
}
|
|
200
217
|
} catch (e) {
|
|
201
|
-
this.logger.error(`Failed to make request to smartico channel, L2. ${e.message}`, {
|
|
202
|
-
|
|
218
|
+
this.logger.error(`Failed to make request to smartico channel, L2. ${e.message}`, {
|
|
219
|
+
url: this.publicUrl,
|
|
220
|
+
request: message,
|
|
221
|
+
error: e.message,
|
|
222
|
+
});
|
|
223
|
+
throw new Error(`Failed to make request to smartico channel, L2 L1. ${e.message}`);
|
|
203
224
|
}
|
|
204
225
|
|
|
205
226
|
if (this.logCIDs.includes(message.cid)) {
|
|
206
|
-
this.logger.info('RES', result)
|
|
227
|
+
this.logger.info('RES', result);
|
|
207
228
|
}
|
|
208
229
|
|
|
209
230
|
if (expectCID) {
|
|
210
231
|
if (Array.isArray(result)) {
|
|
211
232
|
for (const str of result as string[]) {
|
|
212
|
-
const obj: ProtocolResponse = JSON.parse(str)
|
|
233
|
+
const obj: ProtocolResponse = JSON.parse(str);
|
|
213
234
|
if (this.logCIDs.includes(obj.cid)) {
|
|
214
|
-
this.logger.info('RES', result)
|
|
235
|
+
this.logger.info('RES', result);
|
|
215
236
|
}
|
|
216
237
|
if (obj.cid === expectCID) {
|
|
217
|
-
return obj as any
|
|
238
|
+
return obj as any;
|
|
218
239
|
}
|
|
219
240
|
}
|
|
220
|
-
this.logger.error(`Cant find proper response in array, expected CID ${expectCID}`, {
|
|
241
|
+
this.logger.error(`Cant find proper response in array, expected CID ${expectCID}`, {
|
|
242
|
+
request: message,
|
|
243
|
+
response: result,
|
|
244
|
+
});
|
|
221
245
|
} else {
|
|
222
|
-
return result
|
|
246
|
+
return result;
|
|
223
247
|
}
|
|
224
248
|
} else {
|
|
225
249
|
if (Array.isArray(result)) {
|
|
226
250
|
if (result.length === 1) {
|
|
227
|
-
const obj = JSON.parse(result[0])
|
|
251
|
+
const obj = JSON.parse(result[0]);
|
|
228
252
|
if (this.logCIDs.includes(obj.cid)) {
|
|
229
|
-
this.logger.info('RES', result)
|
|
253
|
+
this.logger.info('RES', result);
|
|
230
254
|
}
|
|
231
|
-
return obj
|
|
255
|
+
return obj;
|
|
232
256
|
} else {
|
|
233
|
-
this.logger.error('Expected one response, but got array', { request: message, response: result })
|
|
257
|
+
this.logger.error('Expected one response, but got array', { request: message, response: result });
|
|
234
258
|
}
|
|
235
259
|
}
|
|
236
|
-
return result
|
|
260
|
+
return result;
|
|
237
261
|
}
|
|
238
262
|
}
|
|
239
263
|
|
|
@@ -248,66 +272,79 @@ class SmarticoAPI {
|
|
|
248
272
|
uuid: IntUtils.uuid(),
|
|
249
273
|
ts: new Date().getTime(),
|
|
250
274
|
...payload,
|
|
251
|
-
}
|
|
275
|
+
};
|
|
252
276
|
|
|
253
277
|
if (message.ext_user_id === undefined || message.ext_user_id === null) {
|
|
254
|
-
delete message.ext_user_id
|
|
278
|
+
delete message.ext_user_id;
|
|
255
279
|
}
|
|
256
280
|
|
|
257
281
|
if (message.brand_key === undefined || message.brand_key === null) {
|
|
258
|
-
delete message.brand_key
|
|
282
|
+
delete message.brand_key;
|
|
259
283
|
}
|
|
260
284
|
|
|
261
|
-
return message as any
|
|
285
|
+
return message as any;
|
|
262
286
|
}
|
|
263
287
|
|
|
264
288
|
public async coreReportCustomEvent(user_ext_id: string, eventType: string, payload: any = {}): Promise<any> {
|
|
265
289
|
const eventMessage = this.buildMessage<any, any>(user_ext_id, ClassId.EVENT, {
|
|
266
290
|
eventType,
|
|
267
291
|
payload,
|
|
268
|
-
})
|
|
292
|
+
});
|
|
269
293
|
|
|
270
|
-
const eventResponse = await this.send<any>(eventMessage, ClassId.EVENT_RESPONSE)
|
|
271
|
-
return eventResponse
|
|
294
|
+
const eventResponse = await this.send<any>(eventMessage, ClassId.EVENT_RESPONSE);
|
|
295
|
+
return eventResponse;
|
|
272
296
|
}
|
|
273
297
|
|
|
274
|
-
public async coreGetTranslations(
|
|
298
|
+
public async coreGetTranslations(
|
|
299
|
+
user_ext_id: string,
|
|
300
|
+
lang_code: string,
|
|
301
|
+
areas: TranslationArea[],
|
|
302
|
+
cacheSec: number = 60,
|
|
303
|
+
): Promise<GetTranslationsResponse> {
|
|
275
304
|
if (lang_code === undefined || lang_code === null || (lang_code.trim && lang_code.trim() === '')) {
|
|
276
|
-
lang_code = DEFAULT_LANG_EN
|
|
305
|
+
lang_code = DEFAULT_LANG_EN;
|
|
277
306
|
}
|
|
278
307
|
|
|
279
308
|
const response = await OCache.use<GetTranslationsResponse>(
|
|
280
309
|
`${lang_code}-${this.label_api_key}-${this.brand_api_key}`,
|
|
281
310
|
ECacheContext.Translations,
|
|
282
311
|
async () => {
|
|
283
|
-
const tsBaseRQ = this.buildMessage<GetTranslationsRequest, GetTranslationsResponse>(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const trBase = await this.send<GetTranslationsResponse>(tsBaseRQ, ClassId.GET_TRANSLATIONS_RESPONSE)
|
|
290
|
-
|
|
291
|
-
if (lang_code !== DEFAULT_LANG_EN) {
|
|
292
|
-
const trUserRQ = this.buildMessage<GetTranslationsRequest, GetTranslationsResponse>(user_ext_id, ClassId.GET_TRANSLATIONS_REQUEST, {
|
|
293
|
-
lang_code,
|
|
312
|
+
const tsBaseRQ = this.buildMessage<GetTranslationsRequest, GetTranslationsResponse>(
|
|
313
|
+
user_ext_id,
|
|
314
|
+
ClassId.GET_TRANSLATIONS_REQUEST,
|
|
315
|
+
{
|
|
316
|
+
lang_code: DEFAULT_LANG_EN,
|
|
294
317
|
hash_code: 0,
|
|
295
318
|
areas,
|
|
296
|
-
}
|
|
319
|
+
},
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const trBase = await this.send<GetTranslationsResponse>(tsBaseRQ, ClassId.GET_TRANSLATIONS_RESPONSE);
|
|
297
323
|
|
|
298
|
-
|
|
324
|
+
if (lang_code !== DEFAULT_LANG_EN) {
|
|
325
|
+
const trUserRQ = this.buildMessage<GetTranslationsRequest, GetTranslationsResponse>(
|
|
326
|
+
user_ext_id,
|
|
327
|
+
ClassId.GET_TRANSLATIONS_REQUEST,
|
|
328
|
+
{
|
|
329
|
+
lang_code,
|
|
330
|
+
hash_code: 0,
|
|
331
|
+
areas,
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const trUser = await this.send<GetTranslationsResponse>(trUserRQ, ClassId.GET_TRANSLATIONS_RESPONSE);
|
|
299
336
|
|
|
300
337
|
Object.keys(trUser?.translations ?? {}).forEach((k) => {
|
|
301
|
-
trBase.translations[k] = trUser.translations[k]
|
|
302
|
-
})
|
|
338
|
+
trBase.translations[k] = trUser.translations[k];
|
|
339
|
+
});
|
|
303
340
|
}
|
|
304
341
|
|
|
305
|
-
return trBase
|
|
342
|
+
return trBase;
|
|
306
343
|
},
|
|
307
344
|
cacheSec,
|
|
308
|
-
)
|
|
345
|
+
);
|
|
309
346
|
|
|
310
|
-
return response
|
|
347
|
+
return response;
|
|
311
348
|
}
|
|
312
349
|
|
|
313
350
|
public async coreIdentifyLabel(user_ext_id: string, cacheSec: number = 60): Promise<GetLabelInfoResponse> {
|
|
@@ -315,112 +352,169 @@ class SmarticoAPI {
|
|
|
315
352
|
`${this.label_api_key} - ${this.brand_api_key}`,
|
|
316
353
|
ECacheContext.LabelInfo,
|
|
317
354
|
async () => {
|
|
318
|
-
const message = this.buildMessage<GetLabelInfoResponse, GetLabelInfoRequest>(user_ext_id, ClassId.INIT)
|
|
355
|
+
const message = this.buildMessage<GetLabelInfoResponse, GetLabelInfoRequest>(user_ext_id, ClassId.INIT);
|
|
319
356
|
|
|
320
|
-
return this.send<GetLabelInfoResponse>(message, ClassId.INIT_RESPONSE)
|
|
357
|
+
return this.send<GetLabelInfoResponse>(message, ClassId.INIT_RESPONSE);
|
|
321
358
|
},
|
|
322
359
|
cacheSec,
|
|
323
|
-
)
|
|
360
|
+
);
|
|
324
361
|
}
|
|
325
362
|
|
|
326
363
|
public async coreIdentifyUser(user_ext_id: string): Promise<ResponseIdentify> {
|
|
327
364
|
const message = this.buildMessage<any, ResponseIdentify>(user_ext_id, ClassId.IDENTIFY, {
|
|
328
365
|
request_id: IntUtils.uuid(), // AA: do we need request_id?
|
|
329
|
-
})
|
|
366
|
+
});
|
|
330
367
|
|
|
331
|
-
const r = await this.send<ResponseIdentify>(message, ClassId.IDENTIFY_RESPONSE)
|
|
368
|
+
const r = await this.send<ResponseIdentify>(message, ClassId.IDENTIFY_RESPONSE);
|
|
332
369
|
|
|
333
|
-
r.avatar_id = CoreUtils.avatarUrl(r.avatar_id, this.avatarDomain)
|
|
370
|
+
r.avatar_id = CoreUtils.avatarUrl(r.avatar_id, this.avatarDomain);
|
|
334
371
|
|
|
335
|
-
return r
|
|
372
|
+
return r;
|
|
336
373
|
}
|
|
337
374
|
|
|
338
|
-
public async coreChangeUsername(
|
|
375
|
+
public async coreChangeUsername(
|
|
376
|
+
user_ext_id: string,
|
|
377
|
+
public_username_custom: string,
|
|
378
|
+
): Promise<{ public_username_custom: string }> {
|
|
339
379
|
const message = this.buildMessage<any, any>(user_ext_id, ClassId.CLIENT_SET_CUSTOM_USERNAME_REQUEST, {
|
|
340
380
|
public_username_custom,
|
|
341
|
-
})
|
|
381
|
+
});
|
|
342
382
|
|
|
343
|
-
return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE)
|
|
383
|
+
return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
|
|
344
384
|
}
|
|
345
385
|
|
|
346
386
|
public async coreCheckSegments(user_ext_id: string, segment_id: number[]): Promise<TSegmentCheckResult[]> {
|
|
347
387
|
const message = this.buildMessage<CheckSegmentMatchRequest, any>(user_ext_id, ClassId.CHECK_SEGMENT_MATCH_REQUEST, {
|
|
348
388
|
segment_id,
|
|
349
|
-
})
|
|
389
|
+
});
|
|
350
390
|
|
|
351
|
-
const results = await this.send<CheckSegmentMatchResponse>(message, ClassId.CHECK_SEGMENT_MATCH_RESPONSE)
|
|
391
|
+
const results = await this.send<CheckSegmentMatchResponse>(message, ClassId.CHECK_SEGMENT_MATCH_RESPONSE);
|
|
352
392
|
|
|
353
|
-
return results.segments || []
|
|
393
|
+
return results.segments || [];
|
|
354
394
|
}
|
|
355
395
|
|
|
356
|
-
public async jackpotGet(
|
|
357
|
-
|
|
358
|
-
|
|
396
|
+
public async jackpotGet(
|
|
397
|
+
user_ext_id: string,
|
|
398
|
+
filter?: { related_game_id?: string; jp_template_id?: number },
|
|
399
|
+
force_language?: string,
|
|
400
|
+
): Promise<GetJackpotsResponse> {
|
|
401
|
+
const message = this.buildMessage<GetJackpotsRequest, GetJackpotsResponse>(
|
|
402
|
+
user_ext_id,
|
|
403
|
+
ClassId.JP_GET_JACKPOTS_REQUEST,
|
|
404
|
+
filter,
|
|
405
|
+
);
|
|
406
|
+
return await this.send<GetJackpotsResponse>(message, ClassId.JP_GET_JACKPOTS_RESPONSE, force_language);
|
|
359
407
|
}
|
|
360
408
|
|
|
361
409
|
public async potGet(user_ext_id: string, filter: { jp_template_ids: number[] }): Promise<GetJackpotsPotsResponse> {
|
|
362
|
-
const message = this.buildMessage<GetJackpotsPotsRequest, GetJackpotsPotsResponse>(
|
|
363
|
-
|
|
410
|
+
const message = this.buildMessage<GetJackpotsPotsRequest, GetJackpotsPotsResponse>(
|
|
411
|
+
user_ext_id,
|
|
412
|
+
ClassId.JP_GET_LATEST_POTS_REQUEST,
|
|
413
|
+
filter,
|
|
414
|
+
);
|
|
415
|
+
return await this.send<GetJackpotsPotsResponse>(message, ClassId.JP_GET_LATEST_POTS_RESPONSE);
|
|
364
416
|
}
|
|
365
417
|
|
|
366
418
|
public async jackpotOptIn(user_ext_id: string, payload: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
|
|
367
|
-
const message = this.buildMessage<JackpotsOptinRequest, JackpotsOptinResponse>(
|
|
368
|
-
|
|
419
|
+
const message = this.buildMessage<JackpotsOptinRequest, JackpotsOptinResponse>(
|
|
420
|
+
user_ext_id,
|
|
421
|
+
ClassId.JP_OPTIN_REQUEST,
|
|
422
|
+
payload,
|
|
423
|
+
);
|
|
424
|
+
return await this.send<JackpotsOptinResponse>(message, ClassId.JP_OPTIN_RESPONSE);
|
|
369
425
|
}
|
|
370
426
|
|
|
371
427
|
public async jackpotOptOut(user_ext_id: string, payload: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
|
|
372
|
-
const message = this.buildMessage<JackpotsOptoutRequest, JackpotsOptoutResponse>(
|
|
373
|
-
|
|
428
|
+
const message = this.buildMessage<JackpotsOptoutRequest, JackpotsOptoutResponse>(
|
|
429
|
+
user_ext_id,
|
|
430
|
+
ClassId.JP_OPTOUT_REQUEST,
|
|
431
|
+
payload,
|
|
432
|
+
);
|
|
433
|
+
return await this.send<JackpotsOptoutResponse>(message, ClassId.JP_OPTOUT_RESPONSE);
|
|
374
434
|
}
|
|
375
435
|
|
|
376
|
-
public async sawGetTemplates(
|
|
377
|
-
|
|
436
|
+
public async sawGetTemplates(
|
|
437
|
+
user_ext_id: string,
|
|
438
|
+
force_language?: string,
|
|
439
|
+
is_visitor_mode: boolean = false,
|
|
440
|
+
): Promise<SAWGetTemplatesResponse> {
|
|
441
|
+
const message = this.buildMessage<SAWGetTemplatesRequest, SAWGetTemplatesResponse>(
|
|
442
|
+
user_ext_id,
|
|
443
|
+
ClassId.SAW_GET_SPINS_REQUEST,
|
|
444
|
+
{ is_visitor_mode },
|
|
445
|
+
);
|
|
378
446
|
|
|
379
|
-
const response = await this.send<SAWGetTemplatesResponse>(message, ClassId.SAW_GET_SPINS_RESPONSE, force_language)
|
|
447
|
+
const response = await this.send<SAWGetTemplatesResponse>(message, ClassId.SAW_GET_SPINS_RESPONSE, force_language);
|
|
380
448
|
|
|
381
449
|
if (response && response.templates) {
|
|
382
450
|
response.templates.forEach((t) => {
|
|
383
451
|
if (t.jackpot_current !== undefined && t.jackpot_current !== null) {
|
|
384
|
-
const jackpotValue =
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
t.saw_template_ui_definition.
|
|
452
|
+
const jackpotValue =
|
|
453
|
+
t.jackpot_current +
|
|
454
|
+
(t.saw_template_ui_definition?.jackpot_symbol ? ' ' + t.saw_template_ui_definition?.jackpot_symbol : '');
|
|
455
|
+
t.saw_template_ui_definition.name = IntUtils.replaceAll(
|
|
456
|
+
t.saw_template_ui_definition.name,
|
|
457
|
+
'{{jackpot}}',
|
|
458
|
+
jackpotValue,
|
|
459
|
+
);
|
|
460
|
+
t.saw_template_ui_definition.description = IntUtils.replaceAll(
|
|
461
|
+
t.saw_template_ui_definition.description,
|
|
462
|
+
'{{jackpot}}',
|
|
463
|
+
jackpotValue,
|
|
464
|
+
);
|
|
465
|
+
t.saw_template_ui_definition.promo_text = IntUtils.replaceAll(
|
|
466
|
+
t.saw_template_ui_definition.promo_text,
|
|
467
|
+
'{{jackpot}}',
|
|
468
|
+
jackpotValue,
|
|
469
|
+
);
|
|
388
470
|
t.prizes.forEach((p) => {
|
|
389
|
-
p.saw_prize_ui_definition.name = IntUtils.replaceAll(
|
|
390
|
-
|
|
391
|
-
|
|
471
|
+
p.saw_prize_ui_definition.name = IntUtils.replaceAll(
|
|
472
|
+
p.saw_prize_ui_definition.name,
|
|
473
|
+
'{{jackpot}}',
|
|
474
|
+
jackpotValue,
|
|
475
|
+
);
|
|
476
|
+
p.saw_prize_ui_definition.aknowledge_message = IntUtils.replaceAll(
|
|
477
|
+
p.saw_prize_ui_definition.aknowledge_message,
|
|
478
|
+
'{{jackpot}}',
|
|
479
|
+
jackpotValue,
|
|
480
|
+
);
|
|
481
|
+
});
|
|
392
482
|
}
|
|
393
|
-
})
|
|
483
|
+
});
|
|
394
484
|
}
|
|
395
485
|
|
|
396
|
-
return response
|
|
486
|
+
return response;
|
|
397
487
|
}
|
|
398
488
|
|
|
399
489
|
public async sawGetTemplatesT(user_ext_id: string): Promise<TMiniGameTemplate[]> {
|
|
400
|
-
return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates)
|
|
490
|
+
return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
|
|
401
491
|
}
|
|
402
492
|
|
|
403
493
|
public async doAcknowledgeRequest(user_ext_id: string, request_id: string): Promise<SAWDoAknowledgeResponse> {
|
|
404
|
-
const message = this.buildMessage<SAWDoAknowledgeRequest, SAWDoAknowledgeResponse>(
|
|
405
|
-
|
|
406
|
-
|
|
494
|
+
const message = this.buildMessage<SAWDoAknowledgeRequest, SAWDoAknowledgeResponse>(
|
|
495
|
+
user_ext_id,
|
|
496
|
+
ClassId.SAW_AKNOWLEDGE_REQUEST,
|
|
497
|
+
{
|
|
498
|
+
request_id,
|
|
499
|
+
},
|
|
500
|
+
);
|
|
407
501
|
|
|
408
|
-
return await this.send<SAWDoAknowledgeResponse>(message, ClassId.SAW_AKNOWLEDGE_RESPONSE)
|
|
502
|
+
return await this.send<SAWDoAknowledgeResponse>(message, ClassId.SAW_AKNOWLEDGE_RESPONSE);
|
|
409
503
|
}
|
|
410
504
|
|
|
411
505
|
public async sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse> {
|
|
412
506
|
if (!saw_template_id) {
|
|
413
|
-
throw new Error('Missing template id')
|
|
507
|
+
throw new Error('Missing template id');
|
|
414
508
|
}
|
|
415
509
|
|
|
416
|
-
const request_id = IntUtils.uuid()
|
|
510
|
+
const request_id = IntUtils.uuid();
|
|
417
511
|
|
|
418
512
|
const message = this.buildMessage<SAWDoSpinRequest, SAWDoSpinResponse>(user_ext_id, ClassId.SAW_DO_SPIN_REQUEST, {
|
|
419
513
|
saw_template_id,
|
|
420
514
|
request_id,
|
|
421
|
-
})
|
|
515
|
+
});
|
|
422
516
|
|
|
423
|
-
const spinAttemptResponse = await this.send<SAWDoSpinResponse>(message, ClassId.SAW_DO_SPIN_RESPONSE)
|
|
517
|
+
const spinAttemptResponse = await this.send<SAWDoSpinResponse>(message, ClassId.SAW_DO_SPIN_RESPONSE);
|
|
424
518
|
|
|
425
519
|
// to simulate fail
|
|
426
520
|
// response.errCode = SAWSpinErrorCode.SAW_NO_SPINS;
|
|
@@ -432,279 +526,414 @@ class SmarticoAPI {
|
|
|
432
526
|
[SAWSpinErrorCode.SAW_PRIZE_POOL_EMPTY]: 'PRIZE POOL IS EMPTY',
|
|
433
527
|
[SAWSpinErrorCode.SAW_NOT_ENOUGH_POINTS]: 'NOT ENOUGH POINTS',
|
|
434
528
|
[SAWSpinErrorCode.SAW_FAILED_MAX_SPINS_REACHED]: 'MAX SPIN ATTEMPTS REACHED',
|
|
435
|
-
}[spinAttemptResponse.errCode] || 'OTHER'
|
|
529
|
+
}[spinAttemptResponse.errCode] || 'OTHER';
|
|
436
530
|
|
|
437
531
|
await this.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
438
532
|
saw_template_id,
|
|
439
533
|
status,
|
|
440
534
|
round_id,
|
|
441
|
-
})
|
|
535
|
+
});
|
|
442
536
|
|
|
443
|
-
return { ...spinAttemptResponse, request_id }
|
|
537
|
+
return { ...spinAttemptResponse, request_id };
|
|
444
538
|
}
|
|
445
539
|
|
|
446
540
|
public async missionOptIn(user_ext_id: string, mission_id: number) {
|
|
447
541
|
if (!mission_id) {
|
|
448
|
-
throw new Error('Missing mission id')
|
|
542
|
+
throw new Error('Missing mission id');
|
|
449
543
|
}
|
|
450
|
-
const message = this.buildMessage<AchievementOptinRequest, AchievementOptinResponse>(
|
|
451
|
-
|
|
452
|
-
|
|
544
|
+
const message = this.buildMessage<AchievementOptinRequest, AchievementOptinResponse>(
|
|
545
|
+
user_ext_id,
|
|
546
|
+
ClassId.MISSION_OPTIN_REQUEST,
|
|
547
|
+
{
|
|
548
|
+
achievementId: mission_id,
|
|
549
|
+
},
|
|
550
|
+
);
|
|
453
551
|
|
|
454
|
-
const res = await this.send<AchievementOptinResponse>(message, ClassId.MISSION_OPTIN_RESPONSE)
|
|
552
|
+
const res = await this.send<AchievementOptinResponse>(message, ClassId.MISSION_OPTIN_RESPONSE);
|
|
455
553
|
|
|
456
|
-
return res
|
|
554
|
+
return res;
|
|
457
555
|
}
|
|
458
556
|
|
|
459
557
|
public async missionClaimPrize(user_ext_id: string, mission_id: number, ach_completed_id: number) {
|
|
460
558
|
if (!mission_id) {
|
|
461
|
-
throw new Error('Missing mission id')
|
|
559
|
+
throw new Error('Missing mission id');
|
|
462
560
|
}
|
|
463
561
|
|
|
464
|
-
const message = this.buildMessage<AchClaimPrizeRequest, AchClaimPrizeResponse>(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
562
|
+
const message = this.buildMessage<AchClaimPrizeRequest, AchClaimPrizeResponse>(
|
|
563
|
+
user_ext_id,
|
|
564
|
+
ClassId.ACHIEVEMENT_CLAIM_PRIZE_REQUEST,
|
|
565
|
+
{
|
|
566
|
+
ach_id: mission_id,
|
|
567
|
+
ach_completed_id: ach_completed_id,
|
|
568
|
+
},
|
|
569
|
+
);
|
|
468
570
|
|
|
469
|
-
const res = await this.send<AchClaimPrizeResponse>(message, ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE)
|
|
571
|
+
const res = await this.send<AchClaimPrizeResponse>(message, ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE);
|
|
470
572
|
|
|
471
|
-
return res
|
|
573
|
+
return res;
|
|
472
574
|
}
|
|
473
575
|
|
|
474
576
|
public async registerInTournament(user_ext_id: string, tournamentInstanceId: number) {
|
|
475
577
|
if (!tournamentInstanceId) {
|
|
476
|
-
throw new Error('Missing tournament instance id')
|
|
578
|
+
throw new Error('Missing tournament instance id');
|
|
477
579
|
}
|
|
478
|
-
const message = this.buildMessage<TournamentRegisterRequest, TournamentRegisterResponse>(
|
|
479
|
-
|
|
480
|
-
|
|
580
|
+
const message = this.buildMessage<TournamentRegisterRequest, TournamentRegisterResponse>(
|
|
581
|
+
user_ext_id,
|
|
582
|
+
ClassId.TOURNAMENT_REGISTER_REQUEST,
|
|
583
|
+
{
|
|
584
|
+
tournamentInstanceId,
|
|
585
|
+
},
|
|
586
|
+
);
|
|
481
587
|
|
|
482
|
-
const res = await this.send<TournamentRegisterResponse>(message, ClassId.TOURNAMENT_REGISTER_RESPONSE)
|
|
588
|
+
const res = await this.send<TournamentRegisterResponse>(message, ClassId.TOURNAMENT_REGISTER_RESPONSE);
|
|
483
589
|
|
|
484
|
-
return res
|
|
590
|
+
return res;
|
|
485
591
|
}
|
|
486
592
|
|
|
487
593
|
public async buyStoreItem(user_ext_id: string, itemId: number) {
|
|
488
594
|
if (!itemId) {
|
|
489
|
-
throw new Error('Missing store item id')
|
|
595
|
+
throw new Error('Missing store item id');
|
|
490
596
|
}
|
|
491
597
|
const message = this.buildMessage<BuyStoreItemRequest, BuyStoreItemResponse>(user_ext_id, ClassId.BUY_SHOP_ITEM_REQUEST, {
|
|
492
598
|
itemId,
|
|
493
|
-
})
|
|
599
|
+
});
|
|
494
600
|
|
|
495
|
-
const res = await this.send<BuyStoreItemResponse>(message, ClassId.BUY_SHOP_ITEM_RESPONSE)
|
|
601
|
+
const res = await this.send<BuyStoreItemResponse>(message, ClassId.BUY_SHOP_ITEM_RESPONSE);
|
|
496
602
|
|
|
497
|
-
return res
|
|
603
|
+
return res;
|
|
498
604
|
}
|
|
499
605
|
|
|
500
|
-
public async inboxGetMessages(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
606
|
+
public async inboxGetMessages(
|
|
607
|
+
user_ext_id: string,
|
|
608
|
+
limit: number = 10,
|
|
609
|
+
offset: number = 0,
|
|
610
|
+
): Promise<GetInboxMessagesResponse> {
|
|
611
|
+
const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(
|
|
612
|
+
user_ext_id,
|
|
613
|
+
ClassId.GET_INBOX_MESSAGES_REQUEST,
|
|
614
|
+
{
|
|
615
|
+
limit,
|
|
616
|
+
offset,
|
|
617
|
+
},
|
|
618
|
+
);
|
|
505
619
|
|
|
506
|
-
return await this.send<GetInboxMessagesResponse>(message, ClassId.GET_INBOX_MESSAGES_RESPONSE)
|
|
620
|
+
return await this.send<GetInboxMessagesResponse>(message, ClassId.GET_INBOX_MESSAGES_RESPONSE);
|
|
507
621
|
}
|
|
508
622
|
|
|
509
623
|
public async storeGetItems(user_ext_id: string, force_language?: string): Promise<GetStoreItemsResponse> {
|
|
510
|
-
const message = this.buildMessage<any, GetStoreItemsResponse>(user_ext_id, ClassId.GET_SHOP_ITEMS_REQUEST)
|
|
511
|
-
return await this.send<GetStoreItemsResponse>(message, ClassId.GET_SHOP_ITEMS_RESPONSE, force_language)
|
|
624
|
+
const message = this.buildMessage<any, GetStoreItemsResponse>(user_ext_id, ClassId.GET_SHOP_ITEMS_REQUEST);
|
|
625
|
+
return await this.send<GetStoreItemsResponse>(message, ClassId.GET_SHOP_ITEMS_RESPONSE, force_language);
|
|
512
626
|
}
|
|
513
627
|
|
|
514
628
|
public async storeGetItemsT(user_ext_id: string): Promise<TStoreItem[]> {
|
|
515
|
-
return StoreItemTransform((await this.storeGetItems(user_ext_id)).items)
|
|
629
|
+
return StoreItemTransform((await this.storeGetItems(user_ext_id)).items);
|
|
516
630
|
}
|
|
517
631
|
|
|
518
632
|
public async storeGetCategories(user_ext_id: string, force_language?: string): Promise<GetCategoriesStoreResponse> {
|
|
519
|
-
const message = this.buildMessage<any, GetCategoriesStoreResponse>(user_ext_id, ClassId.GET_SHOP_CATEGORIES_REQUEST)
|
|
520
|
-
return await this.send<GetCategoriesStoreResponse>(message, ClassId.GET_SHOP_CATEGORIES_RESPONSE, force_language)
|
|
633
|
+
const message = this.buildMessage<any, GetCategoriesStoreResponse>(user_ext_id, ClassId.GET_SHOP_CATEGORIES_REQUEST);
|
|
634
|
+
return await this.send<GetCategoriesStoreResponse>(message, ClassId.GET_SHOP_CATEGORIES_RESPONSE, force_language);
|
|
521
635
|
}
|
|
522
636
|
|
|
523
637
|
public async storeGetCategoriesT(user_ext_id: string): Promise<TStoreCategory[]> {
|
|
524
|
-
return StoreCategoryTransform((await this.storeGetCategories(user_ext_id)).categories)
|
|
638
|
+
return StoreCategoryTransform((await this.storeGetCategories(user_ext_id)).categories);
|
|
525
639
|
}
|
|
526
640
|
|
|
527
|
-
public async storeGetPurchasedItems(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
641
|
+
public async storeGetPurchasedItems(
|
|
642
|
+
user_ext_id: string,
|
|
643
|
+
limit: number = 20,
|
|
644
|
+
offset: number = 0,
|
|
645
|
+
): Promise<GetStoreHistoryResponse> {
|
|
646
|
+
const message = this.buildMessage<GetStoreHistoryRequest, GetStoreHistoryResponse>(
|
|
647
|
+
user_ext_id,
|
|
648
|
+
ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST,
|
|
649
|
+
{
|
|
650
|
+
limit,
|
|
651
|
+
offset,
|
|
652
|
+
},
|
|
653
|
+
);
|
|
532
654
|
|
|
533
|
-
return await this.send<GetStoreHistoryResponse>(message, ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE)
|
|
655
|
+
return await this.send<GetStoreHistoryResponse>(message, ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE);
|
|
534
656
|
}
|
|
535
657
|
|
|
536
658
|
public async storeGetPurchasedItemsT(user_ext_id: string, limit?: number, offset?: number): Promise<TStoreItem[]> {
|
|
537
|
-
return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items)
|
|
659
|
+
return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items);
|
|
538
660
|
}
|
|
539
661
|
|
|
540
662
|
public async missionsGetItems(user_ext_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
|
|
541
|
-
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(
|
|
542
|
-
|
|
663
|
+
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(
|
|
664
|
+
user_ext_id,
|
|
665
|
+
ClassId.GET_ACHIEVEMENT_MAP_REQUEST,
|
|
666
|
+
);
|
|
667
|
+
const response = await this.send<GetAchievementMapResponse>(
|
|
668
|
+
message,
|
|
669
|
+
ClassId.GET_ACHIEVEMENT_MAP_RESPONSE,
|
|
670
|
+
force_language,
|
|
671
|
+
);
|
|
543
672
|
// we need to clone response to avoid changing original object,for cases when its called together with badgesGetItems (e.g. in Promise.all)
|
|
544
|
-
const responseClone = { ...response }
|
|
673
|
+
const responseClone = { ...response };
|
|
545
674
|
|
|
546
675
|
if (responseClone.achievements) {
|
|
547
|
-
responseClone.achievements = responseClone.achievements.filter((a) => a.ach_type_id === AchievementType.Mission)
|
|
676
|
+
responseClone.achievements = responseClone.achievements.filter((a) => a.ach_type_id === AchievementType.Mission);
|
|
548
677
|
}
|
|
549
|
-
return responseClone
|
|
678
|
+
return responseClone;
|
|
550
679
|
}
|
|
551
680
|
|
|
552
681
|
public async missionsGetItemsT(user_ext_id: string): Promise<TMissionOrBadge[]> {
|
|
553
|
-
return UserAchievementTransform((await this.missionsGetItems(user_ext_id)).achievements)
|
|
682
|
+
return UserAchievementTransform((await this.missionsGetItems(user_ext_id)).achievements);
|
|
554
683
|
}
|
|
555
684
|
|
|
556
685
|
public async getUserGamificationInfo(user_ext_id: string): Promise<GetAchievementsUserInfoResponse> {
|
|
557
|
-
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementsUserInfoResponse>(
|
|
686
|
+
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementsUserInfoResponse>(
|
|
687
|
+
user_ext_id,
|
|
688
|
+
ClassId.GET_ACHIEVEMENT_USER_REQUEST,
|
|
689
|
+
);
|
|
558
690
|
|
|
559
|
-
return await this.send<GetAchievementsUserInfoResponse>(message, ClassId.GET_ACHIEVEMENT_USER_RESPONSE)
|
|
691
|
+
return await this.send<GetAchievementsUserInfoResponse>(message, ClassId.GET_ACHIEVEMENT_USER_RESPONSE);
|
|
560
692
|
}
|
|
561
693
|
|
|
562
694
|
public async getUserGamificationInfoT(user_ext_id: string): Promise<UserLevelExtraCountersT> {
|
|
563
|
-
const response = await this.getUserGamificationInfo(user_ext_id)
|
|
695
|
+
const response = await this.getUserGamificationInfo(user_ext_id);
|
|
564
696
|
|
|
565
697
|
return {
|
|
566
698
|
level_counter_1: response.level_counter_1,
|
|
567
699
|
level_counter_2: response.level_counter_2,
|
|
568
|
-
}
|
|
700
|
+
};
|
|
569
701
|
}
|
|
570
702
|
|
|
571
703
|
public async achGetCategories(user_ext_id: string, force_language?: string): Promise<GetAchCategoriesResponse> {
|
|
572
|
-
const message = this.buildMessage<any, GetAchCategoriesResponse>(user_ext_id, ClassId.GET_ACH_CATEGORIES_REQUEST)
|
|
573
|
-
return await this.send<GetAchCategoriesResponse>(message, ClassId.GET_ACH_CATEGORIES_RESPONSE, force_language)
|
|
704
|
+
const message = this.buildMessage<any, GetAchCategoriesResponse>(user_ext_id, ClassId.GET_ACH_CATEGORIES_REQUEST);
|
|
705
|
+
return await this.send<GetAchCategoriesResponse>(message, ClassId.GET_ACH_CATEGORIES_RESPONSE, force_language);
|
|
574
706
|
}
|
|
575
707
|
|
|
576
708
|
public async achGetCategoriesT(user_ext_id: string): Promise<TAchCategory[]> {
|
|
577
|
-
return AchCategoryTransform((await this.achGetCategories(user_ext_id)).categories)
|
|
709
|
+
return AchCategoryTransform((await this.achGetCategories(user_ext_id)).categories);
|
|
578
710
|
}
|
|
579
711
|
|
|
580
712
|
public async badgetsGetItems(user_ext_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
|
|
581
|
-
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(
|
|
582
|
-
|
|
713
|
+
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(
|
|
714
|
+
user_ext_id,
|
|
715
|
+
ClassId.GET_ACHIEVEMENT_MAP_REQUEST,
|
|
716
|
+
);
|
|
717
|
+
const response = await this.send<GetAchievementMapResponse>(
|
|
718
|
+
message,
|
|
719
|
+
ClassId.GET_ACHIEVEMENT_MAP_RESPONSE,
|
|
720
|
+
force_language,
|
|
721
|
+
);
|
|
583
722
|
// we need to clone response to avoid changing original object,for cases when its called together with missionsGetItems (e.g. in Promise.all)
|
|
584
|
-
const responseClone = { ...response }
|
|
723
|
+
const responseClone = { ...response };
|
|
585
724
|
|
|
586
725
|
if (responseClone.achievements) {
|
|
587
|
-
responseClone.achievements = responseClone.achievements.filter((a) => a.ach_type_id === AchievementType.Badge)
|
|
726
|
+
responseClone.achievements = responseClone.achievements.filter((a) => a.ach_type_id === AchievementType.Badge);
|
|
588
727
|
}
|
|
589
|
-
return responseClone
|
|
728
|
+
return responseClone;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
public async bonusesGetItems(user_ext_id: string, force_language?: string): Promise<GetBonusesResponse> {
|
|
732
|
+
const message = this.buildMessage<GetBonusesRequest, GetBonusesResponse>(
|
|
733
|
+
user_ext_id,
|
|
734
|
+
ClassId.GET_BONUSES_REQUEST,
|
|
735
|
+
);
|
|
736
|
+
const response = await this.send<GetBonusesResponse>(
|
|
737
|
+
message,
|
|
738
|
+
ClassId.GET_BONUSES_RESPONSE,
|
|
739
|
+
force_language,
|
|
740
|
+
);
|
|
741
|
+
|
|
742
|
+
const responseClone = { ...response };
|
|
743
|
+
|
|
744
|
+
return responseClone;
|
|
745
|
+
}
|
|
746
|
+
public async bonusClaimItem(user_ext_id: string, bonus_id: number): Promise<ClaimBonusResponse> {
|
|
747
|
+
const message = this.buildMessage<ClaimBonusRequest, ClaimBonusResponse>(
|
|
748
|
+
user_ext_id,
|
|
749
|
+
ClassId.CLAIM_BONUS_REQUEST,
|
|
750
|
+
{ bonusId: bonus_id }
|
|
751
|
+
|
|
752
|
+
);
|
|
753
|
+
const response = await this.send<ClaimBonusResponse>(
|
|
754
|
+
message,
|
|
755
|
+
ClassId.CLAIM_BONUS_RESPONSE,
|
|
756
|
+
|
|
757
|
+
);
|
|
758
|
+
|
|
759
|
+
const responseClone = { ...response };
|
|
760
|
+
|
|
761
|
+
return responseClone;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
public async bonusesGetItemsT(user_ext_id: string): Promise<TBonus[]> {
|
|
765
|
+
return BonusItemsTransform((await this.bonusesGetItems(user_ext_id)).bonuses);
|
|
590
766
|
}
|
|
591
767
|
|
|
592
768
|
public async badgetsGetItemsT(user_ext_id: string): Promise<TMissionOrBadge[]> {
|
|
593
|
-
return UserAchievementTransform((await this.badgetsGetItems(user_ext_id)).achievements)
|
|
769
|
+
return UserAchievementTransform((await this.badgetsGetItems(user_ext_id)).achievements);
|
|
594
770
|
}
|
|
595
771
|
|
|
596
772
|
public async tournamentsGetLobby(user_ext_id: string, force_language?: string): Promise<GetTournamentsResponse> {
|
|
597
|
-
const message = this.buildMessage<GetTournamentsRequest, GetTournamentsResponse>(
|
|
598
|
-
|
|
773
|
+
const message = this.buildMessage<GetTournamentsRequest, GetTournamentsResponse>(
|
|
774
|
+
user_ext_id,
|
|
775
|
+
ClassId.GET_TOURNAMENT_LOBBY_REQUEST,
|
|
776
|
+
);
|
|
777
|
+
return await this.send<GetTournamentsResponse>(message, ClassId.GET_TOURNAMENT_LOBBY_RESPONSE, force_language);
|
|
599
778
|
}
|
|
600
779
|
|
|
601
780
|
public async tournamentsGetLobbyT(user_ext_id: string): Promise<TTournament[]> {
|
|
602
|
-
return TournamentItemsTransform((await this.tournamentsGetLobby(user_ext_id)).tournaments)
|
|
781
|
+
return TournamentItemsTransform((await this.tournamentsGetLobby(user_ext_id)).tournaments);
|
|
603
782
|
}
|
|
604
783
|
|
|
605
|
-
public async tournamentsGetInfo(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
784
|
+
public async tournamentsGetInfo(
|
|
785
|
+
user_ext_id: string,
|
|
786
|
+
tournamentInstanceId: number,
|
|
787
|
+
force_language?: string,
|
|
788
|
+
): Promise<GetTournamentInfoResponse> {
|
|
789
|
+
const message = this.buildMessage<GetTournamentInfoRequest, GetTournamentInfoResponse>(
|
|
790
|
+
user_ext_id,
|
|
791
|
+
ClassId.GET_TOURNAMENT_INFO_REQUEST,
|
|
792
|
+
{
|
|
793
|
+
tournamentInstanceId,
|
|
794
|
+
},
|
|
795
|
+
);
|
|
796
|
+
const response = await this.send<GetTournamentInfoResponse>(
|
|
797
|
+
message,
|
|
798
|
+
ClassId.GET_TOURNAMENT_INFO_RESPONSE,
|
|
799
|
+
force_language,
|
|
800
|
+
);
|
|
610
801
|
|
|
611
802
|
if (response.userPosition?.avatar_id) {
|
|
612
|
-
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, this.avatarDomain)
|
|
803
|
+
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, this.avatarDomain);
|
|
613
804
|
}
|
|
614
805
|
|
|
615
806
|
if (response.tournamentInfo.players?.length) {
|
|
616
807
|
response.tournamentInfo.players.forEach((p) => {
|
|
617
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, this.avatarDomain)
|
|
618
|
-
})
|
|
808
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, this.avatarDomain);
|
|
809
|
+
});
|
|
619
810
|
}
|
|
620
811
|
|
|
621
|
-
return response
|
|
812
|
+
return response;
|
|
622
813
|
}
|
|
623
814
|
|
|
624
815
|
public async tournamentsGetInfoT(user_ext_id: string, tournamentInstanceId: number): Promise<TTournamentDetailed> {
|
|
625
816
|
if (!tournamentInstanceId) {
|
|
626
|
-
throw new Error('Missing tournament instance id')
|
|
817
|
+
throw new Error('Missing tournament instance id');
|
|
627
818
|
}
|
|
628
|
-
const response = await this.tournamentsGetInfo(user_ext_id, tournamentInstanceId)
|
|
629
|
-
return tournamentInfoItemTransform(response)
|
|
819
|
+
const response = await this.tournamentsGetInfo(user_ext_id, tournamentInstanceId);
|
|
820
|
+
return tournamentInfoItemTransform(response);
|
|
630
821
|
}
|
|
631
822
|
|
|
632
|
-
public async leaderboardGet(
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
823
|
+
public async leaderboardGet(
|
|
824
|
+
user_ext_id: string,
|
|
825
|
+
period_type_id?: LeaderBoardPeriodType,
|
|
826
|
+
prevPeriod: boolean = false,
|
|
827
|
+
force_language?: string,
|
|
828
|
+
): Promise<LeaderBoardDetails> {
|
|
829
|
+
const message = this.buildMessage<GetLeaderBoardsRequest, GetLeaderBoardsResponse>(
|
|
830
|
+
user_ext_id,
|
|
831
|
+
ClassId.GET_LEADERS_BOARD_REQUEST,
|
|
832
|
+
{
|
|
833
|
+
period_type_id,
|
|
834
|
+
snapshot_offset: prevPeriod ? 1 : 0,
|
|
835
|
+
include_users: true,
|
|
836
|
+
},
|
|
837
|
+
);
|
|
638
838
|
|
|
639
|
-
const response = await this.send<GetLeaderBoardsResponse>(message, ClassId.GET_LEADERS_BOARD_RESPONSE, force_language)
|
|
839
|
+
const response = await this.send<GetLeaderBoardsResponse>(message, ClassId.GET_LEADERS_BOARD_RESPONSE, force_language);
|
|
640
840
|
|
|
641
|
-
const boardKey = Object.keys(response.map).find((k) => period_type_id === undefined || k === period_type_id?.toString())
|
|
841
|
+
const boardKey = Object.keys(response.map).find((k) => period_type_id === undefined || k === period_type_id?.toString());
|
|
642
842
|
|
|
643
843
|
if (boardKey === undefined) {
|
|
644
|
-
return undefined
|
|
844
|
+
return undefined;
|
|
645
845
|
}
|
|
646
846
|
|
|
647
847
|
if (response.map[boardKey]?.userPosition?.avatar_id) {
|
|
648
|
-
response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(
|
|
848
|
+
response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(
|
|
849
|
+
response.map[boardKey].userPosition.avatar_id,
|
|
850
|
+
this.avatarDomain,
|
|
851
|
+
);
|
|
649
852
|
}
|
|
650
853
|
|
|
651
854
|
if (response.map[boardKey]?.positions?.length) {
|
|
652
855
|
response.map[boardKey].positions.forEach((p) => {
|
|
653
|
-
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, this.avatarDomain)
|
|
654
|
-
})
|
|
856
|
+
p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, this.avatarDomain);
|
|
857
|
+
});
|
|
655
858
|
}
|
|
656
859
|
|
|
657
|
-
return response.map[boardKey]
|
|
860
|
+
return response.map[boardKey];
|
|
658
861
|
}
|
|
659
862
|
|
|
660
|
-
public async leaderboardsGetT(
|
|
661
|
-
|
|
863
|
+
public async leaderboardsGetT(
|
|
864
|
+
user_ext_id: string,
|
|
865
|
+
period_type_id: LeaderBoardPeriodType = LeaderBoardPeriodType.DAILY,
|
|
866
|
+
prevPeriod: boolean = false,
|
|
867
|
+
): Promise<LeaderBoardDetailsT> {
|
|
868
|
+
return getLeaderBoardTransform(await this.leaderboardGet(user_ext_id, period_type_id, prevPeriod));
|
|
662
869
|
}
|
|
663
870
|
|
|
664
871
|
public async levelsGet(user_ext_id: string, force_language?: string): Promise<GetLevelMapResponse> {
|
|
665
|
-
const message = this.buildMessage<any, GetLevelMapResponse>(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST)
|
|
666
|
-
return await this.send<GetLevelMapResponse>(message, ClassId.GET_LEVEL_MAP_RESPONSE, force_language)
|
|
872
|
+
const message = this.buildMessage<any, GetLevelMapResponse>(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST);
|
|
873
|
+
return await this.send<GetLevelMapResponse>(message, ClassId.GET_LEVEL_MAP_RESPONSE, force_language);
|
|
667
874
|
}
|
|
668
875
|
|
|
669
876
|
public async levelsGetT(user_ext_id: string): Promise<TLevel[]> {
|
|
670
|
-
return GetLevelMapResponseTransform(await this.levelsGet(user_ext_id))
|
|
877
|
+
return GetLevelMapResponseTransform(await this.levelsGet(user_ext_id));
|
|
671
878
|
}
|
|
672
879
|
|
|
673
880
|
public async getCustomSections(user_ext_id: string): Promise<GetCustomSectionsResponse> {
|
|
674
|
-
const message = this.buildMessage<GetCustomSectionsRequest, GetCustomSectionsResponse>(
|
|
675
|
-
|
|
881
|
+
const message = this.buildMessage<GetCustomSectionsRequest, GetCustomSectionsResponse>(
|
|
882
|
+
user_ext_id,
|
|
883
|
+
ClassId.GET_CUSTOM_SECTIONS_REQUEST,
|
|
884
|
+
);
|
|
885
|
+
return await this.send<GetCustomSectionsResponse>(message, ClassId.GET_CUSTOM_SECTIONS_RESPONSE);
|
|
676
886
|
}
|
|
677
887
|
|
|
678
888
|
public async getCustomSectionsT(user_ext_id: string): Promise<TUICustomSection[]> {
|
|
679
|
-
return UICustomSectionTransform(Object.values((await this.getCustomSections(user_ext_id)).customSections))
|
|
889
|
+
return UICustomSectionTransform(Object.values((await this.getCustomSections(user_ext_id)).customSections));
|
|
680
890
|
}
|
|
681
891
|
|
|
682
|
-
public async getTranslationsT(
|
|
683
|
-
|
|
892
|
+
public async getTranslationsT(
|
|
893
|
+
user_ext_id: string,
|
|
894
|
+
lang_code: string,
|
|
895
|
+
areas: TranslationArea[],
|
|
896
|
+
cacheSec: number = 60,
|
|
897
|
+
): Promise<GetTranslationsResponse> {
|
|
898
|
+
return await this.coreGetTranslations(user_ext_id, lang_code, areas, 30);
|
|
684
899
|
}
|
|
685
900
|
|
|
686
|
-
public async getInboxMessages(
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
901
|
+
public async getInboxMessages(
|
|
902
|
+
user_ext_id: string,
|
|
903
|
+
limit: number = 20,
|
|
904
|
+
offset: number = 0,
|
|
905
|
+
starred_only: boolean,
|
|
906
|
+
): Promise<GetInboxMessagesResponse> {
|
|
907
|
+
const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(
|
|
908
|
+
user_ext_id,
|
|
909
|
+
ClassId.GET_INBOX_MESSAGES_REQUEST,
|
|
910
|
+
{
|
|
911
|
+
limit,
|
|
912
|
+
offset,
|
|
913
|
+
starred_only,
|
|
914
|
+
},
|
|
915
|
+
);
|
|
916
|
+
return await this.send<GetInboxMessagesResponse>(message, ClassId.GET_INBOX_MESSAGES_RESPONSE);
|
|
693
917
|
}
|
|
694
918
|
|
|
695
|
-
public async getInboxMessagesT(
|
|
696
|
-
|
|
697
|
-
|
|
919
|
+
public async getInboxMessagesT(
|
|
920
|
+
user_ext_id: string,
|
|
921
|
+
from: number = 0,
|
|
922
|
+
to: number = 20,
|
|
923
|
+
favoriteOnly: boolean = false,
|
|
924
|
+
): Promise<TInboxMessage[]> {
|
|
925
|
+
const limit = to - from > 20 ? 20 : to - from;
|
|
926
|
+
const offset = from;
|
|
698
927
|
|
|
699
|
-
return InboxMessagesTransform((await this.getInboxMessages(user_ext_id, limit, offset, favoriteOnly)).log)
|
|
928
|
+
return InboxMessagesTransform((await this.getInboxMessages(user_ext_id, limit, offset, favoriteOnly)).log);
|
|
700
929
|
}
|
|
701
930
|
|
|
702
931
|
public async getInboxMessageBody(messageGuid: string): Promise<InboxMessageBody> {
|
|
703
932
|
const getMessageBody = async (messageGuid: string): Promise<InboxMessageBody> => {
|
|
704
|
-
const inboxCdnUrl = this.tracker.getLabelSetting(PublicLabelSettings.INBOX_PUBLIC_CDN)
|
|
933
|
+
const inboxCdnUrl = this.tracker.getLabelSetting(PublicLabelSettings.INBOX_PUBLIC_CDN);
|
|
705
934
|
|
|
706
935
|
try {
|
|
707
|
-
const url = `${inboxCdnUrl}${messageGuid}.json
|
|
936
|
+
const url = `${inboxCdnUrl}${messageGuid}.json`;
|
|
708
937
|
|
|
709
938
|
const response = await fetch(url, {
|
|
710
939
|
method: 'GET',
|
|
@@ -713,67 +942,91 @@ class SmarticoAPI {
|
|
|
713
942
|
'Content-Type': 'application/json',
|
|
714
943
|
'Access-Control-Allow-Origin': '*',
|
|
715
944
|
},
|
|
716
|
-
})
|
|
717
|
-
const data = await response.json()
|
|
718
|
-
return data || {}
|
|
945
|
+
});
|
|
946
|
+
const data = await response.json();
|
|
947
|
+
return data || {};
|
|
719
948
|
} catch (error) {
|
|
720
|
-
this.logger.error('Error fetching inbox message body:', error)
|
|
721
|
-
return null
|
|
949
|
+
this.logger.error('Error fetching inbox message body:', error);
|
|
950
|
+
return null;
|
|
722
951
|
}
|
|
723
|
-
}
|
|
952
|
+
};
|
|
724
953
|
|
|
725
|
-
return await getMessageBody(messageGuid)
|
|
954
|
+
return await getMessageBody(messageGuid);
|
|
726
955
|
}
|
|
727
956
|
|
|
728
957
|
public async getInboxMessageBodyT(messageGuid: string): Promise<TInboxMessageBody> {
|
|
729
|
-
const message = await this.getInboxMessageBody(messageGuid)
|
|
730
|
-
return InboxMessageBodyTransform(message)
|
|
958
|
+
const message = await this.getInboxMessageBody(messageGuid);
|
|
959
|
+
return InboxMessageBodyTransform(message);
|
|
731
960
|
}
|
|
732
961
|
|
|
733
962
|
public async markInboxMessageRead(user_ext_id: string, messageGuid: string): Promise<MarkInboxMessageReadResponse> {
|
|
734
|
-
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(
|
|
735
|
-
|
|
736
|
-
|
|
963
|
+
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(
|
|
964
|
+
user_ext_id,
|
|
965
|
+
ClassId.MARK_INBOX_READ_REQUEST,
|
|
966
|
+
{
|
|
967
|
+
engagement_uid: messageGuid,
|
|
968
|
+
},
|
|
969
|
+
);
|
|
737
970
|
|
|
738
|
-
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE)
|
|
971
|
+
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE);
|
|
739
972
|
}
|
|
740
973
|
|
|
741
974
|
public async markAllInboxMessageRead(user_ext_id: string): Promise<MarkInboxMessageReadResponse> {
|
|
742
|
-
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(
|
|
743
|
-
|
|
744
|
-
|
|
975
|
+
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(
|
|
976
|
+
user_ext_id,
|
|
977
|
+
ClassId.MARK_INBOX_READ_REQUEST,
|
|
978
|
+
{
|
|
979
|
+
all_read: true,
|
|
980
|
+
},
|
|
981
|
+
);
|
|
745
982
|
|
|
746
|
-
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE)
|
|
983
|
+
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE);
|
|
747
984
|
}
|
|
748
985
|
|
|
749
|
-
public async markUnmarkInboxMessageAsFavorite(
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
986
|
+
public async markUnmarkInboxMessageAsFavorite(
|
|
987
|
+
user_ext_id: string,
|
|
988
|
+
messageGuid: string,
|
|
989
|
+
mark: boolean,
|
|
990
|
+
): Promise<MarkInboxMessageStarredResponse> {
|
|
991
|
+
const message = this.buildMessage<MarkInboxMessageStarredRequest, MarkInboxMessageStarredResponse>(
|
|
992
|
+
user_ext_id,
|
|
993
|
+
ClassId.MARK_INBOX_STARRED_REQUEST,
|
|
994
|
+
{
|
|
995
|
+
engagement_uid: messageGuid,
|
|
996
|
+
is_starred: mark,
|
|
997
|
+
},
|
|
998
|
+
);
|
|
754
999
|
|
|
755
|
-
return await this.send<MarkInboxMessageStarredResponse>(message, ClassId.MARK_INBOX_STARRED_RESPONSE)
|
|
1000
|
+
return await this.send<MarkInboxMessageStarredResponse>(message, ClassId.MARK_INBOX_STARRED_RESPONSE);
|
|
756
1001
|
}
|
|
757
1002
|
|
|
758
1003
|
public async deleteInboxMessage(user_ext_id: string, messageGuid: string): Promise<MarkInboxMessageDeletedResponse> {
|
|
759
|
-
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(
|
|
760
|
-
|
|
761
|
-
|
|
1004
|
+
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(
|
|
1005
|
+
user_ext_id,
|
|
1006
|
+
ClassId.MARK_INBOX_DELETED_REQUEST,
|
|
1007
|
+
{
|
|
1008
|
+
engagement_uid: messageGuid,
|
|
1009
|
+
},
|
|
1010
|
+
);
|
|
762
1011
|
|
|
763
|
-
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE)
|
|
1012
|
+
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
764
1013
|
}
|
|
765
1014
|
|
|
766
1015
|
public async deleteAllInboxMessages(user_ext_id: string): Promise<MarkInboxMessageDeletedResponse> {
|
|
767
|
-
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(
|
|
768
|
-
|
|
769
|
-
|
|
1016
|
+
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(
|
|
1017
|
+
user_ext_id,
|
|
1018
|
+
ClassId.MARK_INBOX_DELETED_REQUEST,
|
|
1019
|
+
{
|
|
1020
|
+
all_deleted: true,
|
|
1021
|
+
},
|
|
1022
|
+
);
|
|
770
1023
|
|
|
771
|
-
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE)
|
|
1024
|
+
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
772
1025
|
}
|
|
773
1026
|
|
|
774
1027
|
public getWSCalls(): WSAPI {
|
|
775
|
-
return new WSAPI(this)
|
|
1028
|
+
return new WSAPI(this);
|
|
776
1029
|
}
|
|
777
1030
|
}
|
|
778
1031
|
|
|
779
|
-
export { SmarticoAPI, MessageSender }
|
|
1032
|
+
export { SmarticoAPI, MessageSender };
|