@smartico/public-api 0.0.352 → 0.0.353
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/GamePick/GPTypes.d.ts +3 -0
- package/dist/SmarticoAPI.d.ts +16 -11
- package/dist/WSAPI/WSAPI.d.ts +212 -90
- package/dist/index.d.ts +1 -0
- package/dist/index.js +772 -616
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +405 -221
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/README.md +3 -0
- package/docs/api/classes/WSAPI.md +199 -0
- package/docs/api/enums/QuizAnswersValueType.md +121 -0
- package/docs/api/enums/RaffleTicketCapVisualization.md +5 -1
- package/docs/api/enums/SAWGPMarketType.md +157 -0
- package/docs/api/interfaces/RafflePublicMeta.md +3 -2
- package/docs/api/interfaces/TRaffle.md +8 -0
- package/package.json +4 -2
- package/src/GamePick/GPTypes.ts +4 -0
- package/src/SmarticoAPI.ts +98 -62
- package/src/WSAPI/WSAPI.ts +294 -156
- package/src/index.ts +1 -0
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
GamePickUserInfo,
|
|
48
48
|
GamePickGameInfo,
|
|
49
49
|
GamePickRequestParams,
|
|
50
|
+
GamePickRoundRequestParams,
|
|
50
51
|
} from '../GamePick';
|
|
51
52
|
import { LeaderBoardPeriodType } from '../Leaderboard';
|
|
52
53
|
import {
|
|
@@ -110,9 +111,11 @@ enum onUpdateContextKey {
|
|
|
110
111
|
export class WSAPI {
|
|
111
112
|
private onUpdateCallback: Map<onUpdateContextKey, (data: any) => void> = new Map();
|
|
112
113
|
private jackpotGetSignature: string = '';
|
|
114
|
+
private userExtId: string = null;
|
|
113
115
|
|
|
114
116
|
/** @private */
|
|
115
|
-
constructor(private api: SmarticoAPI) {
|
|
117
|
+
constructor(private api: SmarticoAPI, userExtId: string = null) {
|
|
118
|
+
this.userExtId = userExtId;
|
|
116
119
|
OCache.clearAll();
|
|
117
120
|
if (this.api.tracker) {
|
|
118
121
|
const on = this.api.tracker.on;
|
|
@@ -201,7 +204,7 @@ export class WSAPI {
|
|
|
201
204
|
* **Visitor mode: not supported**
|
|
202
205
|
*/
|
|
203
206
|
public async checkSegmentMatch(segment_id: number): Promise<boolean> {
|
|
204
|
-
const r = await this.api.coreCheckSegments(
|
|
207
|
+
const r = await this.api.coreCheckSegments(this.userExtId, [segment_id]);
|
|
205
208
|
if (r && r.find((s) => s.segment_id === segment_id && s.is_matching)) {
|
|
206
209
|
return true;
|
|
207
210
|
} else {
|
|
@@ -219,7 +222,7 @@ export class WSAPI {
|
|
|
219
222
|
* **Visitor mode: not supported**
|
|
220
223
|
*/
|
|
221
224
|
public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
|
|
222
|
-
return await this.api.coreCheckSegments(
|
|
225
|
+
return await this.api.coreCheckSegments(this.userExtId, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
/** Returns all the levels available the current user
|
|
@@ -238,7 +241,7 @@ export class WSAPI {
|
|
|
238
241
|
* ```
|
|
239
242
|
*/
|
|
240
243
|
public async getLevels(): Promise<TLevel[]> {
|
|
241
|
-
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(
|
|
244
|
+
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(this.userExtId), CACHE_DATA_SEC);
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
/**
|
|
@@ -254,7 +257,7 @@ export class WSAPI {
|
|
|
254
257
|
* **Visitor mode: not supported**
|
|
255
258
|
*/
|
|
256
259
|
public async getCurrentLevel(): Promise<TLevelCurrent> {
|
|
257
|
-
return OCache.use(onUpdateContextKey.CurrentLevel, ECacheContext.WSAPI, () => this.api.getLevelCurrent(
|
|
260
|
+
return OCache.use(onUpdateContextKey.CurrentLevel, ECacheContext.WSAPI, () => this.api.getLevelCurrent(this.userExtId), CACHE_DATA_SEC);
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
/** Returns all the missions configured for the current user (server-side scoped, not filtered by Widget visibility).
|
|
@@ -284,7 +287,7 @@ export class WSAPI {
|
|
|
284
287
|
return OCache.use(
|
|
285
288
|
onUpdateContextKey.Missions,
|
|
286
289
|
ECacheContext.WSAPI,
|
|
287
|
-
() => this.api.missionsGetItemsT(
|
|
290
|
+
() => this.api.missionsGetItemsT(this.userExtId),
|
|
288
291
|
CACHE_DATA_SEC,
|
|
289
292
|
);
|
|
290
293
|
}
|
|
@@ -295,7 +298,7 @@ export class WSAPI {
|
|
|
295
298
|
* **Visitor mode: not supported**
|
|
296
299
|
*/
|
|
297
300
|
public async getBadges(): Promise<TMissionOrBadge[]> {
|
|
298
|
-
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(
|
|
301
|
+
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(this.userExtId), CACHE_DATA_SEC);
|
|
299
302
|
}
|
|
300
303
|
|
|
301
304
|
/**
|
|
@@ -311,7 +314,7 @@ export class WSAPI {
|
|
|
311
314
|
this.onUpdateCallback.set(onUpdateContextKey.Bonuses, onUpdate);
|
|
312
315
|
}
|
|
313
316
|
|
|
314
|
-
return OCache.use(onUpdateContextKey.Bonuses, ECacheContext.WSAPI, () => this.api.bonusesGetItemsT(
|
|
317
|
+
return OCache.use(onUpdateContextKey.Bonuses, ECacheContext.WSAPI, () => this.api.bonusesGetItemsT(this.userExtId), CACHE_DATA_SEC);
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
/**
|
|
@@ -323,7 +326,7 @@ export class WSAPI {
|
|
|
323
326
|
* **Visitor mode: not supported**
|
|
324
327
|
*/
|
|
325
328
|
public async claimBonus(bonus_id: number): Promise<TClaimBonusResult> {
|
|
326
|
-
const r = await this.api.bonusClaimItem(
|
|
329
|
+
const r = await this.api.bonusClaimItem(this.userExtId, bonus_id);
|
|
327
330
|
|
|
328
331
|
const o: TClaimBonusResult = {
|
|
329
332
|
err_code: r.errCode,
|
|
@@ -352,7 +355,7 @@ export class WSAPI {
|
|
|
352
355
|
return OCache.use(
|
|
353
356
|
onUpdateContextKey.LevelExtraCounters,
|
|
354
357
|
ECacheContext.WSAPI,
|
|
355
|
-
() => this.api.getUserGamificationInfoT(
|
|
358
|
+
() => this.api.getUserGamificationInfoT(this.userExtId),
|
|
356
359
|
CACHE_DATA_SEC,
|
|
357
360
|
);
|
|
358
361
|
}
|
|
@@ -388,7 +391,7 @@ export class WSAPI {
|
|
|
388
391
|
return OCache.use(
|
|
389
392
|
onUpdateContextKey.StoreItems,
|
|
390
393
|
ECacheContext.WSAPI,
|
|
391
|
-
() => this.api.storeGetItemsT(
|
|
394
|
+
() => this.api.storeGetItemsT(this.userExtId),
|
|
392
395
|
CACHE_DATA_SEC,
|
|
393
396
|
);
|
|
394
397
|
}
|
|
@@ -404,7 +407,7 @@ export class WSAPI {
|
|
|
404
407
|
* **Visitor mode: not supported**
|
|
405
408
|
*/
|
|
406
409
|
public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
|
|
407
|
-
const r = await this.api.buyStoreItem(
|
|
410
|
+
const r = await this.api.buyStoreItem(this.userExtId, item_id);
|
|
408
411
|
|
|
409
412
|
const o: TBuyStoreItemResult = {
|
|
410
413
|
err_code: r.errCode,
|
|
@@ -436,7 +439,7 @@ export class WSAPI {
|
|
|
436
439
|
return OCache.use(
|
|
437
440
|
onUpdateContextKey.StoreCategories,
|
|
438
441
|
ECacheContext.WSAPI,
|
|
439
|
-
() => this.api.storeGetCategoriesT(
|
|
442
|
+
() => this.api.storeGetCategoriesT(this.userExtId),
|
|
440
443
|
CACHE_DATA_SEC,
|
|
441
444
|
);
|
|
442
445
|
}
|
|
@@ -470,7 +473,7 @@ export class WSAPI {
|
|
|
470
473
|
return OCache.use(
|
|
471
474
|
onUpdateContextKey.StoreHistory,
|
|
472
475
|
ECacheContext.WSAPI,
|
|
473
|
-
() => this.api.storeGetPurchasedItemsT(
|
|
476
|
+
() => this.api.storeGetPurchasedItemsT(this.userExtId, limit, offset),
|
|
474
477
|
CACHE_DATA_SEC,
|
|
475
478
|
);
|
|
476
479
|
}
|
|
@@ -497,7 +500,7 @@ export class WSAPI {
|
|
|
497
500
|
return OCache.use(
|
|
498
501
|
onUpdateContextKey.AchCategories,
|
|
499
502
|
ECacheContext.WSAPI,
|
|
500
|
-
() => this.api.achGetCategoriesT(
|
|
503
|
+
() => this.api.achGetCategoriesT(this.userExtId),
|
|
501
504
|
CACHE_DATA_SEC,
|
|
502
505
|
);
|
|
503
506
|
}
|
|
@@ -524,7 +527,7 @@ export class WSAPI {
|
|
|
524
527
|
return OCache.use(
|
|
525
528
|
onUpdateContextKey.CustomSections,
|
|
526
529
|
ECacheContext.WSAPI,
|
|
527
|
-
() => this.api.customSectionsGetT(
|
|
530
|
+
() => this.api.customSectionsGetT(this.userExtId),
|
|
528
531
|
CACHE_DATA_SEC,
|
|
529
532
|
);
|
|
530
533
|
}
|
|
@@ -556,7 +559,7 @@ export class WSAPI {
|
|
|
556
559
|
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
557
560
|
}
|
|
558
561
|
|
|
559
|
-
return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(
|
|
562
|
+
return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(this.userExtId), CACHE_DATA_SEC);
|
|
560
563
|
}
|
|
561
564
|
|
|
562
565
|
/**
|
|
@@ -587,7 +590,7 @@ export class WSAPI {
|
|
|
587
590
|
return OCache.use(
|
|
588
591
|
onUpdateContextKey.SAWHistory,
|
|
589
592
|
ECacheContext.WSAPI,
|
|
590
|
-
() => this.api.getSawWinningHistoryT(
|
|
593
|
+
() => this.api.getSawWinningHistoryT(this.userExtId, limit, offset, saw_template_id),
|
|
591
594
|
CACHE_DATA_SEC,
|
|
592
595
|
);
|
|
593
596
|
}
|
|
@@ -614,8 +617,8 @@ export class WSAPI {
|
|
|
614
617
|
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
615
618
|
}
|
|
616
619
|
|
|
617
|
-
const r = await this.api.sawSpinRequest(
|
|
618
|
-
this.api.doAcknowledgeRequest(
|
|
620
|
+
const r = await this.api.sawSpinRequest(this.userExtId, template_id);
|
|
621
|
+
this.api.doAcknowledgeRequest(this.userExtId, r.request_id);
|
|
619
622
|
|
|
620
623
|
const o: TMiniGamePlayResult = {
|
|
621
624
|
err_code: r.errCode,
|
|
@@ -636,7 +639,7 @@ export class WSAPI {
|
|
|
636
639
|
* ```
|
|
637
640
|
*/
|
|
638
641
|
public async miniGameWinAcknowledgeRequest(request_id: string) {
|
|
639
|
-
return this.api.doAcknowledgeRequest(
|
|
642
|
+
return this.api.doAcknowledgeRequest(this.userExtId, request_id);
|
|
640
643
|
}
|
|
641
644
|
|
|
642
645
|
/**
|
|
@@ -661,10 +664,10 @@ export class WSAPI {
|
|
|
661
664
|
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
662
665
|
}
|
|
663
666
|
|
|
664
|
-
const response = await this.api.sawSpinBatchRequest(
|
|
667
|
+
const response = await this.api.sawSpinBatchRequest(this.userExtId, template_id, spin_count);
|
|
665
668
|
|
|
666
669
|
const request_ids = response.results.map((result) => result.request_id);
|
|
667
|
-
this.api.doAcknowledgeBatchRequest(
|
|
670
|
+
this.api.doAcknowledgeBatchRequest(this.userExtId, request_ids);
|
|
668
671
|
|
|
669
672
|
const o: TMiniGamePlayBatchResult[] = response.results.map((result) => ({
|
|
670
673
|
errCode: result.errCode,
|
|
@@ -683,7 +686,7 @@ export class WSAPI {
|
|
|
683
686
|
* **Visitor mode: not supported**
|
|
684
687
|
*/
|
|
685
688
|
public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult> {
|
|
686
|
-
const r = await this.api.missionOptIn(
|
|
689
|
+
const r = await this.api.missionOptIn(this.userExtId, mission_id);
|
|
687
690
|
|
|
688
691
|
const o: TMissionOptInResult = {
|
|
689
692
|
err_code: r.errCode,
|
|
@@ -699,7 +702,7 @@ export class WSAPI {
|
|
|
699
702
|
* **Visitor mode: not supported**
|
|
700
703
|
*/
|
|
701
704
|
public async requestMissionClaimReward(mission_id: number, ach_completed_id: number): Promise<TMissionClaimRewardResult> {
|
|
702
|
-
const r = await this.api.missionClaimPrize(
|
|
705
|
+
const r = await this.api.missionClaimPrize(this.userExtId, mission_id, ach_completed_id);
|
|
703
706
|
|
|
704
707
|
const o: TMissionClaimRewardResult = {
|
|
705
708
|
err_code: r.errCode,
|
|
@@ -735,7 +738,7 @@ export class WSAPI {
|
|
|
735
738
|
return OCache.use(
|
|
736
739
|
onUpdateContextKey.TournamentList,
|
|
737
740
|
ECacheContext.WSAPI,
|
|
738
|
-
() => this.api.tournamentsGetLobbyT(
|
|
741
|
+
() => this.api.tournamentsGetLobbyT(this.userExtId),
|
|
739
742
|
CACHE_DATA_SEC,
|
|
740
743
|
);
|
|
741
744
|
}
|
|
@@ -766,7 +769,7 @@ export class WSAPI {
|
|
|
766
769
|
* ```
|
|
767
770
|
*/
|
|
768
771
|
public async getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed> {
|
|
769
|
-
return this.api.tournamentsGetInfoT(
|
|
772
|
+
return this.api.tournamentsGetInfoT(this.userExtId, tournamentInstanceId);
|
|
770
773
|
}
|
|
771
774
|
|
|
772
775
|
/**
|
|
@@ -775,7 +778,7 @@ export class WSAPI {
|
|
|
775
778
|
* **Visitor mode: not supported**
|
|
776
779
|
*/
|
|
777
780
|
public async registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult> {
|
|
778
|
-
const r = await this.api.registerInTournament(
|
|
781
|
+
const r = await this.api.registerInTournament(this.userExtId, tournamentInstanceId);
|
|
779
782
|
|
|
780
783
|
const o: TTournamentRegistrationResult = {
|
|
781
784
|
err_code: r.errCode,
|
|
@@ -807,7 +810,7 @@ export class WSAPI {
|
|
|
807
810
|
return OCache.use(
|
|
808
811
|
onUpdateContextKey.LeaderBoards,
|
|
809
812
|
ECacheContext.WSAPI,
|
|
810
|
-
() => this.api.leaderboardsGetT(
|
|
813
|
+
() => this.api.leaderboardsGetT(this.userExtId, periodType, getPreviousPeriod),
|
|
811
814
|
CACHE_DATA_SEC,
|
|
812
815
|
);
|
|
813
816
|
}
|
|
@@ -844,7 +847,7 @@ export class WSAPI {
|
|
|
844
847
|
if (onUpdate) {
|
|
845
848
|
this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
|
|
846
849
|
}
|
|
847
|
-
return await this.api.getInboxMessagesT(
|
|
850
|
+
return await this.api.getInboxMessagesT(this.userExtId, from, to, onlyFavorite, categoryId, read_status);
|
|
848
851
|
}
|
|
849
852
|
|
|
850
853
|
/**
|
|
@@ -860,7 +863,7 @@ export class WSAPI {
|
|
|
860
863
|
return OCache.use(
|
|
861
864
|
onUpdateContextKey.InboxUnreadCount,
|
|
862
865
|
ECacheContext.WSAPI,
|
|
863
|
-
() => this.api.getInboxUnreadCountT(
|
|
866
|
+
() => this.api.getInboxUnreadCountT(this.userExtId),
|
|
864
867
|
CACHE_DATA_SEC,
|
|
865
868
|
);
|
|
866
869
|
}
|
|
@@ -880,7 +883,7 @@ export class WSAPI {
|
|
|
880
883
|
* **Visitor mode: not supported**
|
|
881
884
|
*/
|
|
882
885
|
public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
883
|
-
const r = await this.api.markInboxMessageRead(
|
|
886
|
+
const r = await this.api.markInboxMessageRead(this.userExtId, messageGuid);
|
|
884
887
|
|
|
885
888
|
return {
|
|
886
889
|
err_code: r.errCode,
|
|
@@ -894,7 +897,7 @@ export class WSAPI {
|
|
|
894
897
|
* **Visitor mode: not supported**
|
|
895
898
|
*/
|
|
896
899
|
public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
|
|
897
|
-
const r = await this.api.markAllInboxMessageRead(
|
|
900
|
+
const r = await this.api.markAllInboxMessageRead(this.userExtId);
|
|
898
901
|
|
|
899
902
|
return {
|
|
900
903
|
err_code: r.errCode,
|
|
@@ -908,7 +911,7 @@ export class WSAPI {
|
|
|
908
911
|
* **Visitor mode: not supported**
|
|
909
912
|
*/
|
|
910
913
|
public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
|
|
911
|
-
const r = await this.api.markUnmarkInboxMessageAsFavorite(
|
|
914
|
+
const r = await this.api.markUnmarkInboxMessageAsFavorite(this.userExtId, messageGuid, mark);
|
|
912
915
|
|
|
913
916
|
return {
|
|
914
917
|
err_code: r.errCode,
|
|
@@ -923,7 +926,7 @@ export class WSAPI {
|
|
|
923
926
|
*/
|
|
924
927
|
|
|
925
928
|
public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
926
|
-
const r = await this.api.deleteInboxMessage(
|
|
929
|
+
const r = await this.api.deleteInboxMessage(this.userExtId, messageGuid);
|
|
927
930
|
|
|
928
931
|
return {
|
|
929
932
|
err_code: r.errCode,
|
|
@@ -938,7 +941,7 @@ export class WSAPI {
|
|
|
938
941
|
*/
|
|
939
942
|
|
|
940
943
|
public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
|
|
941
|
-
const r = await this.api.deleteAllInboxMessages(
|
|
944
|
+
const r = await this.api.deleteAllInboxMessages(this.userExtId);
|
|
942
945
|
|
|
943
946
|
return {
|
|
944
947
|
err_code: r.errCode,
|
|
@@ -950,7 +953,7 @@ export class WSAPI {
|
|
|
950
953
|
* Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
|
|
951
954
|
*/
|
|
952
955
|
public async getTranslations(lang_code: string): Promise<TGetTranslations> {
|
|
953
|
-
const r = await this.api.getTranslationsT(
|
|
956
|
+
const r = await this.api.getTranslationsT(this.userExtId, lang_code, []);
|
|
954
957
|
|
|
955
958
|
return {
|
|
956
959
|
translations: r.translations,
|
|
@@ -982,7 +985,7 @@ export class WSAPI {
|
|
|
982
985
|
engagement_uid: string;
|
|
983
986
|
activityType: ActivityTypeLimited | number;
|
|
984
987
|
}): void {
|
|
985
|
-
this.api.reportEngagementImpression(
|
|
988
|
+
this.api.reportEngagementImpression(this.userExtId, engagement_uid, activityType);
|
|
986
989
|
}
|
|
987
990
|
|
|
988
991
|
/**
|
|
@@ -1015,7 +1018,7 @@ export class WSAPI {
|
|
|
1015
1018
|
activityType: ActivityTypeLimited | number;
|
|
1016
1019
|
action?: string;
|
|
1017
1020
|
}): void {
|
|
1018
|
-
this.api.reportEngagementAction(
|
|
1021
|
+
this.api.reportEngagementAction(this.userExtId, engagement_uid, activityType, action);
|
|
1019
1022
|
}
|
|
1020
1023
|
|
|
1021
1024
|
/**
|
|
@@ -1070,24 +1073,39 @@ export class WSAPI {
|
|
|
1070
1073
|
return await OCache.use(
|
|
1071
1074
|
onUpdateContextKey.ActivityLog,
|
|
1072
1075
|
ECacheContext.WSAPI,
|
|
1073
|
-
() => this.api.getActivityLogT(
|
|
1076
|
+
() => this.api.getActivityLogT(this.userExtId, startTimeSeconds, endTimeSeconds, from, to),
|
|
1074
1077
|
CACHE_DATA_SEC,
|
|
1075
1078
|
);
|
|
1076
1079
|
}
|
|
1077
1080
|
|
|
1078
1081
|
/**
|
|
1079
|
-
* Returns the active rounds for the specified MatchX or Quiz game
|
|
1080
|
-
* Each round
|
|
1082
|
+
* Returns the active rounds for the specified MatchX or Quiz game.
|
|
1083
|
+
* Each round includes its events (matches/questions) along with the current user's selections and scores.
|
|
1084
|
+
*
|
|
1085
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1086
|
+
*
|
|
1087
|
+
* **Response** `GamesApiResponse<GamePickRound[]>`:
|
|
1088
|
+
* - `errCode` - 0 on success
|
|
1089
|
+
* - `data` - Array of rounds, each containing:
|
|
1090
|
+
* - `round_id`, `round_name` - Round identifier and display name
|
|
1091
|
+
* - `open_date`, `last_bet_date` - Timestamps (ms) for round open and betting deadline
|
|
1092
|
+
* - `is_active_now`, `is_resolved` - Round state flags
|
|
1093
|
+
* - `round_status_id` - Round status: -1 (active), 2 (no more bets), 3 (all events resolved), 4 (round resolved)
|
|
1094
|
+
* - `score_full_win`, `score_part_win`, `score_lost` - Scoring rules per prediction outcome
|
|
1095
|
+
* - `user_score` - Current user's total score in this round
|
|
1096
|
+
* - `user_placed_bet` - Whether the user has submitted predictions
|
|
1097
|
+
* - `has_open_for_bet_events` - Whether there are events still open for betting
|
|
1098
|
+
* - `events[]` - Array of events with `gp_event_id`, `market_type_id`, `event_meta` (team names, images, sport), `match_date`, `is_open_for_bets`, `odds_details`, and user selection fields
|
|
1081
1099
|
*
|
|
1082
1100
|
* **Example**:
|
|
1083
1101
|
* ```
|
|
1084
1102
|
* _smartico.api.getGamePickActiveRounds({
|
|
1085
|
-
* saw_template_id:
|
|
1086
|
-
* ext_user_id: '149598632',
|
|
1087
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1088
|
-
* lang: 'EN'
|
|
1103
|
+
* saw_template_id: 1083,
|
|
1089
1104
|
* }).then((result) => {
|
|
1090
|
-
* console.log(result);
|
|
1105
|
+
* console.log(result.data); // GamePickRound[]
|
|
1106
|
+
* result.data.forEach(round => {
|
|
1107
|
+
* console.log(round.round_name, round.events.length);
|
|
1108
|
+
* });
|
|
1091
1109
|
* });
|
|
1092
1110
|
* ```
|
|
1093
1111
|
*
|
|
@@ -1097,44 +1115,64 @@ export class WSAPI {
|
|
|
1097
1115
|
if (!props.saw_template_id) {
|
|
1098
1116
|
throw new Error('saw_template_id is required');
|
|
1099
1117
|
}
|
|
1100
|
-
return this.api.gpGetActiveRounds(props.
|
|
1118
|
+
return this.api.gpGetActiveRounds(props.saw_template_id);
|
|
1101
1119
|
}
|
|
1102
1120
|
|
|
1103
1121
|
/**
|
|
1104
|
-
* Returns a single active round
|
|
1105
|
-
*
|
|
1122
|
+
* Returns a single active round for the specified MatchX or Quiz game.
|
|
1123
|
+
* The round includes full event details with the current user's selections.
|
|
1124
|
+
*
|
|
1125
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1126
|
+
* @param props.round_id - The specific round to retrieve
|
|
1127
|
+
*
|
|
1128
|
+
* **Response** `GamesApiResponse<GamePickRound>`:
|
|
1129
|
+
* - `errCode` - 0 on success
|
|
1130
|
+
* - `data` - Single round object with the same structure as in `getGamePickActiveRounds`,
|
|
1131
|
+
* including `events[]` with full event details, user selections, and resolution info
|
|
1106
1132
|
*
|
|
1107
1133
|
* **Example**:
|
|
1108
1134
|
* ```
|
|
1109
1135
|
* _smartico.api.getGamePickActiveRound({
|
|
1110
|
-
* saw_template_id:
|
|
1111
|
-
*
|
|
1112
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1136
|
+
* saw_template_id: 1083,
|
|
1137
|
+
* round_id: 31652,
|
|
1113
1138
|
* }).then((result) => {
|
|
1114
|
-
* console.log(result);
|
|
1139
|
+
* console.log(result.data.round_name, result.data.events.length);
|
|
1140
|
+
* console.log(result.data.user_score, result.data.user_placed_bet);
|
|
1115
1141
|
* });
|
|
1116
1142
|
* ```
|
|
1117
1143
|
*
|
|
1118
1144
|
* **Visitor mode: not supported**
|
|
1119
1145
|
*/
|
|
1120
|
-
public async getGamePickActiveRound(props:
|
|
1146
|
+
public async getGamePickActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>> {
|
|
1121
1147
|
if (!props.saw_template_id) {
|
|
1122
1148
|
throw new Error('saw_template_id is required');
|
|
1123
1149
|
}
|
|
1124
|
-
|
|
1150
|
+
if (!props.round_id) {
|
|
1151
|
+
throw new Error('round_id is required');
|
|
1152
|
+
}
|
|
1153
|
+
return this.api.gpGetActiveRound(props.saw_template_id, props.round_id);
|
|
1125
1154
|
}
|
|
1126
1155
|
|
|
1127
1156
|
/**
|
|
1128
|
-
* Returns the history of all rounds (including resolved) for the specified MatchX or Quiz game.
|
|
1157
|
+
* Returns the history of all rounds (including resolved ones) for the specified MatchX or Quiz game.
|
|
1158
|
+
* Each round contains full event details with results and the current user's predictions.
|
|
1159
|
+
*
|
|
1160
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1161
|
+
*
|
|
1162
|
+
* **Response** `GamesApiResponse<GamePickRound[]>`:
|
|
1163
|
+
* - `errCode` - 0 on success
|
|
1164
|
+
* - `data` - Array of rounds ordered by `round_row_id` descending (newest first).
|
|
1165
|
+
* Each round has the same structure as in `getGamePickActiveRounds`, including resolved events
|
|
1166
|
+
* with `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) and `resolution_score`
|
|
1129
1167
|
*
|
|
1130
1168
|
* **Example**:
|
|
1131
1169
|
* ```
|
|
1132
1170
|
* _smartico.api.getGamePickHistory({
|
|
1133
|
-
* saw_template_id:
|
|
1134
|
-
* ext_user_id: '149598632',
|
|
1135
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1171
|
+
* saw_template_id: 1083,
|
|
1136
1172
|
* }).then((result) => {
|
|
1137
|
-
*
|
|
1173
|
+
* result.data.forEach(round => {
|
|
1174
|
+
* console.log(round.round_name, 'Score:', round.user_score, 'Resolved:', round.is_resolved);
|
|
1175
|
+
* });
|
|
1138
1176
|
* });
|
|
1139
1177
|
* ```
|
|
1140
1178
|
*
|
|
@@ -1144,113 +1182,174 @@ export class WSAPI {
|
|
|
1144
1182
|
if (!props.saw_template_id) {
|
|
1145
1183
|
throw new Error('saw_template_id is required');
|
|
1146
1184
|
}
|
|
1147
|
-
return this.api.gpGetGamesHistory(props.
|
|
1185
|
+
return this.api.gpGetGamesHistory(props.saw_template_id);
|
|
1148
1186
|
}
|
|
1149
1187
|
|
|
1150
1188
|
/**
|
|
1151
1189
|
* Returns the leaderboard for a specific round within a MatchX or Quiz game.
|
|
1152
|
-
* Use round_id = -1 (AllRoundsGameBoardID)
|
|
1190
|
+
* Use `round_id = -1` (AllRoundsGameBoardID) to get the season/overall leaderboard across all rounds.
|
|
1191
|
+
*
|
|
1192
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1193
|
+
* @param props.round_id - The round to get the leaderboard for. Use -1 for overall/seasonal leaderboard
|
|
1194
|
+
*
|
|
1195
|
+
* **Response** `GamesApiResponse<GamePickRoundBoard>`:
|
|
1196
|
+
* - `errCode` - 0 on success
|
|
1197
|
+
* - `data` - Leaderboard object containing:
|
|
1198
|
+
* - Round base fields (`round_id`, `round_name`, `open_date`, `last_bet_date`, etc.)
|
|
1199
|
+
* - `users[]` - Ranked list of players, each with:
|
|
1200
|
+
* - `ext_user_id`, `int_user_id` - User identifiers
|
|
1201
|
+
* - `public_username`, `avatar_url` - Display info (usernames may be masked based on label settings)
|
|
1202
|
+
* - `gp_position` - Leaderboard rank (null if not yet ranked)
|
|
1203
|
+
* - `resolution_score` - Total score in this round
|
|
1204
|
+
* - `full_wins_count`, `part_wins_count`, `lost_count` - Prediction outcome counts
|
|
1205
|
+
* - `my_user` - Current user's entry (same fields as above), or null if user hasn't participated
|
|
1153
1206
|
*
|
|
1154
1207
|
* **Example**:
|
|
1155
1208
|
* ```
|
|
1156
1209
|
* _smartico.api.getGamePickBoard({
|
|
1157
|
-
* saw_template_id:
|
|
1158
|
-
*
|
|
1159
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1160
|
-
* round_id: 456
|
|
1210
|
+
* saw_template_id: 1083,
|
|
1211
|
+
* round_id: 31652,
|
|
1161
1212
|
* }).then((result) => {
|
|
1162
|
-
* console.log(
|
|
1213
|
+
* console.log('Top players:', result.data.users);
|
|
1214
|
+
* console.log('My position:', result.data.my_user?.gp_position);
|
|
1163
1215
|
* });
|
|
1164
1216
|
* ```
|
|
1165
1217
|
*
|
|
1166
1218
|
* **Visitor mode: not supported**
|
|
1167
1219
|
*/
|
|
1168
|
-
public async getGamePickBoard(props:
|
|
1220
|
+
public async getGamePickBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>> {
|
|
1169
1221
|
if (!props.saw_template_id) {
|
|
1170
1222
|
throw new Error('saw_template_id is required');
|
|
1171
1223
|
}
|
|
1172
|
-
if (props.round_id
|
|
1224
|
+
if (!props.round_id) {
|
|
1173
1225
|
throw new Error('round_id is required');
|
|
1174
1226
|
}
|
|
1175
|
-
return this.api.gpGetGameBoard(props.
|
|
1227
|
+
return this.api.gpGetGameBoard(props.saw_template_id, props.round_id);
|
|
1176
1228
|
}
|
|
1177
1229
|
|
|
1178
1230
|
/**
|
|
1179
|
-
* Submits
|
|
1180
|
-
* Sends the
|
|
1181
|
-
* Each event
|
|
1231
|
+
* Submits score predictions for a round in a MatchX game.
|
|
1232
|
+
* Sends the round object with user selections for all events at once.
|
|
1233
|
+
* Each event must include `team1_user_selection` and `team2_user_selection` representing predicted scores.
|
|
1234
|
+
* If the user hasn't placed bets before, one game attempt (spin) will be consumed.
|
|
1235
|
+
* Predictions can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
|
|
1236
|
+
*
|
|
1237
|
+
* @param props.saw_template_id - The ID of the MatchX game template
|
|
1238
|
+
* @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `getGamePickActiveRound`
|
|
1239
|
+
* and modified with user predictions. Each event needs: `gp_event_id`, `team1_user_selection`, `team2_user_selection`
|
|
1240
|
+
*
|
|
1241
|
+
* **Response** `GamesApiResponse<GamePickRound>`:
|
|
1242
|
+
* - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
|
|
1243
|
+
* - `data` - Updated round with all events reflecting the submitted selections.
|
|
1244
|
+
* `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
|
|
1182
1245
|
*
|
|
1183
1246
|
* **Example**:
|
|
1184
1247
|
* ```
|
|
1185
|
-
* _smartico.api.
|
|
1186
|
-
* saw_template_id:
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
* round
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1194
|
-
*
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1248
|
+
* _smartico.api.getGamePickActiveRound({
|
|
1249
|
+
* saw_template_id: 1190,
|
|
1250
|
+
* round_id: 38665,
|
|
1251
|
+
* }).then((roundData) => {
|
|
1252
|
+
* const round = roundData.data;
|
|
1253
|
+
* round.events = round.events.map(e => ({
|
|
1254
|
+
* gp_event_id: e.gp_event_id,
|
|
1255
|
+
* team1_user_selection: 1,
|
|
1256
|
+
* team2_user_selection: 0,
|
|
1257
|
+
* }));
|
|
1258
|
+
* _smartico.api.submitGamePickSelection({
|
|
1259
|
+
* saw_template_id: 1190,
|
|
1260
|
+
* round: round,
|
|
1261
|
+
* }).then((result) => {
|
|
1262
|
+
* console.log(result.data.user_placed_bet); // true
|
|
1263
|
+
* });
|
|
1198
1264
|
* });
|
|
1199
1265
|
* ```
|
|
1200
1266
|
*
|
|
1201
1267
|
* **Visitor mode: not supported**
|
|
1202
1268
|
*/
|
|
1203
|
-
public async submitGamePickSelection(props: GamePickRequestParams & { round:
|
|
1269
|
+
public async submitGamePickSelection(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
|
|
1204
1270
|
if (!props.saw_template_id) {
|
|
1205
1271
|
throw new Error('saw_template_id is required');
|
|
1206
1272
|
}
|
|
1207
|
-
|
|
1273
|
+
if (!props.round?.round_id) {
|
|
1274
|
+
throw new Error('round is required');
|
|
1275
|
+
}
|
|
1276
|
+
return this.api.gpSubmitSelection(props.saw_template_id, props.round, false);
|
|
1208
1277
|
}
|
|
1209
1278
|
|
|
1210
1279
|
/**
|
|
1211
1280
|
* Submits answers for a round in a Quiz game.
|
|
1212
|
-
* Sends the
|
|
1213
|
-
* Each event
|
|
1281
|
+
* Sends the round object with user answers for all events at once.
|
|
1282
|
+
* Each event must include `user_selection` with the answer value (e.g. '1', '2', 'x', 'yes', 'no' — depending on the market type).
|
|
1283
|
+
* If the user hasn't placed bets before, one game attempt (spin) will be consumed.
|
|
1284
|
+
* Answers can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
|
|
1285
|
+
*
|
|
1286
|
+
* @param props.saw_template_id - The ID of the Quiz game template
|
|
1287
|
+
* @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `getGamePickActiveRound`
|
|
1288
|
+
* and modified with user answers. Each event needs: `gp_event_id`, `user_selection`
|
|
1289
|
+
*
|
|
1290
|
+
* **Response** `GamesApiResponse<GamePickRound>`:
|
|
1291
|
+
* - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
|
|
1292
|
+
* - `data` - Updated round with all events reflecting the submitted answers.
|
|
1293
|
+
* `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
|
|
1214
1294
|
*
|
|
1215
1295
|
* **Example**:
|
|
1216
1296
|
* ```
|
|
1217
|
-
* _smartico.api.
|
|
1218
|
-
* saw_template_id:
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
* round
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1297
|
+
* _smartico.api.getGamePickActiveRound({
|
|
1298
|
+
* saw_template_id: 1183,
|
|
1299
|
+
* round_id: 37974,
|
|
1300
|
+
* }).then((roundData) => {
|
|
1301
|
+
* const round = roundData.data;
|
|
1302
|
+
* round.events = round.events.map(e => ({
|
|
1303
|
+
* gp_event_id: e.gp_event_id,
|
|
1304
|
+
* user_selection: 'x',
|
|
1305
|
+
* }));
|
|
1306
|
+
* _smartico.api.submitGamePickSelectionQuiz({
|
|
1307
|
+
* saw_template_id: 1183,
|
|
1308
|
+
* round: round,
|
|
1309
|
+
* }).then((result) => {
|
|
1310
|
+
* console.log(result.data.user_placed_bet); // true
|
|
1311
|
+
* });
|
|
1230
1312
|
* });
|
|
1231
1313
|
* ```
|
|
1232
1314
|
*
|
|
1233
1315
|
* **Visitor mode: not supported**
|
|
1234
1316
|
*/
|
|
1235
|
-
public async submitGamePickSelectionQuiz(props: GamePickRequestParams & { round:
|
|
1317
|
+
public async submitGamePickSelectionQuiz(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>> {
|
|
1236
1318
|
if (!props.saw_template_id) {
|
|
1237
1319
|
throw new Error('saw_template_id is required');
|
|
1238
1320
|
}
|
|
1239
|
-
|
|
1321
|
+
if (!props.round?.round_id) {
|
|
1322
|
+
throw new Error('round is required');
|
|
1323
|
+
}
|
|
1324
|
+
return this.api.gpSubmitSelection(props.saw_template_id, props.round, true);
|
|
1240
1325
|
}
|
|
1241
1326
|
|
|
1242
1327
|
/**
|
|
1243
1328
|
* Returns the current user's profile information within the specified MatchX or Quiz game.
|
|
1244
|
-
*
|
|
1329
|
+
* The user record is synced from the Smartico platform into the games DB (synced every 1 minute).
|
|
1330
|
+
* If the user doesn't exist in the games DB yet, it will be created automatically on first call.
|
|
1331
|
+
*
|
|
1332
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1333
|
+
*
|
|
1334
|
+
* **Response** `GamesApiResponse<GamePickUserInfo>`:
|
|
1335
|
+
* - `errCode` - 0 on success
|
|
1336
|
+
* - `data`:
|
|
1337
|
+
* - `ext_user_id` - External user ID (Smartico internal numeric ID)
|
|
1338
|
+
* - `int_user_id` - Internal user ID within the games system
|
|
1339
|
+
* - `public_username` - Display name
|
|
1340
|
+
* - `avatar_url` - User's avatar image URL
|
|
1341
|
+
* - `last_wallet_sync_time` - Last time the user's balance was synced from Smartico
|
|
1342
|
+
* - `ach_points_balance` - User's current points balance
|
|
1343
|
+
* - `ach_gems_balance` - User's current gems balance
|
|
1344
|
+
* - `ach_diamonds_balance` - User's current diamonds balance
|
|
1345
|
+
* - `pubic_username_set` - Whether the user has set a custom username
|
|
1245
1346
|
*
|
|
1246
1347
|
* **Example**:
|
|
1247
1348
|
* ```
|
|
1248
1349
|
* _smartico.api.getGamePickUserInfo({
|
|
1249
|
-
* saw_template_id:
|
|
1250
|
-
* ext_user_id: '149598632',
|
|
1251
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1350
|
+
* saw_template_id: 1083,
|
|
1252
1351
|
* }).then((result) => {
|
|
1253
|
-
* console.log(result.data.public_username, result.data.
|
|
1352
|
+
* console.log(result.data.public_username, result.data.ach_points_balance);
|
|
1254
1353
|
* });
|
|
1255
1354
|
* ```
|
|
1256
1355
|
*
|
|
@@ -1260,20 +1359,38 @@ export class WSAPI {
|
|
|
1260
1359
|
if (!props.saw_template_id) {
|
|
1261
1360
|
throw new Error('saw_template_id is required');
|
|
1262
1361
|
}
|
|
1263
|
-
return this.api.gpGetUserInfo(props.
|
|
1362
|
+
return this.api.gpGetUserInfo(props.saw_template_id);
|
|
1264
1363
|
}
|
|
1265
1364
|
|
|
1266
1365
|
/**
|
|
1267
|
-
* Returns the game configuration
|
|
1366
|
+
* Returns the game configuration and the list of all rounds for the specified MatchX or Quiz game.
|
|
1367
|
+
* Includes the SAW template definition, label settings, and round metadata (without events).
|
|
1368
|
+
*
|
|
1369
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1370
|
+
*
|
|
1371
|
+
* **Response** `GamesApiResponse<GamePickGameInfo>`:
|
|
1372
|
+
* - `errCode` - 0 on success
|
|
1373
|
+
* - `data`:
|
|
1374
|
+
* - `sawTemplate` - Game template configuration including:
|
|
1375
|
+
* - `saw_template_id`, `saw_game_type_id` (6 = MatchX/Quiz)
|
|
1376
|
+
* - `saw_template_ui_definition` - UI settings (name, ranking options, ask_for_username, etc.)
|
|
1377
|
+
* - `saw_buyin_type_id` - Cost type (1=Free, 2=Points, 3=Gems, 4=Diamonds, 5=Spins)
|
|
1378
|
+
* - `buyin_cost_points` - Cost per attempt
|
|
1379
|
+
* - `spin_count` - Available attempts for the current user
|
|
1380
|
+
* - `allRounds[]` - List of all rounds (metadata only, no events), each with:
|
|
1381
|
+
* - `round_id`, `round_name`, `round_description`
|
|
1382
|
+
* - `open_date`, `last_bet_date` - Timestamps (ms)
|
|
1383
|
+
* - `is_active_now`, `is_resolved`, `round_status_id`
|
|
1384
|
+
* - `labelInfo` - Label/brand configuration and settings
|
|
1268
1385
|
*
|
|
1269
1386
|
* **Example**:
|
|
1270
1387
|
* ```
|
|
1271
1388
|
* _smartico.api.getGamePickGameInfo({
|
|
1272
|
-
* saw_template_id:
|
|
1273
|
-
* ext_user_id: '149598632',
|
|
1274
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1389
|
+
* saw_template_id: 1189,
|
|
1275
1390
|
* }).then((result) => {
|
|
1276
|
-
* console.log(result.data.sawTemplate
|
|
1391
|
+
* console.log(result.data.sawTemplate.saw_template_ui_definition.name);
|
|
1392
|
+
* console.log('Rounds:', result.data.allRounds.length);
|
|
1393
|
+
* console.log('Buy-in type:', result.data.sawTemplate.saw_buyin_type_id);
|
|
1277
1394
|
* });
|
|
1278
1395
|
* ```
|
|
1279
1396
|
*
|
|
@@ -1283,22 +1400,31 @@ export class WSAPI {
|
|
|
1283
1400
|
if (!props.saw_template_id) {
|
|
1284
1401
|
throw new Error('saw_template_id is required');
|
|
1285
1402
|
}
|
|
1286
|
-
return this.api.gpGetGameInfo(props.
|
|
1403
|
+
return this.api.gpGetGameInfo(props.saw_template_id);
|
|
1287
1404
|
}
|
|
1288
1405
|
|
|
1289
1406
|
/**
|
|
1290
1407
|
* Returns translations for the MatchX/Quiz game UI.
|
|
1291
|
-
* Translations are returned as a key-value map
|
|
1408
|
+
* Translations are returned as a key-value map for the Gamification and RetentionGames areas,
|
|
1409
|
+
* resolved to the current user's language.
|
|
1410
|
+
*
|
|
1411
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1412
|
+
*
|
|
1413
|
+
* **Response** `GamesApiResponse<any>`:
|
|
1414
|
+
* - `errCode` - 0 on success
|
|
1415
|
+
* - `data`:
|
|
1416
|
+
* - `translations` - Key-value map of translation strings (e.g. `rgSubmitSelection`, `rgLeaderboardTitle`, `quizConfirmAnswer`, etc.)
|
|
1417
|
+
* - `hash_code` - Hash for cache invalidation
|
|
1418
|
+
* - `lang_code` - Resolved language code (e.g. 'EN')
|
|
1292
1419
|
*
|
|
1293
1420
|
* **Example**:
|
|
1294
1421
|
* ```
|
|
1295
1422
|
* _smartico.api.getGamePickTranslations({
|
|
1296
|
-
* saw_template_id:
|
|
1297
|
-
* ext_user_id: '149598632',
|
|
1298
|
-
* smartico_ext_user_id: 'user@example.com',
|
|
1299
|
-
* lang: 'EN'
|
|
1423
|
+
* saw_template_id: 1083,
|
|
1300
1424
|
* }).then((result) => {
|
|
1301
|
-
*
|
|
1425
|
+
* const tr = result.data.translations;
|
|
1426
|
+
* console.log(tr.rgSubmitSelection); // "Submit selection"
|
|
1427
|
+
* console.log(tr.rgLeaderboardTitle); // "Leaderboard"
|
|
1302
1428
|
* });
|
|
1303
1429
|
* ```
|
|
1304
1430
|
*
|
|
@@ -1308,29 +1434,41 @@ export class WSAPI {
|
|
|
1308
1434
|
if (!props.saw_template_id) {
|
|
1309
1435
|
throw new Error('saw_template_id is required');
|
|
1310
1436
|
}
|
|
1311
|
-
return this.api.gpGetTranslations(props.
|
|
1437
|
+
return this.api.gpGetTranslations(props.saw_template_id);
|
|
1312
1438
|
}
|
|
1313
1439
|
|
|
1314
1440
|
/**
|
|
1315
1441
|
* Returns round data with events and picks for a specific user (identified by their internal user ID).
|
|
1316
|
-
* Useful for
|
|
1442
|
+
* Useful for viewing another user's predictions from the leaderboard.
|
|
1443
|
+
* The `int_user_id` can be obtained from the `getGamePickBoard` response (`users[].int_user_id`).
|
|
1444
|
+
*
|
|
1445
|
+
* @param props.saw_template_id - The ID of the MatchX or Quiz game template
|
|
1446
|
+
* @param props.round_id - The round to get info for
|
|
1447
|
+
* @param props.int_user_id - Internal user ID of the player whose predictions to view (from leaderboard data)
|
|
1448
|
+
*
|
|
1449
|
+
* **Response** `GamesApiResponse<GamePickRound>`:
|
|
1450
|
+
* - `errCode` - 0 on success
|
|
1451
|
+
* - `data` - Round object with the target user's selections.
|
|
1452
|
+
* Same structure as `getGamePickActiveRound`, but `user_selection`/`team1_user_selection`/`team2_user_selection`
|
|
1453
|
+
* fields on events reflect the specified user's picks instead of the current user's.
|
|
1454
|
+
* Events also include `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) showing how each prediction was scored
|
|
1317
1455
|
*
|
|
1318
1456
|
* **Example**:
|
|
1319
1457
|
* ```
|
|
1320
1458
|
* _smartico.api.getGamePickRoundInfoForUser({
|
|
1321
|
-
* saw_template_id:
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
* round_id: 456,
|
|
1325
|
-
* int_user_id: 789
|
|
1459
|
+
* saw_template_id: 1083,
|
|
1460
|
+
* round_id: 31652,
|
|
1461
|
+
* int_user_id: 65653810,
|
|
1326
1462
|
* }).then((result) => {
|
|
1327
|
-
*
|
|
1463
|
+
* result.data.events.forEach(e => {
|
|
1464
|
+
* console.log(e.event_meta.team1_name, 'vs', e.event_meta.team2_name, '→', e.user_selection);
|
|
1465
|
+
* });
|
|
1328
1466
|
* });
|
|
1329
1467
|
* ```
|
|
1330
1468
|
*
|
|
1331
1469
|
* **Visitor mode: not supported**
|
|
1332
1470
|
*/
|
|
1333
|
-
public async getGamePickRoundInfoForUser(props:
|
|
1471
|
+
public async getGamePickRoundInfoForUser(props: GamePickRoundRequestParams & { int_user_id: number }): Promise<GamesApiResponse<GamePickRound>> {
|
|
1334
1472
|
if (!props.saw_template_id) {
|
|
1335
1473
|
throw new Error('saw_template_id is required');
|
|
1336
1474
|
}
|
|
@@ -1340,14 +1478,14 @@ export class WSAPI {
|
|
|
1340
1478
|
if (!props.int_user_id) {
|
|
1341
1479
|
throw new Error('int_user_id is required');
|
|
1342
1480
|
}
|
|
1343
|
-
return this.api.gpGetRoundInfoForUser(props.
|
|
1481
|
+
return this.api.gpGetRoundInfoForUser(props.saw_template_id, props.round_id, props.int_user_id);
|
|
1344
1482
|
}
|
|
1345
1483
|
|
|
1346
1484
|
private async updateOnSpin(data: SAWSpinsCountPush) {
|
|
1347
1485
|
const templates: TMiniGameTemplate[] = await OCache.use(
|
|
1348
1486
|
onUpdateContextKey.Saw,
|
|
1349
1487
|
ECacheContext.WSAPI,
|
|
1350
|
-
() => this.api.sawGetTemplatesT(
|
|
1488
|
+
() => this.api.sawGetTemplatesT(this.userExtId),
|
|
1351
1489
|
CACHE_DATA_SEC,
|
|
1352
1490
|
);
|
|
1353
1491
|
const index = templates.findIndex((t) => t.id === data.saw_template_id);
|
|
@@ -1356,32 +1494,32 @@ export class WSAPI {
|
|
|
1356
1494
|
}
|
|
1357
1495
|
|
|
1358
1496
|
private async reloadMiniGameTemplate() {
|
|
1359
|
-
const updatedTemplates = await this.api.sawGetTemplatesT(
|
|
1497
|
+
const updatedTemplates = await this.api.sawGetTemplatesT(this.userExtId);
|
|
1360
1498
|
this.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
|
|
1361
1499
|
}
|
|
1362
1500
|
|
|
1363
1501
|
private async updateMissions() {
|
|
1364
|
-
const payload = await this.api.missionsGetItemsT(
|
|
1502
|
+
const payload = await this.api.missionsGetItemsT(this.userExtId);
|
|
1365
1503
|
this.updateEntity(onUpdateContextKey.Missions, payload);
|
|
1366
1504
|
}
|
|
1367
1505
|
|
|
1368
1506
|
private async updateBonuses() {
|
|
1369
|
-
const payload = await this.api.bonusesGetItemsT(
|
|
1507
|
+
const payload = await this.api.bonusesGetItemsT(this.userExtId);
|
|
1370
1508
|
this.updateEntity(onUpdateContextKey.Bonuses, payload);
|
|
1371
1509
|
}
|
|
1372
1510
|
|
|
1373
1511
|
private async updateTournaments() {
|
|
1374
|
-
const payload = await this.api.tournamentsGetLobbyT(
|
|
1512
|
+
const payload = await this.api.tournamentsGetLobbyT(this.userExtId);
|
|
1375
1513
|
this.updateEntity(onUpdateContextKey.TournamentList, payload);
|
|
1376
1514
|
}
|
|
1377
1515
|
|
|
1378
1516
|
private async updateStorePurchasedItems() {
|
|
1379
|
-
const payload = await this.api.storeGetPurchasedItemsT(
|
|
1517
|
+
const payload = await this.api.storeGetPurchasedItemsT(this.userExtId, 20, 0);
|
|
1380
1518
|
this.updateEntity(onUpdateContextKey.StoreHistory, payload);
|
|
1381
1519
|
}
|
|
1382
1520
|
|
|
1383
1521
|
private async updateStoreItems() {
|
|
1384
|
-
const payload = await this.api.storeGetItemsT(
|
|
1522
|
+
const payload = await this.api.storeGetItemsT(this.userExtId);
|
|
1385
1523
|
this.updateEntity(onUpdateContextKey.StoreItems, payload);
|
|
1386
1524
|
}
|
|
1387
1525
|
|
|
@@ -1390,19 +1528,19 @@ export class WSAPI {
|
|
|
1390
1528
|
}
|
|
1391
1529
|
|
|
1392
1530
|
private async updateInboxMessages() {
|
|
1393
|
-
const payload = await this.api.getInboxMessagesT(
|
|
1531
|
+
const payload = await this.api.getInboxMessagesT(this.userExtId);
|
|
1394
1532
|
this.updateEntity(onUpdateContextKey.InboxMessages, payload);
|
|
1395
1533
|
}
|
|
1396
1534
|
|
|
1397
1535
|
private async updateRaffles() {
|
|
1398
|
-
const payload = await this.api.getRafflesT(
|
|
1536
|
+
const payload = await this.api.getRafflesT(this.userExtId);
|
|
1399
1537
|
this.updateEntity(onUpdateContextKey.Raffles, payload);
|
|
1400
1538
|
}
|
|
1401
1539
|
|
|
1402
1540
|
private async notifyActivityLogUpdate() {
|
|
1403
1541
|
const startSeconds = Date.now() / 1000 - 600;
|
|
1404
1542
|
const endSeconds = Date.now() / 1000;
|
|
1405
|
-
const payload = await this.api.getActivityLogT(
|
|
1543
|
+
const payload = await this.api.getActivityLogT(this.userExtId, startSeconds, endSeconds, 0, 50);
|
|
1406
1544
|
|
|
1407
1545
|
this.updateEntity(onUpdateContextKey.ActivityLog, payload);
|
|
1408
1546
|
}
|
|
@@ -1456,7 +1594,7 @@ export class WSAPI {
|
|
|
1456
1594
|
onUpdateContextKey.Jackpots,
|
|
1457
1595
|
ECacheContext.WSAPI,
|
|
1458
1596
|
async () => {
|
|
1459
|
-
const _jackpots = await this.api.jackpotGet(
|
|
1597
|
+
const _jackpots = await this.api.jackpotGet(this.userExtId, filter);
|
|
1460
1598
|
const _pots = _jackpots.items.map((jp) => jp.pot);
|
|
1461
1599
|
|
|
1462
1600
|
_jackpots.items.forEach((jp) => {
|
|
@@ -1475,7 +1613,7 @@ export class WSAPI {
|
|
|
1475
1613
|
ECacheContext.WSAPI,
|
|
1476
1614
|
async () => {
|
|
1477
1615
|
const jp_template_ids = jackpots.map((jp) => jp.jp_template_id);
|
|
1478
|
-
return (await this.api.potGet(
|
|
1616
|
+
return (await this.api.potGet(this.userExtId, { jp_template_ids })).items;
|
|
1479
1617
|
},
|
|
1480
1618
|
JACKPOT_POT_CACHE_SEC,
|
|
1481
1619
|
);
|
|
@@ -1509,7 +1647,7 @@ export class WSAPI {
|
|
|
1509
1647
|
throw new Error('jp_template_id is required in jackpotOptIn');
|
|
1510
1648
|
}
|
|
1511
1649
|
|
|
1512
|
-
const result = await this.api.jackpotOptIn(
|
|
1650
|
+
const result = await this.api.jackpotOptIn(this.userExtId, filter);
|
|
1513
1651
|
|
|
1514
1652
|
return result;
|
|
1515
1653
|
}
|
|
@@ -1533,7 +1671,7 @@ export class WSAPI {
|
|
|
1533
1671
|
throw new Error('jp_template_id is required in jackpotOptOut');
|
|
1534
1672
|
}
|
|
1535
1673
|
|
|
1536
|
-
const result = await this.api.jackpotOptOut(
|
|
1674
|
+
const result = await this.api.jackpotOptOut(this.userExtId, filter);
|
|
1537
1675
|
|
|
1538
1676
|
return result;
|
|
1539
1677
|
}
|
|
@@ -1566,7 +1704,7 @@ export class WSAPI {
|
|
|
1566
1704
|
return OCache.use(
|
|
1567
1705
|
onUpdateContextKey.JackpotWinners + jp_template_id,
|
|
1568
1706
|
ECacheContext.WSAPI,
|
|
1569
|
-
() => this.api.getJackpotWinnersT(
|
|
1707
|
+
() => this.api.getJackpotWinnersT(this.userExtId, limit, offset, jp_template_id),
|
|
1570
1708
|
JACKPOT_WINNERS_CACHE_SEC,
|
|
1571
1709
|
);
|
|
1572
1710
|
}
|
|
@@ -1593,7 +1731,7 @@ export class WSAPI {
|
|
|
1593
1731
|
return OCache.use(
|
|
1594
1732
|
onUpdateContextKey.JackpotEligibleGames + jp_template_id,
|
|
1595
1733
|
ECacheContext.WSAPI,
|
|
1596
|
-
() => this.api.getJackpotEligibleGamesT(
|
|
1734
|
+
() => this.api.getJackpotEligibleGamesT(this.userExtId, { jp_template_id }),
|
|
1597
1735
|
JACKPOT_ELIGIBLE_GAMES_CACHE_SEC,
|
|
1598
1736
|
);
|
|
1599
1737
|
}
|
|
@@ -1617,7 +1755,7 @@ export class WSAPI {
|
|
|
1617
1755
|
* ```
|
|
1618
1756
|
*/
|
|
1619
1757
|
public async getRelatedItemsForGame(related_game_id: string): Promise<GetRelatedAchTourResponse> {
|
|
1620
|
-
const result = await this.api.getRelatedItemsForGame(
|
|
1758
|
+
const result = await this.api.getRelatedItemsForGame(this.userExtId, related_game_id);
|
|
1621
1759
|
return result;
|
|
1622
1760
|
}
|
|
1623
1761
|
|
|
@@ -1649,7 +1787,7 @@ export class WSAPI {
|
|
|
1649
1787
|
this.onUpdateCallback.set(onUpdateContextKey.Raffles, onUpdate);
|
|
1650
1788
|
}
|
|
1651
1789
|
|
|
1652
|
-
return OCache.use(onUpdateContextKey.Raffles, ECacheContext.WSAPI, () => this.api.getRafflesT(
|
|
1790
|
+
return OCache.use(onUpdateContextKey.Raffles, ECacheContext.WSAPI, () => this.api.getRafflesT(this.userExtId), CACHE_DATA_SEC);
|
|
1653
1791
|
}
|
|
1654
1792
|
|
|
1655
1793
|
/**
|
|
@@ -1681,7 +1819,7 @@ export class WSAPI {
|
|
|
1681
1819
|
throw new Error('both raffle_id and run_id are required');
|
|
1682
1820
|
}
|
|
1683
1821
|
|
|
1684
|
-
return await this.api.getRaffleDrawRunT(
|
|
1822
|
+
return await this.api.getRaffleDrawRunT(this.userExtId, props.raffle_id, props.run_id, props.winners_from, props.winners_to);
|
|
1685
1823
|
}
|
|
1686
1824
|
|
|
1687
1825
|
/**
|
|
@@ -1707,7 +1845,7 @@ export class WSAPI {
|
|
|
1707
1845
|
*/
|
|
1708
1846
|
|
|
1709
1847
|
public async getRaffleDrawRunsHistory(props: { raffle_id: number; draw_id?: number }): Promise<TRaffleDrawRun[]> {
|
|
1710
|
-
const res = await this.api.getRaffleDrawRunsHistory(
|
|
1848
|
+
const res = await this.api.getRaffleDrawRunsHistory(this.userExtId, props);
|
|
1711
1849
|
|
|
1712
1850
|
if (!props.raffle_id) {
|
|
1713
1851
|
throw new Error('raffle_id is required');
|
|
@@ -1742,7 +1880,7 @@ export class WSAPI {
|
|
|
1742
1880
|
throw new Error('won_id is required');
|
|
1743
1881
|
}
|
|
1744
1882
|
|
|
1745
|
-
const res = await this.api.claimRafflePrize(
|
|
1883
|
+
const res = await this.api.claimRafflePrize(this.userExtId, { won_id: props.won_id });
|
|
1746
1884
|
return raffleClaimPrizeResponseTransform(res);
|
|
1747
1885
|
}
|
|
1748
1886
|
|
|
@@ -1762,7 +1900,7 @@ export class WSAPI {
|
|
|
1762
1900
|
throw new Error('raffle_run_id is required');
|
|
1763
1901
|
}
|
|
1764
1902
|
|
|
1765
|
-
const r = await this.api.raffleOptin(
|
|
1903
|
+
const r = await this.api.raffleOptin(this.userExtId, props);
|
|
1766
1904
|
|
|
1767
1905
|
return {
|
|
1768
1906
|
err_code: r.errCode,
|