@smartico/public-api 0.0.140 → 0.0.142
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/dist/OCache.d.ts +1 -0
- package/dist/Quiz/MarketsInfo.d.ts +8 -0
- package/dist/Quiz/MarketsType.d.ts +3 -1
- package/dist/SmarticoAPI.d.ts +13 -13
- package/dist/WSAPI/WSAPI.d.ts +249 -48
- package/dist/index.js +381 -129
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +314 -106
- package/dist/index.modern.mjs.map +1 -1
- package/docs/classes/WSAPI.md +205 -27
- package/package.json +1 -1
- package/src/Level/GetLevelMapResponse.ts +1 -1
- package/src/OCache.ts +5 -0
- package/src/Quiz/MarketsInfo.ts +17 -16
- package/src/Quiz/MarketsType.ts +4 -1
- package/src/SmarticoAPI.ts +30 -32
- package/src/WSAPI/WSAPI.ts +270 -63
package/src/SmarticoAPI.ts
CHANGED
|
@@ -111,13 +111,16 @@ class SmarticoAPI {
|
|
|
111
111
|
return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
private async send<T>(message: any, expectCID?: ClassId): Promise<T> {
|
|
114
|
+
private async send<T>(message: any, expectCID?: ClassId, force_language?: string): Promise<T> {
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
if (this.logCIDs.includes(message.cid)) {
|
|
118
118
|
this.logger.info('REQ', message)
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
if (force_language) {
|
|
122
|
+
message.force_language = force_language;
|
|
123
|
+
}
|
|
121
124
|
|
|
122
125
|
let result: any;
|
|
123
126
|
|
|
@@ -287,18 +290,15 @@ class SmarticoAPI {
|
|
|
287
290
|
return results.segments || [];
|
|
288
291
|
}
|
|
289
292
|
|
|
290
|
-
public async jackpotGet(user_ext_id: string, filter?: { related_game_id?: string, jp_template_id?: number }): Promise<
|
|
291
|
-
const message = this.buildMessage<GetJackpotsRequest, GetJackpotsResponse>(user_ext_id, ClassId.JP_GET_JACKPOTS_REQUEST, filter);
|
|
292
|
-
const response = await this.send<GetJackpotsResponse>(message, ClassId.JP_GET_JACKPOTS_RESPONSE);
|
|
293
|
+
public async jackpotGet(user_ext_id: string, filter?: { related_game_id?: string, jp_template_id?: number }, force_language?: string ): Promise<GetJackpotsResponse> {
|
|
293
294
|
|
|
294
|
-
|
|
295
|
+
const message = this.buildMessage<GetJackpotsRequest, GetJackpotsResponse>(user_ext_id, ClassId.JP_GET_JACKPOTS_REQUEST, filter);
|
|
296
|
+
return await this.send<GetJackpotsResponse>(message, ClassId.JP_GET_JACKPOTS_RESPONSE, force_language);
|
|
295
297
|
}
|
|
296
298
|
|
|
297
|
-
public async potGet(user_ext_id: string, filter: { jp_template_ids: number[] }): Promise<
|
|
299
|
+
public async potGet(user_ext_id: string, filter: { jp_template_ids: number[] }): Promise<GetJackpotsPotsResponse> {
|
|
298
300
|
const message = this.buildMessage<GetJackpotsPotsRequest, GetJackpotsPotsResponse>(user_ext_id, ClassId.JP_GET_LATEST_POTS_REQUEST, filter);
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return response?.items || [];
|
|
301
|
+
return await this.send<GetJackpotsPotsResponse>(message, ClassId.JP_GET_LATEST_POTS_RESPONSE);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
public async jackpotOptIn(user_ext_id: string, payload: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
|
|
@@ -311,11 +311,11 @@ class SmarticoAPI {
|
|
|
311
311
|
return await this.send<JackpotsOptoutResponse>(message, ClassId.JP_OPTOUT_RESPONSE);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
public async sawGetTemplates(user_ext_id: string,
|
|
314
|
+
public async sawGetTemplates(user_ext_id: string, force_language?: string, is_visitor_mode: boolean = false): Promise<SAWGetTemplatesResponse> {
|
|
315
315
|
|
|
316
|
-
const message = this.buildMessage<SAWGetTemplatesRequest, SAWGetTemplatesResponse>(user_ext_id, ClassId.SAW_GET_SPINS_REQUEST,
|
|
316
|
+
const message = this.buildMessage<SAWGetTemplatesRequest, SAWGetTemplatesResponse>(user_ext_id, ClassId.SAW_GET_SPINS_REQUEST, { is_visitor_mode });
|
|
317
317
|
|
|
318
|
-
const response = await this.send<SAWGetTemplatesResponse>(message, ClassId.SAW_GET_SPINS_RESPONSE);
|
|
318
|
+
const response = await this.send<SAWGetTemplatesResponse>(message, ClassId.SAW_GET_SPINS_RESPONSE, force_language);
|
|
319
319
|
|
|
320
320
|
if (response && response.templates) {
|
|
321
321
|
response.templates.forEach(t => {
|
|
@@ -447,20 +447,18 @@ class SmarticoAPI {
|
|
|
447
447
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
public async storeGetItems(user_ext_id: string): Promise<GetStoreItemsResponse> {
|
|
451
|
-
|
|
450
|
+
public async storeGetItems(user_ext_id: string, force_language?: string): Promise<GetStoreItemsResponse> {
|
|
452
451
|
const message = this.buildMessage<any, GetStoreItemsResponse>(user_ext_id, ClassId.GET_SHOP_ITEMS_REQUEST);
|
|
453
|
-
return await this.send<GetStoreItemsResponse>(message, ClassId.GET_SHOP_ITEMS_RESPONSE);
|
|
452
|
+
return await this.send<GetStoreItemsResponse>(message, ClassId.GET_SHOP_ITEMS_RESPONSE, force_language);
|
|
454
453
|
}
|
|
455
454
|
|
|
456
455
|
public async storeGetItemsT(user_ext_id: string): Promise<TStoreItem[]> {
|
|
457
456
|
return StoreItemTransform((await this.storeGetItems(user_ext_id)).items);
|
|
458
457
|
}
|
|
459
458
|
|
|
460
|
-
public async storeGetCategories(user_ext_id: string): Promise<GetCategoriesStoreResponse> {
|
|
461
|
-
|
|
459
|
+
public async storeGetCategories(user_ext_id: string, force_language?: string): Promise<GetCategoriesStoreResponse> {
|
|
462
460
|
const message = this.buildMessage<any, GetCategoriesStoreResponse>(user_ext_id, ClassId.GET_SHOP_CATEGORIES_REQUEST);
|
|
463
|
-
return await this.send<GetCategoriesStoreResponse>(message, ClassId.GET_SHOP_CATEGORIES_RESPONSE);
|
|
461
|
+
return await this.send<GetCategoriesStoreResponse>(message, ClassId.GET_SHOP_CATEGORIES_RESPONSE, force_language);
|
|
464
462
|
}
|
|
465
463
|
|
|
466
464
|
public async storeGetCategoriesT(user_ext_id: string): Promise<TStoreCategory[]> {
|
|
@@ -481,10 +479,10 @@ class SmarticoAPI {
|
|
|
481
479
|
return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items);
|
|
482
480
|
}
|
|
483
481
|
|
|
484
|
-
public async missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse> {
|
|
482
|
+
public async missionsGetItems(user_ext_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
|
|
485
483
|
|
|
486
484
|
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(user_ext_id, ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
487
|
-
const response = await this.send<GetAchievementMapResponse>(message, ClassId.GET_ACHIEVEMENT_MAP_RESPONSE);
|
|
485
|
+
const response = await this.send<GetAchievementMapResponse>(message, ClassId.GET_ACHIEVEMENT_MAP_RESPONSE, force_language);
|
|
488
486
|
// we need to clone response to avoid changing original object,for cases when its called together with badgesGetItems (e.g. in Promise.all)
|
|
489
487
|
const responseClone = { ...response };
|
|
490
488
|
|
|
@@ -513,20 +511,20 @@ class SmarticoAPI {
|
|
|
513
511
|
}
|
|
514
512
|
}
|
|
515
513
|
|
|
516
|
-
public async achGetCategories(user_ext_id: string): Promise<GetAchCategoriesResponse> {
|
|
514
|
+
public async achGetCategories(user_ext_id: string, force_language?: string): Promise<GetAchCategoriesResponse> {
|
|
517
515
|
|
|
518
516
|
const message = this.buildMessage<any, GetAchCategoriesResponse>(user_ext_id, ClassId.GET_ACH_CATEGORIES_REQUEST);
|
|
519
|
-
return await this.send<GetAchCategoriesResponse>(message, ClassId.GET_ACH_CATEGORIES_RESPONSE);
|
|
517
|
+
return await this.send<GetAchCategoriesResponse>(message, ClassId.GET_ACH_CATEGORIES_RESPONSE, force_language);
|
|
520
518
|
}
|
|
521
519
|
|
|
522
520
|
public async achGetCategoriesT(user_ext_id: string): Promise<TAchCategory[]> {
|
|
523
521
|
return AchCategoryTransform((await this.achGetCategories(user_ext_id)).categories);
|
|
524
522
|
}
|
|
525
523
|
|
|
526
|
-
public async badgetsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse> {
|
|
524
|
+
public async badgetsGetItems(user_ext_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
|
|
527
525
|
|
|
528
526
|
const message = this.buildMessage<GetAchievementMapRequest, GetAchievementMapResponse>(user_ext_id, ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
529
|
-
const response = await this.send<GetAchievementMapResponse>(message, ClassId.GET_ACHIEVEMENT_MAP_RESPONSE);
|
|
527
|
+
const response = await this.send<GetAchievementMapResponse>(message, ClassId.GET_ACHIEVEMENT_MAP_RESPONSE, force_language);
|
|
530
528
|
// we need to clone response to avoid changing original object,for cases when its called together with missionsGetItems (e.g. in Promise.all)
|
|
531
529
|
const responseClone = { ...response };
|
|
532
530
|
|
|
@@ -541,10 +539,10 @@ class SmarticoAPI {
|
|
|
541
539
|
}
|
|
542
540
|
|
|
543
541
|
|
|
544
|
-
public async tournamentsGetLobby(user_ext_id: string): Promise<GetTournamentsResponse> {
|
|
542
|
+
public async tournamentsGetLobby(user_ext_id: string, force_language?: string): Promise<GetTournamentsResponse> {
|
|
545
543
|
|
|
546
544
|
const message = this.buildMessage<GetTournamentsRequest, GetTournamentsResponse>(user_ext_id, ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
|
|
547
|
-
return await this.send<GetTournamentsResponse>(message, ClassId.GET_TOURNAMENT_LOBBY_RESPONSE);
|
|
545
|
+
return await this.send<GetTournamentsResponse>(message, ClassId.GET_TOURNAMENT_LOBBY_RESPONSE, force_language);
|
|
548
546
|
|
|
549
547
|
}
|
|
550
548
|
|
|
@@ -552,14 +550,14 @@ class SmarticoAPI {
|
|
|
552
550
|
return TournamentItemsTransform((await this.tournamentsGetLobby(user_ext_id)).tournaments);
|
|
553
551
|
}
|
|
554
552
|
|
|
555
|
-
public async tournamentsGetInfo(user_ext_id: string, tournamentInstanceId: number): Promise<GetTournamentInfoResponse> {
|
|
553
|
+
public async tournamentsGetInfo(user_ext_id: string, tournamentInstanceId: number, force_language?: string): Promise<GetTournamentInfoResponse> {
|
|
556
554
|
|
|
557
555
|
const message = this.buildMessage<GetTournamentInfoRequest, GetTournamentInfoResponse>(user_ext_id, ClassId.GET_TOURNAMENT_INFO_REQUEST,
|
|
558
556
|
{
|
|
559
557
|
tournamentInstanceId
|
|
560
558
|
}
|
|
561
559
|
);
|
|
562
|
-
const response = await this.send<GetTournamentInfoResponse>(message, ClassId.GET_TOURNAMENT_INFO_RESPONSE);
|
|
560
|
+
const response = await this.send<GetTournamentInfoResponse>(message, ClassId.GET_TOURNAMENT_INFO_RESPONSE, force_language);
|
|
563
561
|
|
|
564
562
|
if (response.userPosition?.avatar_id) {
|
|
565
563
|
response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, this.avatarDomain);
|
|
@@ -583,7 +581,7 @@ class SmarticoAPI {
|
|
|
583
581
|
return tournamentInfoItemTransform(response);
|
|
584
582
|
}
|
|
585
583
|
|
|
586
|
-
public async leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod: boolean = false): Promise<LeaderBoardDetails> {
|
|
584
|
+
public async leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod: boolean = false, force_language?: string): Promise<LeaderBoardDetails> {
|
|
587
585
|
|
|
588
586
|
const message = this.buildMessage<GetLeaderBoardsRequest, GetLeaderBoardsResponse>(user_ext_id, ClassId.GET_LEADERS_BOARD_REQUEST,
|
|
589
587
|
{
|
|
@@ -593,7 +591,7 @@ class SmarticoAPI {
|
|
|
593
591
|
}
|
|
594
592
|
);
|
|
595
593
|
|
|
596
|
-
const response = await this.send<GetLeaderBoardsResponse>(message, ClassId.GET_LEADERS_BOARD_RESPONSE);
|
|
594
|
+
const response = await this.send<GetLeaderBoardsResponse>(message, ClassId.GET_LEADERS_BOARD_RESPONSE, force_language);
|
|
597
595
|
|
|
598
596
|
const boardKey = Object.keys(response.map).find( k => period_type_id === undefined || k === period_type_id?.toString());
|
|
599
597
|
|
|
@@ -620,9 +618,9 @@ class SmarticoAPI {
|
|
|
620
618
|
return getLeaderBoardTransform(await this.leaderboardGet(user_ext_id, period_type_id, prevPeriod));
|
|
621
619
|
}
|
|
622
620
|
|
|
623
|
-
public async levelsGet(user_ext_id: string): Promise<GetLevelMapResponse> {
|
|
621
|
+
public async levelsGet(user_ext_id: string, force_language?: string): Promise<GetLevelMapResponse> {
|
|
624
622
|
const message = this.buildMessage<any, GetLevelMapResponse>(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST);
|
|
625
|
-
return await this.send<GetLevelMapResponse>(message, ClassId.GET_LEVEL_MAP_RESPONSE);
|
|
623
|
+
return await this.send<GetLevelMapResponse>(message, ClassId.GET_LEVEL_MAP_RESPONSE, force_language);
|
|
626
624
|
}
|
|
627
625
|
|
|
628
626
|
public async levelsGetT(user_ext_id: string): Promise<TLevel[]> {
|