@smartico/public-api 0.0.351 → 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.
@@ -1,6 +1,7 @@
1
1
  import { ActivityTypeLimited } from '../Core';
2
2
  import { SmarticoAPI } from '../SmarticoAPI';
3
3
  import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUICustomSection, TUserProfile, UserLevelExtraCountersT, TBonus, TClaimBonusResult, TMiniGamePlayBatchResult, TSawHistory, TRaffle, TRaffleDraw, TRaffleDrawRun, TransformedRaffleClaimPrizeResponse, TLevelCurrent, TActivityLog, TRaffleOptinResponse } from './WSAPITypes';
4
+ import { GamesApiResponse, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamePickGameInfo, GamePickRequestParams, GamePickRoundRequestParams } from '../GamePick';
4
5
  import { LeaderBoardPeriodType } from '../Leaderboard';
5
6
  import { JackpotDetails, JackpotWinnerHistory, JackpotsOptinResponse, JackpotsOptoutResponse } from '../Jackpots';
6
7
  import { GetRelatedAchTourResponse } from '../Missions/GetRelatedAchTourResponse';
@@ -12,8 +13,9 @@ export declare class WSAPI {
12
13
  private api;
13
14
  private onUpdateCallback;
14
15
  private jackpotGetSignature;
16
+ private userExtId;
15
17
  /** @private */
16
- constructor(api: SmarticoAPI);
18
+ constructor(api: SmarticoAPI, userExtId?: string);
17
19
  /** @private */
18
20
  clearCaches(): void;
19
21
  /** Returns information about current user
@@ -582,6 +584,337 @@ export declare class WSAPI {
582
584
  to: number;
583
585
  onUpdate?: (data: TActivityLog[]) => void;
584
586
  }): Promise<TActivityLog[]>;
587
+ /**
588
+ * Returns the active rounds for the specified MatchX or Quiz game.
589
+ * Each round includes its events (matches/questions) along with the current user's selections and scores.
590
+ *
591
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
592
+ *
593
+ * **Response** `GamesApiResponse<GamePickRound[]>`:
594
+ * - `errCode` - 0 on success
595
+ * - `data` - Array of rounds, each containing:
596
+ * - `round_id`, `round_name` - Round identifier and display name
597
+ * - `open_date`, `last_bet_date` - Timestamps (ms) for round open and betting deadline
598
+ * - `is_active_now`, `is_resolved` - Round state flags
599
+ * - `round_status_id` - Round status: -1 (active), 2 (no more bets), 3 (all events resolved), 4 (round resolved)
600
+ * - `score_full_win`, `score_part_win`, `score_lost` - Scoring rules per prediction outcome
601
+ * - `user_score` - Current user's total score in this round
602
+ * - `user_placed_bet` - Whether the user has submitted predictions
603
+ * - `has_open_for_bet_events` - Whether there are events still open for betting
604
+ * - `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
605
+ *
606
+ * **Example**:
607
+ * ```
608
+ * _smartico.api.getGamePickActiveRounds({
609
+ * saw_template_id: 1083,
610
+ * }).then((result) => {
611
+ * console.log(result.data); // GamePickRound[]
612
+ * result.data.forEach(round => {
613
+ * console.log(round.round_name, round.events.length);
614
+ * });
615
+ * });
616
+ * ```
617
+ *
618
+ * **Visitor mode: not supported**
619
+ */
620
+ getGamePickActiveRounds(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
621
+ /**
622
+ * Returns a single active round for the specified MatchX or Quiz game.
623
+ * The round includes full event details with the current user's selections.
624
+ *
625
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
626
+ * @param props.round_id - The specific round to retrieve
627
+ *
628
+ * **Response** `GamesApiResponse<GamePickRound>`:
629
+ * - `errCode` - 0 on success
630
+ * - `data` - Single round object with the same structure as in `getGamePickActiveRounds`,
631
+ * including `events[]` with full event details, user selections, and resolution info
632
+ *
633
+ * **Example**:
634
+ * ```
635
+ * _smartico.api.getGamePickActiveRound({
636
+ * saw_template_id: 1083,
637
+ * round_id: 31652,
638
+ * }).then((result) => {
639
+ * console.log(result.data.round_name, result.data.events.length);
640
+ * console.log(result.data.user_score, result.data.user_placed_bet);
641
+ * });
642
+ * ```
643
+ *
644
+ * **Visitor mode: not supported**
645
+ */
646
+ getGamePickActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>>;
647
+ /**
648
+ * Returns the history of all rounds (including resolved ones) for the specified MatchX or Quiz game.
649
+ * Each round contains full event details with results and the current user's predictions.
650
+ *
651
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
652
+ *
653
+ * **Response** `GamesApiResponse<GamePickRound[]>`:
654
+ * - `errCode` - 0 on success
655
+ * - `data` - Array of rounds ordered by `round_row_id` descending (newest first).
656
+ * Each round has the same structure as in `getGamePickActiveRounds`, including resolved events
657
+ * with `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) and `resolution_score`
658
+ *
659
+ * **Example**:
660
+ * ```
661
+ * _smartico.api.getGamePickHistory({
662
+ * saw_template_id: 1083,
663
+ * }).then((result) => {
664
+ * result.data.forEach(round => {
665
+ * console.log(round.round_name, 'Score:', round.user_score, 'Resolved:', round.is_resolved);
666
+ * });
667
+ * });
668
+ * ```
669
+ *
670
+ * **Visitor mode: not supported**
671
+ */
672
+ getGamePickHistory(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
673
+ /**
674
+ * Returns the leaderboard for a specific round within a MatchX or Quiz game.
675
+ * Use `round_id = -1` (AllRoundsGameBoardID) to get the season/overall leaderboard across all rounds.
676
+ *
677
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
678
+ * @param props.round_id - The round to get the leaderboard for. Use -1 for overall/seasonal leaderboard
679
+ *
680
+ * **Response** `GamesApiResponse<GamePickRoundBoard>`:
681
+ * - `errCode` - 0 on success
682
+ * - `data` - Leaderboard object containing:
683
+ * - Round base fields (`round_id`, `round_name`, `open_date`, `last_bet_date`, etc.)
684
+ * - `users[]` - Ranked list of players, each with:
685
+ * - `ext_user_id`, `int_user_id` - User identifiers
686
+ * - `public_username`, `avatar_url` - Display info (usernames may be masked based on label settings)
687
+ * - `gp_position` - Leaderboard rank (null if not yet ranked)
688
+ * - `resolution_score` - Total score in this round
689
+ * - `full_wins_count`, `part_wins_count`, `lost_count` - Prediction outcome counts
690
+ * - `my_user` - Current user's entry (same fields as above), or null if user hasn't participated
691
+ *
692
+ * **Example**:
693
+ * ```
694
+ * _smartico.api.getGamePickBoard({
695
+ * saw_template_id: 1083,
696
+ * round_id: 31652,
697
+ * }).then((result) => {
698
+ * console.log('Top players:', result.data.users);
699
+ * console.log('My position:', result.data.my_user?.gp_position);
700
+ * });
701
+ * ```
702
+ *
703
+ * **Visitor mode: not supported**
704
+ */
705
+ getGamePickBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>>;
706
+ /**
707
+ * Submits score predictions for a round in a MatchX game.
708
+ * Sends the round object with user selections for all events at once.
709
+ * Each event must include `team1_user_selection` and `team2_user_selection` representing predicted scores.
710
+ * If the user hasn't placed bets before, one game attempt (spin) will be consumed.
711
+ * Predictions can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
712
+ *
713
+ * @param props.saw_template_id - The ID of the MatchX game template
714
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `getGamePickActiveRound`
715
+ * and modified with user predictions. Each event needs: `gp_event_id`, `team1_user_selection`, `team2_user_selection`
716
+ *
717
+ * **Response** `GamesApiResponse<GamePickRound>`:
718
+ * - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
719
+ * - `data` - Updated round with all events reflecting the submitted selections.
720
+ * `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
721
+ *
722
+ * **Example**:
723
+ * ```
724
+ * _smartico.api.getGamePickActiveRound({
725
+ * saw_template_id: 1190,
726
+ * round_id: 38665,
727
+ * }).then((roundData) => {
728
+ * const round = roundData.data;
729
+ * round.events = round.events.map(e => ({
730
+ * gp_event_id: e.gp_event_id,
731
+ * team1_user_selection: 1,
732
+ * team2_user_selection: 0,
733
+ * }));
734
+ * _smartico.api.submitGamePickSelection({
735
+ * saw_template_id: 1190,
736
+ * round: round,
737
+ * }).then((result) => {
738
+ * console.log(result.data.user_placed_bet); // true
739
+ * });
740
+ * });
741
+ * ```
742
+ *
743
+ * **Visitor mode: not supported**
744
+ */
745
+ submitGamePickSelection(props: GamePickRequestParams & {
746
+ round: Partial<GamePickRound>;
747
+ }): Promise<GamesApiResponse<GamePickRound>>;
748
+ /**
749
+ * Submits answers for a round in a Quiz game.
750
+ * Sends the round object with user answers for all events at once.
751
+ * Each event must include `user_selection` with the answer value (e.g. '1', '2', 'x', 'yes', 'no' — depending on the market type).
752
+ * If the user hasn't placed bets before, one game attempt (spin) will be consumed.
753
+ * Answers can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
754
+ *
755
+ * @param props.saw_template_id - The ID of the Quiz game template
756
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `getGamePickActiveRound`
757
+ * and modified with user answers. Each event needs: `gp_event_id`, `user_selection`
758
+ *
759
+ * **Response** `GamesApiResponse<GamePickRound>`:
760
+ * - `errCode` - 0 on success. Non-zero codes indicate errors (e.g. not enough points/attempts)
761
+ * - `data` - Updated round with all events reflecting the submitted answers.
762
+ * `user_placed_bet` will be `true`, `has_not_submitted_changes` will be `false`
763
+ *
764
+ * **Example**:
765
+ * ```
766
+ * _smartico.api.getGamePickActiveRound({
767
+ * saw_template_id: 1183,
768
+ * round_id: 37974,
769
+ * }).then((roundData) => {
770
+ * const round = roundData.data;
771
+ * round.events = round.events.map(e => ({
772
+ * gp_event_id: e.gp_event_id,
773
+ * user_selection: 'x',
774
+ * }));
775
+ * _smartico.api.submitGamePickSelectionQuiz({
776
+ * saw_template_id: 1183,
777
+ * round: round,
778
+ * }).then((result) => {
779
+ * console.log(result.data.user_placed_bet); // true
780
+ * });
781
+ * });
782
+ * ```
783
+ *
784
+ * **Visitor mode: not supported**
785
+ */
786
+ submitGamePickSelectionQuiz(props: GamePickRequestParams & {
787
+ round: Partial<GamePickRound>;
788
+ }): Promise<GamesApiResponse<GamePickRound>>;
789
+ /**
790
+ * Returns the current user's profile information within the specified MatchX or Quiz game.
791
+ * The user record is synced from the Smartico platform into the games DB (synced every 1 minute).
792
+ * If the user doesn't exist in the games DB yet, it will be created automatically on first call.
793
+ *
794
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
795
+ *
796
+ * **Response** `GamesApiResponse<GamePickUserInfo>`:
797
+ * - `errCode` - 0 on success
798
+ * - `data`:
799
+ * - `ext_user_id` - External user ID (Smartico internal numeric ID)
800
+ * - `int_user_id` - Internal user ID within the games system
801
+ * - `public_username` - Display name
802
+ * - `avatar_url` - User's avatar image URL
803
+ * - `last_wallet_sync_time` - Last time the user's balance was synced from Smartico
804
+ * - `ach_points_balance` - User's current points balance
805
+ * - `ach_gems_balance` - User's current gems balance
806
+ * - `ach_diamonds_balance` - User's current diamonds balance
807
+ * - `pubic_username_set` - Whether the user has set a custom username
808
+ *
809
+ * **Example**:
810
+ * ```
811
+ * _smartico.api.getGamePickUserInfo({
812
+ * saw_template_id: 1083,
813
+ * }).then((result) => {
814
+ * console.log(result.data.public_username, result.data.ach_points_balance);
815
+ * });
816
+ * ```
817
+ *
818
+ * **Visitor mode: not supported**
819
+ */
820
+ getGamePickUserInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickUserInfo>>;
821
+ /**
822
+ * Returns the game configuration and the list of all rounds for the specified MatchX or Quiz game.
823
+ * Includes the SAW template definition, label settings, and round metadata (without events).
824
+ *
825
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
826
+ *
827
+ * **Response** `GamesApiResponse<GamePickGameInfo>`:
828
+ * - `errCode` - 0 on success
829
+ * - `data`:
830
+ * - `sawTemplate` - Game template configuration including:
831
+ * - `saw_template_id`, `saw_game_type_id` (6 = MatchX/Quiz)
832
+ * - `saw_template_ui_definition` - UI settings (name, ranking options, ask_for_username, etc.)
833
+ * - `saw_buyin_type_id` - Cost type (1=Free, 2=Points, 3=Gems, 4=Diamonds, 5=Spins)
834
+ * - `buyin_cost_points` - Cost per attempt
835
+ * - `spin_count` - Available attempts for the current user
836
+ * - `allRounds[]` - List of all rounds (metadata only, no events), each with:
837
+ * - `round_id`, `round_name`, `round_description`
838
+ * - `open_date`, `last_bet_date` - Timestamps (ms)
839
+ * - `is_active_now`, `is_resolved`, `round_status_id`
840
+ * - `labelInfo` - Label/brand configuration and settings
841
+ *
842
+ * **Example**:
843
+ * ```
844
+ * _smartico.api.getGamePickGameInfo({
845
+ * saw_template_id: 1189,
846
+ * }).then((result) => {
847
+ * console.log(result.data.sawTemplate.saw_template_ui_definition.name);
848
+ * console.log('Rounds:', result.data.allRounds.length);
849
+ * console.log('Buy-in type:', result.data.sawTemplate.saw_buyin_type_id);
850
+ * });
851
+ * ```
852
+ *
853
+ * **Visitor mode: not supported**
854
+ */
855
+ getGamePickGameInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickGameInfo>>;
856
+ /**
857
+ * Returns translations for the MatchX/Quiz game UI.
858
+ * Translations are returned as a key-value map for the Gamification and RetentionGames areas,
859
+ * resolved to the current user's language.
860
+ *
861
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
862
+ *
863
+ * **Response** `GamesApiResponse<any>`:
864
+ * - `errCode` - 0 on success
865
+ * - `data`:
866
+ * - `translations` - Key-value map of translation strings (e.g. `rgSubmitSelection`, `rgLeaderboardTitle`, `quizConfirmAnswer`, etc.)
867
+ * - `hash_code` - Hash for cache invalidation
868
+ * - `lang_code` - Resolved language code (e.g. 'EN')
869
+ *
870
+ * **Example**:
871
+ * ```
872
+ * _smartico.api.getGamePickTranslations({
873
+ * saw_template_id: 1083,
874
+ * }).then((result) => {
875
+ * const tr = result.data.translations;
876
+ * console.log(tr.rgSubmitSelection); // "Submit selection"
877
+ * console.log(tr.rgLeaderboardTitle); // "Leaderboard"
878
+ * });
879
+ * ```
880
+ *
881
+ * **Visitor mode: not supported**
882
+ */
883
+ getGamePickTranslations(props: GamePickRequestParams): Promise<GamesApiResponse<any>>;
884
+ /**
885
+ * Returns round data with events and picks for a specific user (identified by their internal user ID).
886
+ * Useful for viewing another user's predictions from the leaderboard.
887
+ * The `int_user_id` can be obtained from the `getGamePickBoard` response (`users[].int_user_id`).
888
+ *
889
+ * @param props.saw_template_id - The ID of the MatchX or Quiz game template
890
+ * @param props.round_id - The round to get info for
891
+ * @param props.int_user_id - Internal user ID of the player whose predictions to view (from leaderboard data)
892
+ *
893
+ * **Response** `GamesApiResponse<GamePickRound>`:
894
+ * - `errCode` - 0 on success
895
+ * - `data` - Round object with the target user's selections.
896
+ * Same structure as `getGamePickActiveRound`, but `user_selection`/`team1_user_selection`/`team2_user_selection`
897
+ * fields on events reflect the specified user's picks instead of the current user's.
898
+ * Events also include `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) showing how each prediction was scored
899
+ *
900
+ * **Example**:
901
+ * ```
902
+ * _smartico.api.getGamePickRoundInfoForUser({
903
+ * saw_template_id: 1083,
904
+ * round_id: 31652,
905
+ * int_user_id: 65653810,
906
+ * }).then((result) => {
907
+ * result.data.events.forEach(e => {
908
+ * console.log(e.event_meta.team1_name, 'vs', e.event_meta.team2_name, '→', e.user_selection);
909
+ * });
910
+ * });
911
+ * ```
912
+ *
913
+ * **Visitor mode: not supported**
914
+ */
915
+ getGamePickRoundInfoForUser(props: GamePickRoundRequestParams & {
916
+ int_user_id: number;
917
+ }): Promise<GamesApiResponse<GamePickRound>>;
585
918
  private updateOnSpin;
586
919
  private reloadMiniGameTemplate;
587
920
  private updateMissions;
@@ -6,9 +6,11 @@ import { LeaderBoardPeriodType } from '../Leaderboard';
6
6
  import { AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, LiquidEntityData } from '../CustomSections';
7
7
  import { PrizeModifiers } from '../MiniGames/PrizeModifiers';
8
8
  import { InboxCategories } from '../Inbox/InboxCategories';
9
- import { RaffleDrawInstanceState, RaffleDrawTypeExecution } from '../Raffle';
9
+ import { RaffleDrawInstanceState, RaffleDrawTypeExecution, RaffleTicketCapVisualization } from '../Raffle';
10
10
  import { PointChangeSourceType } from '../ActivityLog/PointChangeSourceType';
11
11
  import { UserBalanceType } from '../ActivityLog/UserBalanceType';
12
+ import { SAWGPMarketType } from '../Quiz/MarketsType';
13
+ import { QuizAnswersValueType } from '../Quiz/MarketsAnswers';
12
14
  type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string;
13
15
  /**
14
16
  * TMiniGamePrize describes the information of prize in the array of prizes in the TMiniGameTemplate
@@ -380,6 +382,8 @@ export interface TTournament {
380
382
  min_scores_win?: number;
381
383
  /** When enabled, users who don’t meet the minimum qualifying score will be hidden from the Leaderboard */
382
384
  hide_leaderboard_min_scores?: boolean;
385
+ /** Total scores across all participants in the tournament */
386
+ total_scores?: number;
383
387
  }
384
388
  /**
385
389
  * TTournamentDetailed describes the information of the tournament item and includes list of participants, their scores and position in the tournament leaderboard
@@ -965,6 +969,10 @@ export interface TRaffle {
965
969
  * Then the list will always return 3 draws, no matter if the draws are already executed or they are in the future.
966
970
  */
967
971
  draws: TRaffleDraw[];
972
+ /**
973
+ * Ticket cap visualization
974
+ */
975
+ ticket_cap_visualization: RaffleTicketCapVisualization;
968
976
  }
969
977
  export interface TRaffleTicket {
970
978
  /**
@@ -1259,4 +1267,4 @@ export interface TRaffleOptinResponse {
1259
1267
  /** Optional error message */
1260
1268
  err_message?: string;
1261
1269
  }
1262
- export { SAWAcknowledgeTypeName, PrizeModifiers, SAWTemplateUI, InboxCategories, AchCustomSectionType, SAWAskForUsername, SAWGameLayout, PointChangeSourceType, UserBalanceType };
1270
+ export { SAWAcknowledgeTypeName, PrizeModifiers, SAWTemplateUI, InboxCategories, AchCustomSectionType, SAWAskForUsername, SAWGameLayout, PointChangeSourceType, UserBalanceType, SAWGPMarketType, QuizAnswersValueType };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Base/ClassId';
2
2
  export * from './ILogger';
3
3
  export * from './SmarticoAPI';
4
+ export * from './WSAPI/WSAPI';
4
5
  export * from './CookieStore';
5
6
  export * from './Analytics';
6
7
  export * from './Core';
@@ -19,3 +20,4 @@ export * from './OCache';
19
20
  export * from './Bonuses';
20
21
  export * from './CustomSections';
21
22
  export * from './ActivityLog';
23
+ export * from './GamePick';