@smartico/public-api 0.0.355 → 0.0.357

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 (56) hide show
  1. package/README.md +33 -8
  2. package/dist/SmarticoAPI.d.ts +1 -1
  3. package/dist/WSAPI/WSAPI.d.ts +27 -56
  4. package/dist/WSAPI/WSAPITypes.d.ts +515 -32
  5. package/dist/index.d.ts +0 -1
  6. package/dist/index.js +92 -231
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.modern.mjs +27 -159
  9. package/dist/index.modern.mjs.map +1 -1
  10. package/docs/api/README.md +27 -0
  11. package/docs/api/classes/WSAPI.md +37 -57
  12. package/docs/api/enums/GPRoundStatus.md +43 -0
  13. package/docs/api/enums/GamePickMarketType.md +19 -0
  14. package/docs/api/enums/GamePickResolutionType.md +35 -0
  15. package/docs/api/enums/GamePickScoreType.md +19 -0
  16. package/docs/api/enums/GamePickSportType.md +375 -0
  17. package/docs/api/enums/GameRoundOrderType.md +35 -0
  18. package/docs/api/enums/PointChangeSourceType.md +6 -0
  19. package/docs/api/interfaces/AchRelatedGame-1.md +1 -1
  20. package/docs/api/interfaces/BonusTemplateMetaMap.md +1 -1
  21. package/docs/api/interfaces/GamePickBoardUser.md +75 -0
  22. package/docs/api/interfaces/GamePickEvent.md +121 -0
  23. package/docs/api/interfaces/GamePickEventMeta.md +181 -0
  24. package/docs/api/interfaces/GamePickGameInfo.md +27 -0
  25. package/docs/api/interfaces/GamePickRequestParams.md +41 -0
  26. package/docs/api/interfaces/GamePickRound.md +385 -0
  27. package/docs/api/interfaces/GamePickRoundBase.md +235 -0
  28. package/docs/api/interfaces/GamePickRoundBoard.md +361 -0
  29. package/docs/api/interfaces/GamePickRoundPublicMeta.md +103 -0
  30. package/docs/api/interfaces/GamePickRoundRequestParams.md +65 -0
  31. package/docs/api/interfaces/GamePickUserInfo.md +107 -0
  32. package/docs/api/interfaces/GamesApiResponse.md +33 -0
  33. package/docs/api/interfaces/QuizEventMeta.md +41 -0
  34. package/docs/api/interfaces/TInboxMessageBody.md +1 -1
  35. package/docs/api/interfaces/TLevel.md +1 -1
  36. package/docs/api/interfaces/TLevelCurrent.md +1 -1
  37. package/docs/api/interfaces/TMiniGamePrize.md +1 -1
  38. package/docs/api/interfaces/TMiniGameTemplate.md +2 -2
  39. package/docs/api/interfaces/TMissionOrBadge.md +2 -2
  40. package/docs/api/interfaces/TRaffle.md +2 -2
  41. package/docs/api/interfaces/TRaffleDraw.md +14 -2
  42. package/docs/api/interfaces/TRaffleDrawRun.md +20 -0
  43. package/docs/api/interfaces/TRafflePrize.md +1 -1
  44. package/docs/api/interfaces/TStoreItem.md +3 -3
  45. package/docs/api/interfaces/TTournament.md +4 -4
  46. package/docs/api/interfaces/TTournamentDetailed.md +4 -4
  47. package/docs/api/interfaces/TUICustomSection.md +1 -1
  48. package/package.json +6 -6
  49. package/src/SmarticoAPI.ts +1 -1
  50. package/src/WSAPI/WSAPI.ts +27 -63
  51. package/src/WSAPI/WSAPITypes.ts +525 -32
  52. package/src/index.ts +1 -2
  53. package/dist/GamePick/GPTypes.d.ts +0 -268
  54. package/dist/GamePick/index.d.ts +0 -1
  55. package/src/GamePick/GPTypes.ts +0 -277
  56. package/src/GamePick/index.ts +0 -1
package/README.md CHANGED
@@ -122,19 +122,44 @@ npm install --save @smartico/public-api
122
122
 
123
123
  ### Usage
124
124
 
