@smartico/public-api 0.0.379 → 0.0.380

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +31 -2
  3. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  4. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  5. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  6. package/dist/WSAPI/WSAPIAvatars.d.ts +78 -0
  7. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  8. package/dist/WSAPI/WSAPIBonuses.d.ts +26 -0
  9. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  10. package/dist/WSAPI/WSAPIGamePick.d.ts +308 -0
  11. package/dist/WSAPI/WSAPIGeneral.d.ts +30 -0
  12. package/dist/WSAPI/WSAPIInbox.d.ts +126 -0
  13. package/dist/WSAPI/WSAPIJackpots.d.ts +109 -0
  14. package/dist/WSAPI/WSAPILeaderBoard.d.ts +25 -0
  15. package/dist/WSAPI/WSAPIMiniGames.d.ts +94 -0
  16. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  17. package/dist/WSAPI/WSAPIRaffles.d.ts +119 -0
  18. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  19. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  20. package/dist/WSAPI/WSAPITypes.d.ts +145 -85
  21. package/dist/WSAPI/WSAPIUser.d.ts +383 -0
  22. package/dist/index.js +3818 -1528
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.modern.mjs +3180 -981
  25. package/dist/index.modern.mjs.map +1 -1
  26. package/docs/api/README.md +56 -2
  27. package/docs/api/classes/WSAPIAvatars.md +116 -0
  28. package/docs/api/classes/WSAPIBonuses.md +50 -0
  29. package/docs/api/classes/WSAPIClans.md +66 -0
  30. package/docs/api/classes/WSAPIGamePick.md +181 -0
  31. package/docs/api/classes/WSAPIGeneral.md +63 -0
  32. package/docs/api/classes/WSAPIInbox.md +277 -0
  33. package/docs/api/classes/WSAPIJackpots.md +185 -0
  34. package/docs/api/classes/WSAPILeaderBoard.md +39 -0
  35. package/docs/api/classes/WSAPIMiniGames.md +175 -0
  36. package/docs/api/classes/WSAPIMissions.md +611 -0
  37. package/docs/api/classes/WSAPIRaffles.md +195 -0
  38. package/docs/api/classes/WSAPIStore.md +744 -0
  39. package/docs/api/classes/WSAPITournaments.md +104 -0
  40. package/docs/api/classes/WSAPIUser.md +200 -0
  41. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  42. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  43. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  44. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  45. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  46. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  47. package/docs/api/interfaces/TAchCategory.md +19 -4
  48. package/docs/api/interfaces/TBuyStoreItemResult.md +26 -8
  49. package/docs/api/interfaces/TMissionClaimRewardResult.md +14 -3
  50. package/docs/api/interfaces/TMissionOptInResult.md +10 -3
  51. package/docs/api/interfaces/TMissionOrBadge.md +6 -2
  52. package/docs/api/interfaces/TStoreItem.md +21 -1
  53. package/docs/api/interfaces/TTournamentDetailed.md +8 -0
  54. package/docs/api/interfaces/UserAchievement.md +1 -1
  55. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  56. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  57. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  58. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  59. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  60. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  61. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  62. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  63. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  64. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  65. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  66. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  67. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  68. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  69. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  70. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  71. package/docs/ui/user/UIGuide_getLevels.md +162 -0
  72. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  73. package/package.json +3 -3
  74. package/scripts/postdoc-cleanup.js +195 -0
  75. package/src/Missions/MissionsUtils.ts +5 -2
  76. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  77. package/src/Store/StoreItem.ts +1 -0
  78. package/src/Store/StoreItemPurchased.ts +1 -0
  79. package/src/Store/StoreItemType.ts +1 -1
  80. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  81. package/src/WSAPI/WSAPI.ts +27 -2007
  82. package/src/WSAPI/WSAPIAvatars.ts +127 -0
  83. package/src/WSAPI/WSAPIBase.ts +93 -0
  84. package/src/WSAPI/WSAPIBonuses.ts +54 -0
  85. package/src/WSAPI/WSAPIClans.ts +417 -0
  86. package/src/WSAPI/WSAPIGamePick.ts +382 -0
  87. package/src/WSAPI/WSAPIGeneral.ts +57 -0
  88. package/src/WSAPI/WSAPIInbox.ts +222 -0
  89. package/src/WSAPI/WSAPIJackpots.ts +212 -0
  90. package/src/WSAPI/WSAPILeaderBoard.ts +40 -0
  91. package/src/WSAPI/WSAPIMiniGames.ts +181 -0
  92. package/src/WSAPI/WSAPIMissions.ts +572 -0
  93. package/src/WSAPI/WSAPIRaffles.ts +175 -0
  94. package/src/WSAPI/WSAPIStore.ts +732 -0
  95. package/src/WSAPI/WSAPITournaments.ts +541 -0
  96. package/src/WSAPI/WSAPITypes.ts +145 -87
  97. package/src/WSAPI/WSAPIUser.ts +456 -0
  98. package/tsconfig.json +17 -1
  99. package/docs/api/classes/WSAPI.md +0 -1927
