@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/WSAPI/WSAPI.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClassId } from '../Base/ClassId'
|
|
2
|
-
import { CoreUtils } from '../Core'
|
|
3
|
-
import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from '../MiniGames'
|
|
4
|
-
import { ECacheContext, OCache } from '../OCache'
|
|
5
|
-
import { SmarticoAPI } from '../SmarticoAPI'
|
|
1
|
+
import { ClassId } from '../Base/ClassId';
|
|
2
|
+
import { CoreUtils } from '../Core';
|
|
3
|
+
import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from '../MiniGames';
|
|
4
|
+
import { ECacheContext, OCache } from '../OCache';
|
|
5
|
+
import { SmarticoAPI } from '../SmarticoAPI';
|
|
6
6
|
import {
|
|
7
7
|
InboxMarkMessageAction,
|
|
8
8
|
LeaderBoardDetailsT,
|
|
@@ -25,16 +25,24 @@ import {
|
|
|
25
25
|
TTournamentRegistrationResult,
|
|
26
26
|
TUICustomSection,
|
|
27
27
|
TUserProfile,
|
|
28
|
-
UserLevelExtraCountersT,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import {
|
|
28
|
+
UserLevelExtraCountersT,TBonus,
|
|
29
|
+
TClaimBonusResult
|
|
30
|
+
} from './WSAPITypes';
|
|
31
|
+
import { LeaderBoardPeriodType } from '../Leaderboard';
|
|
32
|
+
import {
|
|
33
|
+
JackpotDetails,
|
|
34
|
+
JackpotPot,
|
|
35
|
+
JackpotWinPush,
|
|
36
|
+
JackpotsOptinResponse,
|
|
37
|
+
JackpotsOptoutRequest,
|
|
38
|
+
JackpotsOptoutResponse,
|
|
39
|
+
} from '../Jackpots';
|
|
32
40
|
|
|
33
41
|
/** @hidden */
|
|
34
|
-
const CACHE_DATA_SEC = 30
|
|
42
|
+
const CACHE_DATA_SEC = 30;
|
|
35
43
|
|
|
36
|
-
const JACKPOT_TEMPLATE_CACHE_SEC = 30
|
|
37
|
-
const JACKPOT_POT_CACHE_SEC = 1
|
|
44
|
+
const JACKPOT_TEMPLATE_CACHE_SEC = 30;
|
|
45
|
+
const JACKPOT_POT_CACHE_SEC = 1;
|
|
38
46
|
|
|
39
47
|
/** @hidden */
|
|
40
48
|
enum onUpdateContextKey {
|
|
@@ -54,29 +62,32 @@ enum onUpdateContextKey {
|
|
|
54
62
|
Jackpots = 'jackpots',
|
|
55
63
|
Pots = 'Pots',
|
|
56
64
|
CustomSections = 'customSections',
|
|
65
|
+
Bonuses = 'bonuses',
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
/** @group General API */
|
|
60
69
|
export class WSAPI {
|
|
61
|
-
private onUpdateCallback: Map<onUpdateContextKey, (data: any) => void> = new Map()
|
|
62
|
-
private jackpotGetSignature: string = ''
|
|
70
|
+
private onUpdateCallback: Map<onUpdateContextKey, (data: any) => void> = new Map();
|
|
71
|
+
private jackpotGetSignature: string = '';
|
|
63
72
|
|
|
64
73
|
/** @private */
|
|
65
74
|
constructor(private api: SmarticoAPI) {
|
|
66
|
-
OCache.clearAll()
|
|
75
|
+
OCache.clearAll();
|
|
67
76
|
if (this.api.tracker) {
|
|
68
|
-
const on = this.api.tracker.on
|
|
69
|
-
on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data))
|
|
70
|
-
on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin())
|
|
71
|
-
on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
on(ClassId.
|
|
75
|
-
on(ClassId.
|
|
76
|
-
on(ClassId.
|
|
77
|
-
on(ClassId.
|
|
78
|
-
on(ClassId.
|
|
79
|
-
on(ClassId.
|
|
77
|
+
const on = this.api.tracker.on;
|
|
78
|
+
on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data));
|
|
79
|
+
on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
|
|
80
|
+
on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) =>
|
|
81
|
+
on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)),
|
|
82
|
+
);
|
|
83
|
+
on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
|
|
84
|
+
on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration());
|
|
85
|
+
on(ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, () => this.updateInboxMessages());
|
|
86
|
+
on(ClassId.LOGOUT_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
|
|
87
|
+
on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
|
|
88
|
+
on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
|
|
89
|
+
on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache());
|
|
90
|
+
on(ClassId.JP_OPTIN_RESPONSE, (data: JackpotsOptinResponse) => this.jackpotClearCache());
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
|
|
@@ -92,11 +103,11 @@ export class WSAPI {
|
|
|
92
103
|
* */
|
|
93
104
|
public getUserProfile(): TUserProfile {
|
|
94
105
|
if (this.api.tracker) {
|
|
95
|
-
const o: TUserProfile = Object.assign({}, this.api.tracker.userPublicProps)
|
|
96
|
-
o.avatar_url = CoreUtils.avatarUrl(this.api.tracker.userPublicProps.avatar_id, this.api.avatarDomain)
|
|
97
|
-
return o
|
|
106
|
+
const o: TUserProfile = Object.assign({}, this.api.tracker.userPublicProps);
|
|
107
|
+
o.avatar_url = CoreUtils.avatarUrl(this.api.tracker.userPublicProps.avatar_id, this.api.avatarDomain);
|
|
108
|
+
return o;
|
|
98
109
|
} else {
|
|
99
|
-
throw new Error('Tracker is not initialized, cannot getUserProfile')
|
|
110
|
+
throw new Error('Tracker is not initialized, cannot getUserProfile');
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
113
|
|
|
@@ -111,11 +122,11 @@ export class WSAPI {
|
|
|
111
122
|
* **Visitor mode: not supported**
|
|
112
123
|
*/
|
|
113
124
|
public async checkSegmentMatch(segment_id: number): Promise<boolean> {
|
|
114
|
-
const r = await this.api.coreCheckSegments(null, [segment_id])
|
|
125
|
+
const r = await this.api.coreCheckSegments(null, [segment_id]);
|
|
115
126
|
if (r && r.find((s) => s.segment_id === segment_id && s.is_matching)) {
|
|
116
|
-
return true
|
|
127
|
+
return true;
|
|
117
128
|
} else {
|
|
118
|
-
return false
|
|
129
|
+
return false;
|
|
119
130
|
}
|
|
120
131
|
}
|
|
121
132
|
|
|
@@ -129,7 +140,7 @@ export class WSAPI {
|
|
|
129
140
|
* **Visitor mode: not supported**
|
|
130
141
|
*/
|
|
131
142
|
public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
|
|
132
|
-
return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids])
|
|
143
|
+
return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
/** Returns all the levels available the current user
|
|
@@ -148,7 +159,7 @@ export class WSAPI {
|
|
|
148
159
|
* ```
|
|
149
160
|
*/
|
|
150
161
|
public async getLevels(): Promise<TLevel[]> {
|
|
151
|
-
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC)
|
|
162
|
+
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
/** Returns all the missions available the current user.
|
|
@@ -172,10 +183,15 @@ export class WSAPI {
|
|
|
172
183
|
*/
|
|
173
184
|
public async getMissions({ onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMissionOrBadge[]> {
|
|
174
185
|
if (onUpdate) {
|
|
175
|
-
this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate)
|
|
186
|
+
this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
|
|
176
187
|
}
|
|
177
188
|
|
|
178
|
-
return OCache.use(
|
|
189
|
+
return OCache.use(
|
|
190
|
+
onUpdateContextKey.Missions,
|
|
191
|
+
ECacheContext.WSAPI,
|
|
192
|
+
() => this.api.missionsGetItemsT(null),
|
|
193
|
+
CACHE_DATA_SEC,
|
|
194
|
+
);
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
/**
|
|
@@ -184,9 +200,39 @@ export class WSAPI {
|
|
|
184
200
|
* **Visitor mode: not supported**
|
|
185
201
|
*/
|
|
186
202
|
public async getBadges(): Promise<TMissionOrBadge[]> {
|
|
187
|
-
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC)
|
|
203
|
+
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC);
|
|
188
204
|
}
|
|
189
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Returns all the bonuses for the current user
|
|
208
|
+
*
|
|
209
|
+
* **Visitor mode: not supported**
|
|
210
|
+
*/
|
|
211
|
+
public async getBonuses(): Promise<TBonus[]> {
|
|
212
|
+
return OCache.use(onUpdateContextKey.Bonuses, ECacheContext.WSAPI, () => this.api.bonusesGetItemsT(null), CACHE_DATA_SEC);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Claim the bonus by bonus_id. Returns the err_code in case of success or error.
|
|
217
|
+
* Note that this method can be used only on integrations where originally failed bonus can be claimed again.
|
|
218
|
+
* For example, user won a bonus in the mini-game, but Operator rejected this bonus.
|
|
219
|
+
* This bonus will be available for the user to claim again.
|
|
220
|
+
*
|
|
221
|
+
* **Visitor mode: not supported**
|
|
222
|
+
*/
|
|
223
|
+
public async claimBonus(bonus_id: number): Promise<TClaimBonusResult> {
|
|
224
|
+
const r = await this.api.bonusClaimItem(null, bonus_id);
|
|
225
|
+
|
|
226
|
+
const o: TClaimBonusResult = {
|
|
227
|
+
err_code: r.errCode,
|
|
228
|
+
err_message: r.errMsg,
|
|
229
|
+
success: r.success,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return o;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
190
236
|
/**
|
|
191
237
|
* Returns the extra counters for the current user level.
|
|
192
238
|
* These are counters that are configured for each Smartico client separatly by request.
|
|
@@ -202,7 +248,12 @@ export class WSAPI {
|
|
|
202
248
|
* **Visitor mode: not supported**
|
|
203
249
|
*/
|
|
204
250
|
public async getUserLevelExtraCounters(): Promise<UserLevelExtraCountersT> {
|
|
205
|
-
return OCache.use(
|
|
251
|
+
return OCache.use(
|
|
252
|
+
onUpdateContextKey.LevelExtraCounters,
|
|
253
|
+
ECacheContext.WSAPI,
|
|
254
|
+
() => this.api.getUserGamificationInfoT(null),
|
|
255
|
+
CACHE_DATA_SEC,
|
|
256
|
+
);
|
|
206
257
|
}
|
|
207
258
|
|
|
208
259
|
/**
|
|
@@ -225,7 +276,12 @@ export class WSAPI {
|
|
|
225
276
|
*/
|
|
226
277
|
|
|
227
278
|
public async getStoreItems(): Promise<TStoreItem[]> {
|
|
228
|
-
return OCache.use(
|
|
279
|
+
return OCache.use(
|
|
280
|
+
onUpdateContextKey.StoreItems,
|
|
281
|
+
ECacheContext.WSAPI,
|
|
282
|
+
() => this.api.storeGetItemsT(null),
|
|
283
|
+
CACHE_DATA_SEC,
|
|
284
|
+
);
|
|
229
285
|
}
|
|
230
286
|
|
|
231
287
|
/** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
|
|
@@ -239,14 +295,14 @@ export class WSAPI {
|
|
|
239
295
|
* **Visitor mode: not supported**
|
|
240
296
|
*/
|
|
241
297
|
public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
|
|
242
|
-
const r = await this.api.buyStoreItem(null, item_id)
|
|
298
|
+
const r = await this.api.buyStoreItem(null, item_id);
|
|
243
299
|
|
|
244
300
|
const o: TBuyStoreItemResult = {
|
|
245
301
|
err_code: r.errCode,
|
|
246
302
|
err_message: r.errMsg,
|
|
247
|
-
}
|
|
303
|
+
};
|
|
248
304
|
|
|
249
|
-
return o
|
|
305
|
+
return o;
|
|
250
306
|
}
|
|
251
307
|
|
|
252
308
|
/**
|
|
@@ -268,7 +324,12 @@ export class WSAPI {
|
|
|
268
324
|
* ```
|
|
269
325
|
*/
|
|
270
326
|
public async getStoreCategories(): Promise<TStoreCategory[]> {
|
|
271
|
-
return OCache.use(
|
|
327
|
+
return OCache.use(
|
|
328
|
+
onUpdateContextKey.StoreCategories,
|
|
329
|
+
ECacheContext.WSAPI,
|
|
330
|
+
() => this.api.storeGetCategoriesT(null),
|
|
331
|
+
CACHE_DATA_SEC,
|
|
332
|
+
);
|
|
272
333
|
}
|
|
273
334
|
|
|
274
335
|
/**
|
|
@@ -286,11 +347,20 @@ export class WSAPI {
|
|
|
286
347
|
* **Visitor mode: not supported**
|
|
287
348
|
*/
|
|
288
349
|
|
|
289
|
-
public async getStorePurchasedItems({
|
|
350
|
+
public async getStorePurchasedItems({
|
|
351
|
+
limit,
|
|
352
|
+
offset,
|
|
353
|
+
onUpdate,
|
|
354
|
+
}: { limit?: number; offset?: number; onUpdate?: (data: TStoreItem[]) => void } = {}): Promise<TStoreItem[]> {
|
|
290
355
|
if (onUpdate) {
|
|
291
|
-
this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate)
|
|
356
|
+
this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
|
|
292
357
|
}
|
|
293
|
-
return OCache.use(
|
|
358
|
+
return OCache.use(
|
|
359
|
+
onUpdateContextKey.StoreHistory,
|
|
360
|
+
ECacheContext.WSAPI,
|
|
361
|
+
() => this.api.storeGetPurchasedItemsT(null, limit, offset),
|
|
362
|
+
CACHE_DATA_SEC,
|
|
363
|
+
);
|
|
294
364
|
}
|
|
295
365
|
|
|
296
366
|
/**
|
|
@@ -312,7 +382,12 @@ export class WSAPI {
|
|
|
312
382
|
*
|
|
313
383
|
* */
|
|
314
384
|
public async getAchCategories(): Promise<TAchCategory[]> {
|
|
315
|
-
return OCache.use(
|
|
385
|
+
return OCache.use(
|
|
386
|
+
onUpdateContextKey.AchCategories,
|
|
387
|
+
ECacheContext.WSAPI,
|
|
388
|
+
() => this.api.achGetCategoriesT(null),
|
|
389
|
+
CACHE_DATA_SEC,
|
|
390
|
+
);
|
|
316
391
|
}
|
|
317
392
|
|
|
318
393
|
/**
|
|
@@ -334,7 +409,12 @@ export class WSAPI {
|
|
|
334
409
|
*
|
|
335
410
|
* */
|
|
336
411
|
public async getCustomSections(): Promise<TUICustomSection[]> {
|
|
337
|
-
return OCache.use(
|
|
412
|
+
return OCache.use(
|
|
413
|
+
onUpdateContextKey.CustomSections,
|
|
414
|
+
ECacheContext.WSAPI,
|
|
415
|
+
() => this.api.getCustomSectionsT(null),
|
|
416
|
+
CACHE_DATA_SEC,
|
|
417
|
+
);
|
|
338
418
|
}
|
|
339
419
|
|
|
340
420
|
/**
|
|
@@ -357,12 +437,14 @@ export class WSAPI {
|
|
|
357
437
|
* ```
|
|
358
438
|
*
|
|
359
439
|
*/
|
|
360
|
-
public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<
|
|
440
|
+
public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<
|
|
441
|
+
TMiniGameTemplate[]
|
|
442
|
+
> {
|
|
361
443
|
if (onUpdate) {
|
|
362
|
-
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate)
|
|
444
|
+
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
363
445
|
}
|
|
364
446
|
|
|
365
|
-
return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC)
|
|
447
|
+
return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
|
|
366
448
|
}
|
|
367
449
|
|
|
368
450
|
/**
|
|
@@ -371,16 +453,16 @@ export class WSAPI {
|
|
|
371
453
|
* **Visitor mode: not supported**
|
|
372
454
|
*/
|
|
373
455
|
public async playMiniGame(template_id: number): Promise<TMiniGamePlayResult> {
|
|
374
|
-
const r = await this.api.sawSpinRequest(null, template_id)
|
|
375
|
-
this.api.doAcknowledgeRequest(null, r.request_id)
|
|
456
|
+
const r = await this.api.sawSpinRequest(null, template_id);
|
|
457
|
+
this.api.doAcknowledgeRequest(null, r.request_id);
|
|
376
458
|
|
|
377
459
|
const o: TMiniGamePlayResult = {
|
|
378
460
|
err_code: r.errCode,
|
|
379
461
|
err_message: r.errMsg,
|
|
380
462
|
prize_id: r.saw_prize_id,
|
|
381
|
-
}
|
|
463
|
+
};
|
|
382
464
|
|
|
383
|
-
return o
|
|
465
|
+
return o;
|
|
384
466
|
}
|
|
385
467
|
|
|
386
468
|
/**
|
|
@@ -389,14 +471,14 @@ export class WSAPI {
|
|
|
389
471
|
* **Visitor mode: not supported**
|
|
390
472
|
*/
|
|
391
473
|
public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult> {
|
|
392
|
-
const r = await this.api.missionOptIn(null, mission_id)
|
|
474
|
+
const r = await this.api.missionOptIn(null, mission_id);
|
|
393
475
|
|
|
394
476
|
const o: TMissionOptInResult = {
|
|
395
477
|
err_code: r.errCode,
|
|
396
478
|
err_message: r.errMsg,
|
|
397
|
-
}
|
|
479
|
+
};
|
|
398
480
|
|
|
399
|
-
return o
|
|
481
|
+
return o;
|
|
400
482
|
}
|
|
401
483
|
|
|
402
484
|
/**
|
|
@@ -405,14 +487,14 @@ export class WSAPI {
|
|
|
405
487
|
* **Visitor mode: not supported**
|
|
406
488
|
*/
|
|
407
489
|
public async requestMissionClaimReward(mission_id: number, ach_completed_id: number): Promise<TMissionClaimRewardResult> {
|
|
408
|
-
const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id)
|
|
490
|
+
const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id);
|
|
409
491
|
|
|
410
492
|
const o: TMissionClaimRewardResult = {
|
|
411
493
|
err_code: r.errCode,
|
|
412
494
|
err_message: r.errMsg,
|
|
413
|
-
}
|
|
495
|
+
};
|
|
414
496
|
|
|
415
|
-
return o
|
|
497
|
+
return o;
|
|
416
498
|
}
|
|
417
499
|
|
|
418
500
|
/** Returns all the active instances of tournaments
|
|
@@ -435,10 +517,15 @@ export class WSAPI {
|
|
|
435
517
|
* */
|
|
436
518
|
public async getTournamentsList({ onUpdate }: { onUpdate?: (data: TTournament[]) => void } = {}): Promise<TTournament[]> {
|
|
437
519
|
if (onUpdate) {
|
|
438
|
-
this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate)
|
|
520
|
+
this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
|
|
439
521
|
}
|
|
440
522
|
|
|
441
|
-
return OCache.use(
|
|
523
|
+
return OCache.use(
|
|
524
|
+
onUpdateContextKey.TournamentList,
|
|
525
|
+
ECacheContext.WSAPI,
|
|
526
|
+
() => this.api.tournamentsGetLobbyT(null),
|
|
527
|
+
CACHE_DATA_SEC,
|
|
528
|
+
);
|
|
442
529
|
}
|
|
443
530
|
|
|
444
531
|
/**
|
|
@@ -467,7 +554,7 @@ export class WSAPI {
|
|
|
467
554
|
* ```
|
|
468
555
|
*/
|
|
469
556
|
public async getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed> {
|
|
470
|
-
return this.api.tournamentsGetInfoT(null, tournamentInstanceId)
|
|
557
|
+
return this.api.tournamentsGetInfoT(null, tournamentInstanceId);
|
|
471
558
|
}
|
|
472
559
|
|
|
473
560
|
/**
|
|
@@ -476,14 +563,14 @@ export class WSAPI {
|
|
|
476
563
|
* **Visitor mode: not supported**
|
|
477
564
|
*/
|
|
478
565
|
public async registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult> {
|
|
479
|
-
const r = await this.api.registerInTournament(null, tournamentInstanceId)
|
|
566
|
+
const r = await this.api.registerInTournament(null, tournamentInstanceId);
|
|
480
567
|
|
|
481
568
|
const o: TTournamentRegistrationResult = {
|
|
482
569
|
err_code: r.errCode,
|
|
483
570
|
err_message: r.errMsg,
|
|
484
|
-
}
|
|
571
|
+
};
|
|
485
572
|
|
|
486
|
-
return o
|
|
573
|
+
return o;
|
|
487
574
|
}
|
|
488
575
|
|
|
489
576
|
/**
|
|
@@ -505,7 +592,12 @@ export class WSAPI {
|
|
|
505
592
|
* ```
|
|
506
593
|
*/
|
|
507
594
|
public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {
|
|
508
|
-
return OCache.use(
|
|
595
|
+
return OCache.use(
|
|
596
|
+
onUpdateContextKey.LeaderBoards,
|
|
597
|
+
ECacheContext.WSAPI,
|
|
598
|
+
() => this.api.leaderboardsGetT(null, periodType, getPreviousPeriod),
|
|
599
|
+
CACHE_DATA_SEC,
|
|
600
|
+
);
|
|
509
601
|
}
|
|
510
602
|
|
|
511
603
|
/** Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
|
|
@@ -520,14 +612,19 @@ export class WSAPI {
|
|
|
520
612
|
*
|
|
521
613
|
* @param params
|
|
522
614
|
*/
|
|
523
|
-
public async getInboxMessages({
|
|
615
|
+
public async getInboxMessages({
|
|
616
|
+
from,
|
|
617
|
+
to,
|
|
618
|
+
onlyFavorite,
|
|
619
|
+
onUpdate,
|
|
620
|
+
}: { from?: number; to?: number; onlyFavorite?: boolean; onUpdate?: (data: TInboxMessage[]) => void } = {}): Promise<
|
|
524
621
|
TInboxMessage[]
|
|
525
622
|
> {
|
|
526
623
|
if (onUpdate) {
|
|
527
|
-
this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate)
|
|
624
|
+
this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
|
|
528
625
|
}
|
|
529
626
|
|
|
530
|
-
return await this.api.getInboxMessagesT(null, from, to, onlyFavorite)
|
|
627
|
+
return await this.api.getInboxMessagesT(null, from, to, onlyFavorite);
|
|
531
628
|
}
|
|
532
629
|
|
|
533
630
|
/**
|
|
@@ -536,7 +633,7 @@ export class WSAPI {
|
|
|
536
633
|
* **Visitor mode: not supported**
|
|
537
634
|
*/
|
|
538
635
|
public async getInboxMessageBody(messageGuid: string): Promise<TInboxMessageBody> {
|
|
539
|
-
return await this.api.getInboxMessageBodyT(messageGuid)
|
|
636
|
+
return await this.api.getInboxMessageBodyT(messageGuid);
|
|
540
637
|
}
|
|
541
638
|
|
|
542
639
|
/**
|
|
@@ -545,12 +642,12 @@ export class WSAPI {
|
|
|
545
642
|
* **Visitor mode: not supported**
|
|
546
643
|
*/
|
|
547
644
|
public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
548
|
-
const r = await this.api.markInboxMessageRead(null, messageGuid)
|
|
645
|
+
const r = await this.api.markInboxMessageRead(null, messageGuid);
|
|
549
646
|
|
|
550
647
|
return {
|
|
551
648
|
err_code: r.errCode,
|
|
552
649
|
err_message: r.errMsg,
|
|
553
|
-
}
|
|
650
|
+
};
|
|
554
651
|
}
|
|
555
652
|
|
|
556
653
|
/**
|
|
@@ -559,12 +656,12 @@ export class WSAPI {
|
|
|
559
656
|
* **Visitor mode: not supported**
|
|
560
657
|
*/
|
|
561
658
|
public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
|
|
562
|
-
const r = await this.api.markAllInboxMessageRead(null)
|
|
659
|
+
const r = await this.api.markAllInboxMessageRead(null);
|
|
563
660
|
|
|
564
661
|
return {
|
|
565
662
|
err_code: r.errCode,
|
|
566
663
|
err_message: r.errMsg,
|
|
567
|
-
}
|
|
664
|
+
};
|
|
568
665
|
}
|
|
569
666
|
|
|
570
667
|
/**
|
|
@@ -573,12 +670,12 @@ export class WSAPI {
|
|
|
573
670
|
* **Visitor mode: not supported**
|
|
574
671
|
*/
|
|
575
672
|
public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
|
|
576
|
-
const r = await this.api.markUnmarkInboxMessageAsFavorite(null, messageGuid, mark)
|
|
673
|
+
const r = await this.api.markUnmarkInboxMessageAsFavorite(null, messageGuid, mark);
|
|
577
674
|
|
|
578
675
|
return {
|
|
579
676
|
err_code: r.errCode,
|
|
580
677
|
err_message: r.errMsg,
|
|
581
|
-
}
|
|
678
|
+
};
|
|
582
679
|
}
|
|
583
680
|
|
|
584
681
|
/**
|
|
@@ -588,12 +685,12 @@ export class WSAPI {
|
|
|
588
685
|
*/
|
|
589
686
|
|
|
590
687
|
public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
591
|
-
const r = await this.api.deleteInboxMessage(null, messageGuid)
|
|
688
|
+
const r = await this.api.deleteInboxMessage(null, messageGuid);
|
|
592
689
|
|
|
593
690
|
return {
|
|
594
691
|
err_code: r.errCode,
|
|
595
692
|
err_message: r.errMsg,
|
|
596
|
-
}
|
|
693
|
+
};
|
|
597
694
|
}
|
|
598
695
|
|
|
599
696
|
/**
|
|
@@ -603,77 +700,92 @@ export class WSAPI {
|
|
|
603
700
|
*/
|
|
604
701
|
|
|
605
702
|
public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
|
|
606
|
-
const r = await this.api.deleteAllInboxMessages(null)
|
|
703
|
+
const r = await this.api.deleteAllInboxMessages(null);
|
|
607
704
|
|
|
608
705
|
return {
|
|
609
706
|
err_code: r.errCode,
|
|
610
707
|
err_message: r.errMsg,
|
|
611
|
-
}
|
|
708
|
+
};
|
|
612
709
|
}
|
|
613
710
|
|
|
614
711
|
/**
|
|
615
712
|
* Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
|
|
616
713
|
*/
|
|
617
714
|
public async getTranslations(lang_code: string): Promise<TGetTranslations> {
|
|
618
|
-
const r = await this.api.getTranslationsT(null, lang_code, [])
|
|
715
|
+
const r = await this.api.getTranslationsT(null, lang_code, []);
|
|
619
716
|
|
|
620
717
|
return {
|
|
621
718
|
translations: r.translations,
|
|
622
|
-
}
|
|
719
|
+
};
|
|
623
720
|
}
|
|
624
721
|
|
|
625
722
|
private async updateOnSpin(data: SAWSpinsCountPush) {
|
|
626
|
-
const templates: TMiniGameTemplate[] = await OCache.use(
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
723
|
+
const templates: TMiniGameTemplate[] = await OCache.use(
|
|
724
|
+
onUpdateContextKey.Saw,
|
|
725
|
+
ECacheContext.WSAPI,
|
|
726
|
+
() => this.api.sawGetTemplatesT(null),
|
|
727
|
+
CACHE_DATA_SEC,
|
|
728
|
+
);
|
|
729
|
+
const index = templates.findIndex((t) => t.id === data.saw_template_id);
|
|
730
|
+
templates[index].spin_count = data.spin_count;
|
|
731
|
+
this.updateEntity(onUpdateContextKey.Saw, templates);
|
|
630
732
|
}
|
|
631
733
|
|
|
632
734
|
private async updateOnAddSpin() {
|
|
633
|
-
const payload = await this.api.sawGetTemplatesT(null)
|
|
634
|
-
this.updateEntity(onUpdateContextKey.Saw, payload)
|
|
735
|
+
const payload = await this.api.sawGetTemplatesT(null);
|
|
736
|
+
this.updateEntity(onUpdateContextKey.Saw, payload);
|
|
635
737
|
}
|
|
636
738
|
|
|
637
739
|
private async updateOnPrizeWin(data: SAWDoSpinResponse) {
|
|
638
740
|
if (data.errCode === SAWSpinErrorCode.SAW_OK) {
|
|
639
|
-
const templates: TMiniGameTemplate[] = await OCache.use(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
741
|
+
const templates: TMiniGameTemplate[] = await OCache.use(
|
|
742
|
+
onUpdateContextKey.Saw,
|
|
743
|
+
ECacheContext.WSAPI,
|
|
744
|
+
() => this.api.sawGetTemplatesT(null),
|
|
745
|
+
CACHE_DATA_SEC,
|
|
746
|
+
);
|
|
747
|
+
const template: TMiniGameTemplate = templates.find((t) => t.prizes.find((p) => p.id === data.saw_prize_id));
|
|
748
|
+
const prizeType = template.prizes.find((p) => p.id === data.saw_prize_id)?.prize_type;
|
|
749
|
+
|
|
750
|
+
if (
|
|
751
|
+
template.jackpot_add_on_attempt ||
|
|
752
|
+
template.spin_count === 1 ||
|
|
753
|
+
prizeType === MiniGamePrizeTypeName.JACKPOT ||
|
|
754
|
+
prizeType === MiniGamePrizeTypeName.SPIN
|
|
755
|
+
) {
|
|
756
|
+
const updatedTemplates = await this.api.sawGetTemplatesT(null);
|
|
757
|
+
this.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
646
758
|
}
|
|
647
759
|
}
|
|
648
760
|
}
|
|
649
761
|
|
|
650
762
|
private async updateMissionsOnOptIn() {
|
|
651
|
-
const payload = await this.api.missionsGetItemsT(null)
|
|
652
|
-
this.updateEntity(onUpdateContextKey.Missions, payload)
|
|
763
|
+
const payload = await this.api.missionsGetItemsT(null);
|
|
764
|
+
this.updateEntity(onUpdateContextKey.Missions, payload);
|
|
653
765
|
}
|
|
654
766
|
|
|
655
767
|
private async updateTournamentsOnRegistration() {
|
|
656
|
-
const payload = await this.api.tournamentsGetLobbyT(null)
|
|
657
|
-
this.updateEntity(onUpdateContextKey.TournamentList, payload)
|
|
768
|
+
const payload = await this.api.tournamentsGetLobbyT(null);
|
|
769
|
+
this.updateEntity(onUpdateContextKey.TournamentList, payload);
|
|
658
770
|
}
|
|
659
771
|
|
|
660
772
|
private async updateInboxMessages() {
|
|
661
|
-
const payload = await this.api.getInboxMessagesT(null)
|
|
662
|
-
this.updateEntity(onUpdateContextKey.InboxMessages, payload)
|
|
773
|
+
const payload = await this.api.getInboxMessagesT(null);
|
|
774
|
+
this.updateEntity(onUpdateContextKey.InboxMessages, payload);
|
|
663
775
|
}
|
|
664
776
|
|
|
665
777
|
private async updateEntity(contextKey: onUpdateContextKey, payload: any) {
|
|
666
|
-
OCache.set(contextKey, payload, ECacheContext.WSAPI)
|
|
778
|
+
OCache.set(contextKey, payload, ECacheContext.WSAPI);
|
|
667
779
|
|
|
668
|
-
const onUpdate = this.onUpdateCallback.get(contextKey)
|
|
780
|
+
const onUpdate = this.onUpdateCallback.get(contextKey);
|
|
669
781
|
if (onUpdate) {
|
|
670
|
-
onUpdate(payload)
|
|
782
|
+
onUpdate(payload);
|
|
671
783
|
}
|
|
672
784
|
}
|
|
673
785
|
|
|
674
786
|
private async jackpotClearCache() {
|
|
675
|
-
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots)
|
|
676
|
-
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots)
|
|
787
|
+
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots);
|
|
788
|
+
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots);
|
|
677
789
|
}
|
|
678
790
|
|
|
679
791
|
/** Returns list of Jackpots that are active in the systen and matching to the filter definition.
|
|
@@ -696,48 +808,48 @@ export class WSAPI {
|
|
|
696
808
|
* ```
|
|
697
809
|
*/
|
|
698
810
|
public async jackpotGet(filter?: { related_game_id?: string; jp_template_id?: number }): Promise<JackpotDetails[]> {
|
|
699
|
-
const signature: string = `${filter?.jp_template_id}:${filter?.related_game_id}
|
|
811
|
+
const signature: string = `${filter?.jp_template_id}:${filter?.related_game_id}`;
|
|
700
812
|
|
|
701
813
|
if (signature !== this.jackpotGetSignature) {
|
|
702
|
-
this.jackpotGetSignature = signature
|
|
703
|
-
this.jackpotClearCache()
|
|
814
|
+
this.jackpotGetSignature = signature;
|
|
815
|
+
this.jackpotClearCache();
|
|
704
816
|
}
|
|
705
817
|
|
|
706
|
-
let jackpots: JackpotDetails[] = []
|
|
707
|
-
let pots: JackpotPot[] = []
|
|
818
|
+
let jackpots: JackpotDetails[] = [];
|
|
819
|
+
let pots: JackpotPot[] = [];
|
|
708
820
|
|
|
709
821
|
jackpots = await OCache.use<JackpotDetails[]>(
|
|
710
822
|
onUpdateContextKey.Jackpots,
|
|
711
823
|
ECacheContext.WSAPI,
|
|
712
824
|
async () => {
|
|
713
|
-
const _jackpots = await this.api.jackpotGet(null, filter)
|
|
714
|
-
const _pots = _jackpots.items.map((jp) => jp.pot)
|
|
825
|
+
const _jackpots = await this.api.jackpotGet(null, filter);
|
|
826
|
+
const _pots = _jackpots.items.map((jp) => jp.pot);
|
|
715
827
|
|
|
716
|
-
OCache.set(onUpdateContextKey.Pots, _pots, ECacheContext.WSAPI, JACKPOT_POT_CACHE_SEC)
|
|
717
|
-
return _jackpots.items
|
|
828
|
+
OCache.set(onUpdateContextKey.Pots, _pots, ECacheContext.WSAPI, JACKPOT_POT_CACHE_SEC);
|
|
829
|
+
return _jackpots.items;
|
|
718
830
|
},
|
|
719
831
|
JACKPOT_TEMPLATE_CACHE_SEC,
|
|
720
|
-
)
|
|
832
|
+
);
|
|
721
833
|
|
|
722
834
|
if (jackpots.length > 0) {
|
|
723
835
|
pots = await OCache.use<JackpotPot[]>(
|
|
724
836
|
onUpdateContextKey.Pots,
|
|
725
837
|
ECacheContext.WSAPI,
|
|
726
838
|
async () => {
|
|
727
|
-
const jp_template_ids = jackpots.map((jp) => jp.jp_template_id)
|
|
728
|
-
return (await this.api.potGet(null, { jp_template_ids })).items
|
|
839
|
+
const jp_template_ids = jackpots.map((jp) => jp.jp_template_id);
|
|
840
|
+
return (await this.api.potGet(null, { jp_template_ids })).items;
|
|
729
841
|
},
|
|
730
842
|
JACKPOT_POT_CACHE_SEC,
|
|
731
|
-
)
|
|
843
|
+
);
|
|
732
844
|
}
|
|
733
845
|
|
|
734
846
|
return jackpots.map((jp) => {
|
|
735
847
|
let _jp: JackpotDetails = {
|
|
736
848
|
...jp,
|
|
737
849
|
pot: pots.find((p) => p.jp_template_id === jp.jp_template_id),
|
|
738
|
-
}
|
|
739
|
-
return _jp
|
|
740
|
-
})
|
|
850
|
+
};
|
|
851
|
+
return _jp;
|
|
852
|
+
});
|
|
741
853
|
}
|
|
742
854
|
|
|
743
855
|
/**
|
|
@@ -756,12 +868,12 @@ export class WSAPI {
|
|
|
756
868
|
*/
|
|
757
869
|
public async jackpotOptIn(filter: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
|
|
758
870
|
if (!filter.jp_template_id) {
|
|
759
|
-
throw new Error('jp_template_id is required in jackpotOptIn')
|
|
871
|
+
throw new Error('jp_template_id is required in jackpotOptIn');
|
|
760
872
|
}
|
|
761
873
|
|
|
762
|
-
const result = await this.api.jackpotOptIn(null, filter)
|
|
874
|
+
const result = await this.api.jackpotOptIn(null, filter);
|
|
763
875
|
|
|
764
|
-
return result
|
|
876
|
+
return result;
|
|
765
877
|
}
|
|
766
878
|
|
|
767
879
|
/**
|
|
@@ -780,11 +892,11 @@ export class WSAPI {
|
|
|
780
892
|
*/
|
|
781
893
|
public async jackpotOptOut(filter: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
|
|
782
894
|
if (!filter.jp_template_id) {
|
|
783
|
-
throw new Error('jp_template_id is required in jackpotOptOut')
|
|
895
|
+
throw new Error('jp_template_id is required in jackpotOptOut');
|
|
784
896
|
}
|
|
785
897
|
|
|
786
|
-
const result = await this.api.jackpotOptOut(null, filter)
|
|
898
|
+
const result = await this.api.jackpotOptOut(null, filter);
|
|
787
899
|
|
|
788
|
-
return result
|
|
900
|
+
return result;
|
|
789
901
|
}
|
|
790
902
|
}
|