125
+ `WSAPI` provides a high-level interface on top of `SmarticoAPI`. Create a `SmarticoAPI` instance with a custom `messageSender`, then create `WSAPI` instances bound to specific users:
126
+
125
127
  ```typescript
126
- import { SmarticoAPI } from '@smartico/public-api';
128
+ import { SmarticoAPI, WSAPI } from '@smartico/public-api';
129
+
130
+ // publicApiUrl is resolved automatically by SmarticoAPI from your label key
131
+ const messageSender = async (message: any, publicApiUrl?: string): Promise<any> => {
132
+ const res = await fetch(publicApiUrl, {
133
+ method: 'POST',
134
+ headers: { 'Content-Type': 'application/json' },
135
+ body: JSON.stringify(message),
136
+ });
137
+ return res.ok ? res.json() : '';
138
+ };
139
+
140
+ const smarticoApi = new SmarticoAPI('your-label-api-key', 'your-brand-key', messageSender);
141
+
142
+ const userExtId = 'John1984';
143
+ const api = new WSAPI(smarticoApi, userExtId);
144
+
145
+ const missions = await api.getMissions();
146
+ missions.forEach(m => {
147
+ console.log(m.name, m.is_completed);
148
+ });
127
149
 
128
- const SAPI = new SmarticoAPI( 'your-label-api-key', 'your-brand-key', 'your-message-sender', { logger: console });
150
+ const optInResult = await api.requestMissionOptIn(missions[0].id);
151
+ console.log('Opt-in:', optInResult.err_code);
152
+ ```
129
153
 
130
- const userExtId = 'John1984'
131
-
132
- const response = await SAPI.miniGamesGetTemplates(userExtId);
154
+ For the full list of available methods, see the [WSAPI documentation](docs/api/classes/WSAPI.md).
133
155
 