@@ -0,0 +1,212 @@
1
+ import { ECacheContext, OCache } from '../OCache';
2
+ import {
3
+ JackpotDetails,
4
+ JackpotPot,
5
+ JackpotWinnerHistory,
6
+ JackpotsOptinResponse,
7
+ JackpotsOptoutResponse,
8
+ } from '../Jackpots';
9
+ import { IntUtils } from '../IntUtils';
10
+ import { TGetJackpotEligibleGamesResponse } from '../Jackpots/GetJackpotEligibleGamesResponse';
11
+ import {
12
+ JACKPOT_TEMPLATE_CACHE_SEC,
13
+ JACKPOT_POT_CACHE_SEC,
14
+ JACKPOT_WINNERS_CACHE_SEC,
15
+ JACKPOT_ELIGIBLE_GAMES_CACHE_SEC,
16
+ onUpdateContextKey,
17
+ } from './WSAPIBase';
18
+ import { WSAPIClans } from './WSAPIClans';
19
+
20
+ /** @group Jackpots */
21
+ export class WSAPIJackpots extends WSAPIClans {
22
+
23
+ /** @hidden */
24
+ protected jackpotGetSignature: string = '';
25
+ protected async jackpotClearCache() {
26
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots);
27
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots);
28
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.JackpotWinners);
29
+ }
30
+
31
+ /** Returns list of Jackpots that are active in the system and matching to the filter definition.
32
+ * If filter is not provided, all active jackpots will be returned.
33
+ * Filter can be used to get jackpots related to specific game or specific jackpot template.
34
+ * You can call this method every second in order to get up to date information about current value of the jackpot(s) and present them to the end-users
35
+ *
36
+ * **Example**:
37
+ * ```
38
+ * _smartico.api.jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
39
+ * console.log(result);
40
+ * });
41
+ * ```
42
+ *
43
+ * **Example in the Visitor mode**:
44
+ * ```
45
+ * _smartico.vapi('EN').jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
46
+ * console.log(result);
47
+ * });
48
+ * ```
49
+ */
50
+ public async jackpotGet(filter?: { related_game_id?: string; jp_template_id?: number }): Promise<JackpotDetails[]> {
51
+ const signature: string = `${filter?.jp_template_id}:${filter?.related_game_id}`;
52
+
53
+ if (signature !== this.jackpotGetSignature) {
54
+ this.jackpotGetSignature = signature;
55
+ this.jackpotClearCache();
56
+ }
57
+
58
+ let jackpots: JackpotDetails[] = [];
59
+ let pots: JackpotPot[] = [];
60
+
61
+ jackpots = await OCache.use<JackpotDetails[]>(
62
+ onUpdateContextKey.Jackpots,
63
+ ECacheContext.WSAPI,
64
+ async () => {
65
+ const _jackpots = await this.api.jackpotGet(this.userExtId, filter);
66
+ const _pots = _jackpots.items.map((jp) => jp.pot);
67
+
68
+ _jackpots.items.forEach((jp) => {
69
+ jp.jp_public_meta.custom_data = IntUtils.JsonOrText(jp.jp_public_meta.custom_data);
70
+ });
71
+
72
+ OCache.set(onUpdateContextKey.Pots, _pots, ECacheContext.WSAPI, JACKPOT_POT_CACHE_SEC);
73
+ return _jackpots.items;
74
+ },
75
+ JACKPOT_TEMPLATE_CACHE_SEC,
76
+ );
77
+
78
+ if (jackpots.length > 0) {
79
+ pots = await OCache.use<JackpotPot[]>(
80
+ onUpdateContextKey.Pots,
81
+ ECacheContext.WSAPI,
82
+ async () => {
83
+ const jp_template_ids = jackpots.map((jp) => jp.jp_template_id);
84
+ return (await this.api.potGet(this.userExtId, { jp_template_ids })).items;
85
+ },
86
+ JACKPOT_POT_CACHE_SEC,
87
+ );
88
+ }
89
+
90
+ return jackpots.map((jp) => {
91
+ let _jp: JackpotDetails = {
92
+ ...jp,
93
+ pot: pots.find((p) => p.jp_template_id === jp.jp_template_id),
94
+ };
95
+ return _jp;
96
+ });
97
+ }
98
+
99
+ /**
100
+ * Opt-in currently logged in user to the jackpot with the specified jp_template_id.
101
+ * You may call jackpotGet method after doing optin to see that user is opted in to the jackpot.
102
+ *
103
+ * **Example**:
104
+ * ```
105
+ * _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
106
+ * console.log('Opted in to the jackpot');
107
+ * });
108
+ * ```
109
+ *
110
+ * **Visitor mode: not supported**
111
+ *
112
+ */
113
+ public async jackpotOptIn(filter: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
114
+ if (!filter.jp_template_id) {
115
+ throw new Error('jp_template_id is required in jackpotOptIn');
116
+ }
117
+
118
+ const result = await this.api.jackpotOptIn(this.userExtId, filter);
119
+
120
+ return result;
121
+ }
122
+
123
+ /**
124
+ * Opt-out currently logged in user from the jackpot with the specified jp_template_id.
125
+ * You may call jackpotGet method after doing optout to see that user is not opted in to the jackpot.
126
+ *
127
+ * **Example**:
128
+ * ```
129
+ * _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
130
+ * console.log('Opted out from the jackpot');
131
+ * });
132
+ * ```
133
+ *
134
+ * **Visitor mode: not supported**
135
+ *
136
+ */
137
+ public async jackpotOptOut(filter: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
138
+ if (!filter.jp_template_id) {
139
+ throw new Error('jp_template_id is required in jackpotOptOut');
140
+ }
141
+
142
+ const result = await this.api.jackpotOptOut(this.userExtId, filter);
143
+
144
+ return result;
145
+ }
146
+
147
+ /**
148
+ * Returns jackpot winners for the given `jp_template_id` (paginated on the server).
149
+ * Default page size on the wire is 20; use `limit`, `offset`, and repeated calls to load more.
150
+ * The full protocol response also includes `has_more`; this method returns only the `winners` array.
151
+ *
152
+ * **Example**:
153
+ * ```
154
+ * _smartico.api.getJackpotWinners({
155
+ * jp_template_id: 123,
156
+ * }).then((result) => {
157
+ * console.log(result);
158
+ * });
159
+ * ```
160
+ *
161
+ * **Visitor mode: not supported**
162
+ *
163
+ * @param params - Jackpot winners parameters
164
+ * @param params.jp_template_id - Jackpot template id (required; throws if missing)
165
+ * @param params.limit - Page size (server default 20 when omitted)
166
+ * @param params.offset - Offset into the winner list
167
+ */
168
+
169
+ public async getJackpotWinners({
170
+ limit,
171
+ offset,
172
+ jp_template_id,
173
+ }: {
174
+ limit?: number;
175
+ offset?: number;
176
+ jp_template_id?: number;
177
+ }): Promise<JackpotWinnerHistory[]> {
178
+ return OCache.use(
179
+ onUpdateContextKey.JackpotWinners + jp_template_id,
180
+ ECacheContext.WSAPI,
181
+ () => this.api.getJackpotWinnersT(this.userExtId, limit, offset, jp_template_id),
182
+ JACKPOT_WINNERS_CACHE_SEC,
183
+ );
184
+ }
185
+
186
+ /**
187
+ * Returns the eligible games for the jackpot with the specified jp_template_id.
188
+ *
189
+ * **Example**:
190
+ * ```
191
+ * _smartico.api.getJackpotEligibleGames({ jp_template_id: 123 }).then((result) => {
192
+ * console.log(result);
193
+ * });
194
+ * ```
195
+ *
196
+ * **Visitor mode: not supported**
197
+ *
198
+ */
199
+
200
+ public async getJackpotEligibleGames({ jp_template_id, onUpdate } : { jp_template_id: number, onUpdate?: () => void }): Promise<TGetJackpotEligibleGamesResponse> {
201
+ if (onUpdate) {
202
+ this.onUpdateCallback.set(onUpdateContextKey.JackpotEligibleGames, onUpdate);
203
+ }
204
+
205
+ return OCache.use(
206
+ onUpdateContextKey.JackpotEligibleGames + jp_template_id,
207
+ ECacheContext.WSAPI,
208
+ () => this.api.getJackpotEligibleGamesT(this.userExtId, { jp_template_id }),
209
+ JACKPOT_ELIGIBLE_GAMES_CACHE_SEC,
210
+ );
211
+ }
212
+ }
@@ -0,0 +1,40 @@
1
+ import { ECacheContext, OCache } from '../OCache';
2
+ import {
3
+ LeaderBoardDetailsT,
4
+ } from './WSAPITypes';
5
+ import { LeaderBoardPeriodType } from '../Leaderboard';
6
+ import {
7
+ CACHE_DATA_SEC,
8
+ onUpdateContextKey,
9
+ } from './WSAPIBase';
10
+ import { WSAPIGamePick } from './WSAPIGamePick';
11
+
12
+ /** @group LeaderBoard */
13
+ export class WSAPILeaderBoard extends WSAPIGamePick {
14
+ /**
15
+ * Returns the leaderboard for the current type (default is Daily). If getPreviousPeriod is passed as true, a leaderboard for the previous period for the current type will be returned.
16
+ * For example, if the type is Weekly and getPreviousPeriod is true, a leaderboard for the previous week will be returned.
17
+ *
18
+ * **Example**:
19
+ * ```
20
+ * _smartico.api.getLeaderBoard(1).then((result) => {
21
+ * console.log(result);
22
+ * });
23
+ * ```
24
+ *
25
+ * **Example in the Visitor mode**:
26
+ * ```
27
+ * _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
28
+ * console.log(result);
29
+ * });
30
+ * ```
31
+ */
32
+ public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {
33
+ return OCache.use(
34
+ onUpdateContextKey.LeaderBoards,
35
+ ECacheContext.WSAPI,
36
+ () => this.api.leaderboardsGetT(this.userExtId, periodType, getPreviousPeriod),
37
+ CACHE_DATA_SEC,
38
+ );
39
+ }
40
+ }
@@ -0,0 +1,181 @@
1
+ import { SAWSpinsCountPush } from '../MiniGames';
2
+ import { ECacheContext, OCache } from '../OCache';
3
+ import {
4
+ TMiniGamePlayResult,
5
+ TMiniGameTemplate,
6
+ TMiniGamePlayBatchResult,
7
+ TSawHistory,
8
+ } from './WSAPITypes';
9
+ import {
10
+ CACHE_DATA_SEC,
11
+ onUpdateContextKey,
12
+ } from './WSAPIBase';
13
+ import { WSAPIRaffles } from './WSAPIRaffles';
14
+
15
+ /** @group MiniGames */
16
+ export class WSAPIMiniGames extends WSAPIRaffles {
17
+ /**
18
+ * Returns the list of mini-games configured for the current user (not filtered by spin availability or Widget visibility).
19
+ * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
20
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or won prize is spin/jackpot and if max count of the available user spins equals one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
21
+ *
22
+ * **Example**:
23
+ * ```
24
+ * _smartico.api.getMiniGames().then((result) => {
25
+ * console.log(result);
26
+ * });
27
+ * ```
28
+ *
29
+ * **Example in the Visitor mode**:
30
+ * ```
31
+ * _smartico.vapi('EN').getMiniGames().then((result) => {
32
+ * console.log(result);
33
+ * });
34
+ * ```
35
+ *
36
+ */
37
+ public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<
38
+ TMiniGameTemplate[]
39
+ > {
40
+ if (onUpdate) {
41
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
42
+ }
43
+
44
+ return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(this.userExtId), CACHE_DATA_SEC);
45
+ }
46
+
47
+ /**
48
+ * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
49
+ * The maximum number of items per request is limited to 20.
50
+ * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
51
+ * The returned list of mini-games history is cached for 30 seconds.
52
+ *
53
+ * **Example**:
54
+ * ```
55
+ * _smartico.api.getMiniGamesHistory().then((result) => {
56
+ * console.log(result);
57
+ * });
58
+ * ```
59
+ *
60
+ * **Visitor mode: not supported**
61
+ */
62
+
63
+ public async getMiniGamesHistory({
64
+ limit,
65
+ offset,
66
+ saw_template_id,
67
+ }: {
68
+ limit?: number;
69
+ offset?: number;
70
+ saw_template_id?: number;
71
+ }): Promise<TSawHistory[]> {
72
+ return OCache.use(
73
+ onUpdateContextKey.SAWHistory,
74
+ ECacheContext.WSAPI,
75
+ () => this.api.getSawWinningHistoryT(this.userExtId, limit, offset, saw_template_id),
76
+ CACHE_DATA_SEC,
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
82
+ * After playMiniGame is called, you can call getMiniGames to get the list of mini-games.The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call playMiniGame with a new onUpdate callback, the old one will be overwritten by the new one.
83
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or won prize is spin/jackpot and if max count of the available user spins equals one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
84
+ *
85
+ * **Example**:
86
+ * ```
87
+ * _smartico.api.playMiniGame(55).then((result) => {
88
+ * console.log(result);
89
+ * });
90
+ * ```
91
+ *
92
+ * **Visitor mode: not supported**
93
+ */
94
+ public async playMiniGame(
95
+ template_id: number,
96
+ { onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {},
97
+ ): Promise<TMiniGamePlayResult> {
98
+ if (onUpdate) {
99
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
100
+ }
101
+
102
+ const r = await this.api.sawSpinRequest(this.userExtId, template_id);
103
+ this.api.doAcknowledgeRequest(this.userExtId, r.request_id);
104
+
105
+ const o: TMiniGamePlayResult = {
106
+ err_code: r.errCode,
107
+ err_message: r.errMsg,
108
+ prize_id: r.saw_prize_id,
109
+ };
110
+
111
+ return o;
112
+ }
113
+
114
+ /**
115
+ * Sends the acknowledge request with specific client_request_id from minigame history in order to claim prize
116
+ * **Example**:
117
+ * ```
118
+ * _smartico.api.miniGameWinAcknowledgeRequest('2a189322-31bb-4119-b943-bx7868ff8dc3').then((result) => {
119
+ * console.log(result);
120
+ * });
121
+ * ```
122
+ */
123
+ public async miniGameWinAcknowledgeRequest(request_id: string) {
124
+ return this.api.doAcknowledgeRequest(this.userExtId, request_id);
125
+ }
126
+
127
+ /**
128
+ * Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
129
+ * After playMiniGameBatch is called, you can call getMiniGames to get the list of mini-games. The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call playMiniGameBatch with a new onUpdate callback, the old one will be overwritten by the new one.
130
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or won prize is spin/jackpot and if max count of the available user spins equals one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
131
+ *
132
+ * **Example**:
133
+ * ```
134
+ * _smartico.api.playMiniGameBatch(55, 10).then((result) => {
135
+ * console.log(result);
136
+ * });
137
+ * ```
138
+ * **Visitor mode: not supported**
139
+ */
140
+ public async playMiniGameBatch(
141
+ template_id: number,
142
+ spin_count: number,
143
+ { onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {},
144
+ ): Promise<TMiniGamePlayBatchResult[]> {
145
+ if (onUpdate) {
146
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
147
+ }
148
+
149
+ const response = await this.api.sawSpinBatchRequest(this.userExtId, template_id, spin_count);
150
+
151
+ const request_ids = response.results.map((result) => result.request_id);
152
+ this.api.doAcknowledgeBatchRequest(this.userExtId, request_ids);
153
+
154
+ const o: TMiniGamePlayBatchResult[] = response.results.map((result) => ({
155
+ errCode: result.errCode,
156
+ errMessage: result.errMsg,
157
+ saw_prize_id: result.saw_prize_id,
158
+ jackpot_amount: result.jackpot_amount,
159
+ first_spin_in_period: result.first_spin_in_period,
160
+ }));
161
+
162
+ return o;
163
+ }
164
+
165
+ protected async updateOnSpin(data: SAWSpinsCountPush) {
166
+ const templates: TMiniGameTemplate[] = await OCache.use(
167
+ onUpdateContextKey.Saw,
168
+ ECacheContext.WSAPI,
169
+ () => this.api.sawGetTemplatesT(this.userExtId),
170
+ CACHE_DATA_SEC,
171
+ );
172
+ const index = templates.findIndex((t) => t.id === data.saw_template_id);
173
+ templates[index].spin_count = data.spin_count;
174
+ this.updateEntity(onUpdateContextKey.Saw, templates);
175
+ }
176
+
177
+ protected async reloadMiniGameTemplate() {
178
+ const updatedTemplates = await this.api.sawGetTemplatesT(this.userExtId);
179
+ this.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
180
+ }
181
+ }