134
- response.templates.forEach( t => {
135
- console.log(t.saw_template_ui_definition.name)
136
- }
156
+ You can also use `SmarticoAPI` directly for low-level protocol access:
137
157
 
158
+ ```typescript
159
+ const response = await smarticoApi.miniGamesGetTemplates(userExtId);
160
+ response.templates.forEach(t => {
161
+ console.log(t.saw_template_ui_definition.name);
162
+ });
138
163
  ```
139
164
 
140
165
  ## Backend usage (http-protocol)
@@ -25,7 +25,7 @@ import { InboxCategories } from './Inbox/InboxCategories';
25
25
  import { GetDrawRunResponse, GetRaffleDrawRunsHistoryResponse, RaffleClaimPrizeResponse, RaffleOptinResponse } from './Raffle';
26
26
  import { GetJackpotWinnersResponse, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
27
27
  import { GetJackpotEligibleGamesResponse, TGetJackpotEligibleGamesResponse } from './Jackpots/GetJackpotEligibleGamesResponse';
28
- import { GamesApiResponse, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamePickGameInfo } from './GamePick';
28
+ import { GamesApiResponse, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamePickGameInfo } from './WSAPI/WSAPITypes';
29
29
  interface Tracker {
30
30
  label_api_key: string;
31
31
  userPublicProps: any;
@@ -1,7 +1,6 @@
1
1
  import { ActivityTypeLimited } from '../Core';
2
2
  import { SmarticoAPI } from '../SmarticoAPI';
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';
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, GamesApiResponse, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamePickGameInfo, GamePickRequestParams, GamePickRoundRequestParams } from './WSAPITypes';
5
4
  import { LeaderBoardPeriodType } from '../Leaderboard';
6
5
  import { JackpotDetails, JackpotWinnerHistory, JackpotsOptinResponse, JackpotsOptoutResponse } from '../Jackpots';
7
6
  import { GetRelatedAchTourResponse } from '../Missions/GetRelatedAchTourResponse';
@@ -605,7 +604,7 @@ export declare class WSAPI {
605
604
  *
606
605
  * **Example**:
607
606
  * ```
608
- * _smartico.api.getGamePickActiveRounds({
607
+ * _smartico.api.gamePickGetActiveRounds({
609
608
  * saw_template_id: 1083,
610
609
  * }).then((result) => {
611
610
  * console.log(result.data); // GamePickRound[]
@@ -617,7 +616,7 @@ export declare class WSAPI {
617
616
  *
618
617
  * **Visitor mode: not supported**
619
618
  */
620
- getGamePickActiveRounds(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
619
+ gamePickGetActiveRounds(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
621
620
  /**
622
621
  * Returns a single active round for the specified MatchX or Quiz game.
623
622
  * The round includes full event details with the current user's selections.
@@ -627,12 +626,12 @@ export declare class WSAPI {
627
626
  *
628
627
  * **Response** `GamesApiResponse<GamePickRound>`:
629
628
  * - `errCode` - 0 on success
630
- * - `data` - Single round object with the same structure as in `getGamePickActiveRounds`,
629
+ * - `data` - Single round object with the same structure as in `gamePickGetActiveRounds`,
631
630
  * including `events[]` with full event details, user selections, and resolution info
632
631
  *
633
632
  * **Example**:
634
633
  * ```
635
- * _smartico.api.getGamePickActiveRound({
634
+ * _smartico.api.gamePickGetActiveRound({
636
635
  * saw_template_id: 1083,
637
636
  * round_id: 31652,
638
637
  * }).then((result) => {
@@ -643,7 +642,7 @@ export declare class WSAPI {
643
642
  *
644
643
  * **Visitor mode: not supported**
645
644
  */
646
- getGamePickActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>>;
645
+ gamePickGetActiveRound(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRound>>;
647
646
  /**
648
647
  * Returns the history of all rounds (including resolved ones) for the specified MatchX or Quiz game.
649
648
  * Each round contains full event details with results and the current user's predictions.
@@ -653,12 +652,12 @@ export declare class WSAPI {
653
652
  * **Response** `GamesApiResponse<GamePickRound[]>`:
654
653
  * - `errCode` - 0 on success
655
654
  * - `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
655
+ * Each round has the same structure as in `gamePickGetActiveRounds`, including resolved events
657
656
  * with `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) and `resolution_score`
658
657
  *
659
658
  * **Example**:
660
659
  * ```
661
- * _smartico.api.getGamePickHistory({
660
+ * _smartico.api.gamePickGetHistory({
662
661
  * saw_template_id: 1083,
663
662
  * }).then((result) => {
664
663
  * result.data.forEach(round => {
@@ -669,7 +668,7 @@ export declare class WSAPI {
669
668
  *
670
669
  * **Visitor mode: not supported**
671
670
  */
672
- getGamePickHistory(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
671
+ gamePickGetHistory(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickRound[]>>;
673
672
  /**
674
673
  * Returns the leaderboard for a specific round within a MatchX or Quiz game.
675
674
  * Use `round_id = -1` (AllRoundsGameBoardID) to get the season/overall leaderboard across all rounds.
@@ -691,7 +690,7 @@ export declare class WSAPI {
691
690
  *
692
691
  * **Example**:
693
692
  * ```
694
- * _smartico.api.getGamePickBoard({
693
+ * _smartico.api.gamePickGetBoard({
695
694
  * saw_template_id: 1083,
696
695
  * round_id: 31652,
697
696
  * }).then((result) => {
@@ -702,7 +701,7 @@ export declare class WSAPI {
702
701
  *
703
702
  * **Visitor mode: not supported**
704
703
  */
705
- getGamePickBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>>;
704
+ gamePickGetBoard(props: GamePickRoundRequestParams): Promise<GamesApiResponse<GamePickRoundBoard>>;
706
705
  /**
707
706
  * Submits score predictions for a round in a MatchX game.
708
707
  * Sends the round object with user selections for all events at once.
@@ -711,7 +710,7 @@ export declare class WSAPI {
711
710
  * Predictions can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
712
711
  *
713
712
  * @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`
713
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `gamePickGetActiveRound`
715
714
  * and modified with user predictions. Each event needs: `gp_event_id`, `team1_user_selection`, `team2_user_selection`
716
715
  *
717
716
  * **Response** `GamesApiResponse<GamePickRound>`:
@@ -721,7 +720,7 @@ export declare class WSAPI {
721
720
  *
722
721
  * **Example**:
723
722
  * ```
724
- * _smartico.api.getGamePickActiveRound({
723
+ * _smartico.api.gamePickGetActiveRound({
725
724
  * saw_template_id: 1190,
726
725
  * round_id: 38665,
727
726
  * }).then((roundData) => {
@@ -731,7 +730,7 @@ export declare class WSAPI {
731
730
  * team1_user_selection: 1,
732
731
  * team2_user_selection: 0,
733
732
  * }));
734
- * _smartico.api.submitGamePickSelection({
733
+ * _smartico.api.gamePickSubmitSelection({
735
734
  * saw_template_id: 1190,
736
735
  * round: round,
737
736
  * }).then((result) => {
@@ -742,7 +741,7 @@ export declare class WSAPI {
742
741
  *
743
742
  * **Visitor mode: not supported**
744
743
  */
745
- submitGamePickSelection(props: GamePickRequestParams & {
744
+ gamePickSubmitSelection(props: GamePickRequestParams & {
746
745
  round: Partial<GamePickRound>;
747
746
  }): Promise<GamesApiResponse<GamePickRound>>;
748
747
  /**
@@ -753,7 +752,7 @@ export declare class WSAPI {
753
752
  * Answers can be edited until each match starts (if `allow_edit_answers` is enabled on the round).
754
753
  *
755
754
  * @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`
755
+ * @param props.round - Round object containing `round_id` and `events[]`. Typically obtained from `gamePickGetActiveRound`
757
756
  * and modified with user answers. Each event needs: `gp_event_id`, `user_selection`
758
757
  *
759
758
  * **Response** `GamesApiResponse<GamePickRound>`:
@@ -763,7 +762,7 @@ export declare class WSAPI {
763
762
  *
764
763
  * **Example**:
765
764
  * ```
766
- * _smartico.api.getGamePickActiveRound({
765
+ * _smartico.api.gamePickGetActiveRound({
767
766
  * saw_template_id: 1183,
768
767
  * round_id: 37974,
769
768
  * }).then((roundData) => {
@@ -772,7 +771,7 @@ export declare class WSAPI {
772
771
  * gp_event_id: e.gp_event_id,
773
772
  * user_selection: 'x',
774
773
  * }));
775
- * _smartico.api.submitGamePickSelectionQuiz({
774
+ * _smartico.api.gamePickSubmitSelectionQuiz({
776
775
  * saw_template_id: 1183,
777
776
  * round: round,
778
777
  * }).then((result) => {
@@ -783,7 +782,7 @@ export declare class WSAPI {
783
782
  *
784
783
  * **Visitor mode: not supported**
785
784
  */
786
- submitGamePickSelectionQuiz(props: GamePickRequestParams & {
785
+ gamePickSubmitSelectionQuiz(props: GamePickRequestParams & {
787
786
  round: Partial<GamePickRound>;
788
787
  }): Promise<GamesApiResponse<GamePickRound>>;
789
788
  /**
@@ -808,7 +807,7 @@ export declare class WSAPI {
808
807
  *
809
808
  * **Example**:
810
809
  * ```
811
- * _smartico.api.getGamePickUserInfo({
810
+ * _smartico.api.gamePickGetUserInfo({
812
811
  * saw_template_id: 1083,
813
812
  * }).then((result) => {
814
813
  * console.log(result.data.public_username, result.data.ach_points_balance);
@@ -817,7 +816,7 @@ export declare class WSAPI {
817
816
  *
818
817
  * **Visitor mode: not supported**
819
818
  */
820
- getGamePickUserInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickUserInfo>>;
819
+ gamePickGetUserInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickUserInfo>>;
821
820
  /**
822
821
  * Returns the game configuration and the list of all rounds for the specified MatchX or Quiz game.
823
822
  * Includes the SAW template definition, label settings, and round metadata (without events).
@@ -841,7 +840,7 @@ export declare class WSAPI {
841
840
  *
842
841
  * **Example**:
843
842
  * ```
844
- * _smartico.api.getGamePickGameInfo({
843
+ * _smartico.api.gamePickGetGameInfo({
845
844
  * saw_template_id: 1189,
846
845
  * }).then((result) => {
847
846
  * console.log(result.data.sawTemplate.saw_template_ui_definition.name);
@@ -852,39 +851,11 @@ export declare class WSAPI {
852
851
  *
853
852
  * **Visitor mode: not supported**
854
853
  */
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>>;
854
+ gamePickGetGameInfo(props: GamePickRequestParams): Promise<GamesApiResponse<GamePickGameInfo>>;
884
855
  /**
885
856
  * Returns round data with events and picks for a specific user (identified by their internal user ID).
886
857
  * 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`).
858
+ * The `int_user_id` can be obtained from the `gamePickGetBoard` response (`users[].int_user_id`).
888
859
  *
889
860
  * @param props.saw_template_id - The ID of the MatchX or Quiz game template
890
861
  * @param props.round_id - The round to get info for
@@ -893,13 +864,13 @@ export declare class WSAPI {
893
864
  * **Response** `GamesApiResponse<GamePickRound>`:
894
865
  * - `errCode` - 0 on success
895
866
  * - `data` - Round object with the target user's selections.
896
- * Same structure as `getGamePickActiveRound`, but `user_selection`/`team1_user_selection`/`team2_user_selection`
867
+ * Same structure as `gamePickGetActiveRound`, but `user_selection`/`team1_user_selection`/`team2_user_selection`
897
868
  * fields on events reflect the specified user's picks instead of the current user's.
898
869
  * Events also include `resolution_type_id` (0=None, 2=Lost, 3=PartialWin, 4=FullWin) showing how each prediction was scored
899
870
  *
900
871
  * **Example**:
901
872
  * ```
902
- * _smartico.api.getGamePickRoundInfoForUser({
873
+ * _smartico.api.gamePickGetRoundInfoForUser({
903
874
  * saw_template_id: 1083,
904
875
  * round_id: 31652,
905
876
  * int_user_id: 65653810,
@@ -912,7 +883,7 @@ export declare class WSAPI {
912
883
  *
913
884
  * **Visitor mode: not supported**
914
885
  */
915
- getGamePickRoundInfoForUser(props: GamePickRoundRequestParams & {
886
+ gamePickGetRoundInfoForUser(props: GamePickRoundRequestParams & {
916
887
  int_user_id: number;
917
888
  }): Promise<GamesApiResponse<GamePickRound>>;
918
889
  private updateOnSpin;