@smartico/public-api 0.0.142 → 0.0.144

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 (42) hide show
  1. package/README.md +14 -1
  2. package/dist/CustomSections/AchCustomSection.d.ts +27 -0
  3. package/dist/CustomSections/GetCustomSectionsRequest.d.ts +3 -0
  4. package/dist/CustomSections/GetCustomSectionsResponse.d.ts +7 -0
  5. package/dist/CustomSections/UICustomSection.d.ts +15 -0
  6. package/dist/CustomSections/index.d.ts +4 -0
  7. package/dist/Missions/AchievementPublicMeta.d.ts +1 -0
  8. package/dist/Missions/UserAchievement.d.ts +1 -0
  9. package/dist/Quiz/MarketsAnswers.d.ts +38 -0
  10. package/dist/Quiz/MarketsInfo.d.ts +4 -12
  11. package/dist/Quiz/MarketsPerSport.d.ts +4 -4
  12. package/dist/Quiz/MarketsType.d.ts +1 -1
  13. package/dist/Quiz/index.d.ts +1 -1
  14. package/dist/SmarticoAPI.d.ts +4 -1
  15. package/dist/WSAPI/WSAPI.d.ts +22 -1
  16. package/dist/WSAPI/WSAPITypes.d.ts +25 -0
  17. package/dist/index.js +310 -203
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.modern.mjs +199 -109
  20. package/dist/index.modern.mjs.map +1 -1
  21. package/docs/README.md +1 -0
  22. package/docs/classes/WSAPI.md +28 -0
  23. package/docs/interfaces/TMissionOrBadge.md +8 -0
  24. package/docs/interfaces/TUICustomSection.md +81 -0
  25. package/package.json +1 -1
  26. package/src/Core/CoreUtils.ts +2 -2
  27. package/src/CustomSections/AchCustomSection.ts +30 -0
  28. package/src/CustomSections/GetCustomSectionsRequest.ts +5 -0
  29. package/src/CustomSections/GetCustomSectionsResponse.ts +7 -0
  30. package/src/CustomSections/UICustomSection.ts +34 -0
  31. package/src/CustomSections/index.ts +4 -0
  32. package/src/Missions/AchievementPublicMeta.ts +1 -0
  33. package/src/Missions/UserAchievement.ts +3 -1
  34. package/src/Quiz/MarketsAnswers.ts +40 -0
  35. package/src/Quiz/MarketsInfo.ts +50 -59
  36. package/src/Quiz/MarketsPerSport.ts +29 -29
  37. package/src/Quiz/MarketsType.ts +1 -1
  38. package/src/Quiz/index.ts +1 -1
  39. package/src/SmarticoAPI.ts +12 -2
  40. package/src/WSAPI/WSAPI.ts +26 -1
  41. package/src/WSAPI/WSAPITypes.ts +27 -0
  42. package/src/Quiz/MarketsAnswersType.ts +0 -22
package/README.md CHANGED
@@ -13,7 +13,7 @@ and for terms of API usage
13
13
 
14
14
  To use the API you need the smartico.js library installed and initialized on your site according to this guide https://help.smartico.ai/welcome/technical-guides/front-end-integration
15
15
 
16
- As soon as the _smartico object is available in the global context and the user is identified, you can call API methods to get the data or act on behalf of the logged-in user.
16
+ As soon as the **_smartico** object is available in the global context of the browser window and the user is identified, you can call API methods to get the data or act on behalf of the logged-in user.
17
17
 
18
18
  ```javascript
19
19
 
@@ -40,6 +40,19 @@ _smartico.api.getMiniGames( { onUpdate: miniGamesUpdates} ).then( games => {
40
40
 
41
41
  See the [API documentation](docs/classes/WSAPI.md) for all available methods and returning data.
42
42
 
43
+ ## Visitor mode
44
+
45
+ You can also get gamification data for the visitors (not authorized users).
46
+
47
+ Calls to the methods look similar, with the only exception that you need to use **_smartico.vapi('EN')** method in order to get access to the Visitor API object with specific language.
48
+
49
+ ```javascript
50
+
51
+ _smartico.vapi('EN').getLevels().then( levels => {
52
+ console.log('There are ' + levels.length + ' levels available');
53
+ });
54
+
55
+ ```
43
56
 
44
57
  ## Backend usage (NodeJS context)
45
58
 
@@ -0,0 +1,27 @@
1
+ export declare enum AchCustomSectionType {
2
+ HTML_PAGE = 1,
3
+ MISSIONS_CATEGORY = 2,
4
+ TOURNAMENTS_CATEGORY = 3,
5
+ LEVELS = 4,
6
+ MINI_GAMES = 5,
7
+ MISSION_CUSTOM_LAYOUT = 6,
8
+ MATCH_X = 7
9
+ }
10
+ export declare enum AchCustomLayoutTheme {
11
+ VALENTINES_LIGHT = "valentines-light",
12
+ VALENTINES_DARK = "valentines-dark",
13
+ EURO_2024 = "euro-2024",
14
+ GENERIC = "generic"
15
+ }
16
+ export declare enum AchMissionsTabsOptions {
17
+ ONLY_OVERVIEW = 1,
18
+ NO_OVERVIEW = 2,
19
+ ALL = 3
20
+ }
21
+ export declare enum AchOverviewMissionsFilter {
22
+ ANY = 1,
23
+ ALL_MISSIONS = 2,
24
+ ALL_EXCEPT_COMPLETED = 3,
25
+ ALL_EXCEPT_LOCKED = 4,
26
+ ALL_EXCEPT_COMPLETED_AND_LOCKED = 5
27
+ }
@@ -0,0 +1,3 @@
1
+ import { ProtocolMessage } from "../Base/ProtocolMessage";
2
+ export interface GetCustomSectionsRequest extends ProtocolMessage {
3
+ }
@@ -0,0 +1,7 @@
1
+ import { ProtocolResponse } from "../Base/ProtocolResponse";
2
+ import { UICustomSection } from "./UICustomSection";
3
+ export interface GetCustomSectionsResponse extends ProtocolResponse {
4
+ customSections: {
5
+ [key: string]: UICustomSection;
6
+ };
7
+ }
@@ -0,0 +1,15 @@
1
+ import { TUICustomSection } from "../WSAPI/WSAPITypes";
2
+ import { AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter } from "./AchCustomSection";
3
+ export interface UICustomSection {
4
+ body?: string;
5
+ menu_img?: string;
6
+ menu_name?: string;
7
+ custom_skin_images?: string;
8
+ section_type_id?: AchCustomSectionType;
9
+ theme?: AchCustomLayoutTheme;
10
+ generic_custom_css?: string;
11
+ mission_tabs_options?: AchMissionsTabsOptions;
12
+ overview_missions_filter?: AchOverviewMissionsFilter;
13
+ overview_missions_count?: number;
14
+ }
15
+ export declare const UICustomSectionTransform: (items: UICustomSection[]) => TUICustomSection[];
@@ -0,0 +1,4 @@
1
+ export * from './AchCustomSection';
2
+ export * from './UICustomSection';
3
+ export * from './GetCustomSectionsRequest';
4
+ export * from './GetCustomSectionsResponse';
@@ -17,4 +17,5 @@ export interface AchievementPublicMeta {
17
17
  hint_text?: string;
18
18
  hide_badge_from_ui?: boolean;
19
19
  show_badge_first_task_completed?: boolean;
20
+ custom_section_type_id?: number;
20
21
  }
@@ -34,5 +34,6 @@ export interface UserAchievement {
34
34
  completed_today?: boolean;
35
35
  completed_this_week?: boolean;
36
36
  completed_this_month?: boolean;
37
+ custom_section_type_id?: number;
37
38
  }
38
39
  export declare const UserAchievementTransform: (items: UserAchievement[]) => TMissionOrBadge[];
@@ -0,0 +1,38 @@
1
+ export declare enum QuizAnswersValueType {
2
+ HomeTeam = "1",
3
+ AwayTeam = "2",
4
+ Draw = "x",
5
+ HomeTeamHomeTeam = "1/1",
6
+ HomeTeamDraw = "1/x",
7
+ HomeTeamAwayTeam = "1/2",
8
+ DrawHomeTeam = "x/1",
9
+ DrawDraw = "x/x",
10
+ DrawAwayTeam = "x/2",
11
+ AwayTeamHomeTeam = "2/1",
12
+ AwayTeamDraw = "2/x",
13
+ AwayTeamAwayTeam = "2/2",
14
+ Yes = "yes",
15
+ No = "no",
16
+ Odd = "odd",
17
+ Even = "even",
18
+ HomeOdd = "1/odd",
19
+ HomeEven = "1/even",
20
+ AwayOdd = "2/odd",
21
+ AwayEven = "2/even"
22
+ }
23
+ export declare const quizAnswerHomeTeamReplacementText = "{quiz_home_team}";
24
+ export declare const quizAnswerAwayTeamReplacementText = "{quiz_away_team}";
25
+ export declare const quizDrawReplacementText = "{quiz_draw}";
26
+ export declare const quizYesReplacementText = "{yes}";
27
+ export declare const quizNoReplacementText = "{no}";
28
+ export declare const quizOddReplacementText = "{odd}";
29
+ export declare const quizEvenReplacementText = "{even}";
30
+ export declare const quizOrReplacementText = "{or}";
31
+ export declare const quizAnswersTrKeys: {
32
+ "{quiz_draw}": string;
33
+ "{yes}": string;
34
+ "{no}": string;
35
+ "{odd}": string;
36
+ "{even}": string;
37
+ "{or}": string;
38
+ };
@@ -1,15 +1,7 @@
1
- import { MarketsValueType } from "./MarketsAnswersType";
2
- import { QuizMarketType } from "./MarketsType";
3
- export declare const quizAnswerHomeTeamReplacementText = "{quiz_home_team}";
4
- export declare const quizAnswerAwayTeamReplacementText = "{quiz_away_team}";
5
- export declare const quizDrawReplacementText = "{quiz_draw}";
6
- export declare const quizYesReplacementText = "{yes}";
7
- export declare const quizNoReplacementText = "{no}";
8
- export declare const quizOddReplacementText = "{odd}";
9
- export declare const quizEvenReplacementText = "{even}";
10
- export declare const quizOrReplacementText = "{or}";
1
+ import { QuizAnswersValueType } from "./MarketsAnswers";
2
+ import { SAWGPMarketType } from "./MarketsType";
11
3
  export declare const marketsInfo: {
12
- type: QuizMarketType;
4
+ type: SAWGPMarketType;
13
5
  name: string;
14
6
  question: {
15
7
  text: string;
@@ -17,6 +9,6 @@ export declare const marketsInfo: {
17
9
  };
18
10
  answers: {
19
11
  text: string;
20
- value: MarketsValueType;
12
+ value: QuizAnswersValueType;
21
13
  }[];
22
14
  }[];
@@ -1,6 +1,6 @@
1
- import { QuizMarketType } from "./MarketsType";
1
+ import { SAWGPMarketType } from "./MarketsType";
2
2
  export declare const QuizMarketPerSport: {
3
- 6: QuizMarketType[];
4
- 1: QuizMarketType[];
5
- 5: QuizMarketType[];
3
+ 6: SAWGPMarketType[];
4
+ 1: SAWGPMarketType[];
5
+ 5: SAWGPMarketType[];
6
6
  };
@@ -1,4 +1,4 @@
1
- export declare enum QuizMarketType {
1
+ export declare enum SAWGPMarketType {
2
2
  TwoTeamsWithScore = 1,
3
3
  RedCard = 2,
4
4
  OneXTwo = 3,
@@ -3,4 +3,4 @@ export * from './MarketsType';
3
3
  export * from './ScoreResultTypes';
4
4
  export * from './MarketsInfo';
5
5
  export * from './MarketsPerSport';
6
- export * from './MarketsAnswersType';
6
+ export * from './MarketsAnswers';
@@ -11,9 +11,10 @@ import { GetTournamentInfoResponse, GetTournamentsResponse, TournamentRegisterRe
11
11
  import { LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
12
12
  import { GetLevelMapResponse } from "./Level";
13
13
  import { WSAPI } from "./WSAPI/WSAPI";
14
- import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult } from "./WSAPI/WSAPITypes";
14
+ import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult, TUICustomSection } from "./WSAPI/WSAPITypes";
15
15
  import { GetAchievementsUserInfoResponse } from "./Core/GetAchievementsUserInfoResponse";
16
16
  import { GetJackpotsPotsResponse, GetJackpotsResponse, JackpotsOptinResponse, JackpotsOptoutResponse } from "./Jackpots";
17
+ import { GetCustomSectionsResponse } from "./CustomSections";
17
18
  interface Tracker {
18
19
  label_api_key: string;
19
20
  userPublicProps: any;
@@ -101,6 +102,8 @@ declare class SmarticoAPI {
101
102
  leaderboardsGetT(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean): Promise<LeaderBoardDetailsT>;
102
103
  levelsGet(user_ext_id: string, force_language?: string): Promise<GetLevelMapResponse>;
103
104
  levelsGetT(user_ext_id: string): Promise<TLevel[]>;
105
+ getCustomSections(user_ext_id: string): Promise<GetCustomSectionsResponse>;
106
+ getCustomSectionsT(user_ext_id: string): Promise<TUICustomSection[]>;
104
107
  getTranslationsT(user_ext_id: string, lang_code: string, areas: TranslationArea[], cacheSec?: number): Promise<GetTranslationsResponse>;
105
108
  getInboxMessages(user_ext_id: string, limit: number, offset: number, starred_only: boolean): Promise<GetInboxMessagesResponse>;
106
109
  getInboxMessagesT(user_ext_id: string, from?: number, to?: number, favoriteOnly?: boolean): Promise<TInboxMessage[]>;
@@ -1,5 +1,5 @@
1
1
  import { SmarticoAPI } from "../SmarticoAPI";
2
- import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
2
+ import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUICustomSection, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
3
3
  import { LeaderBoardPeriodType } from "../Leaderboard";
4
4
  import { JackpotDetails, JackpotsOptinResponse, JackpotsOptoutResponse } from "../Jackpots";
5
5
  /** @group General API */
@@ -116,6 +116,7 @@ export declare class WSAPI {
116
116
  * _smartico.vapi('EN').getStoreItems().then((result) => {
117
117
  * console.log(result);
118
118
  * });
119
+ * ```
119
120
  */
120
121
  getStoreItems(): Promise<TStoreItem[]>;
121
122
  /** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
@@ -145,6 +146,7 @@ export declare class WSAPI {
145
146
  * _smartico.vapi('EN').getStoreCategories().then((result) => {
146
147
  * console.log(result);
147
148
  * });
149
+ * ```
148
150
  */
149
151
  getStoreCategories(): Promise<TStoreCategory[]>;
150
152
  /**
@@ -185,6 +187,25 @@ export declare class WSAPI {
185
187
  *
186
188
  * */
187
189
  getAchCategories(): Promise<TAchCategory[]>;
190
+ /**
191
+ * Returns list of custom sections
192
+ *
193
+ * **Example**:
194
+ * ```
195
+ * _smartico.api.getCustomSections().then((result) => {
196
+ * console.log(result);
197
+ * });
198
+ * ```
199
+ *
200
+ * **Example in the Visitor mode**:
201
+ * ```
202
+ * _smartico.vapi('EN').getCustomSections().then((result) => {
203
+ * console.log(result);
204
+ * });
205
+ * ```
206
+ *
207
+ * */
208
+ getCustomSections(): Promise<TUICustomSection[]>;
188
209
  /**
189
210
  * Returns the list of mini-games available for user
190
211
  * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
@@ -2,6 +2,7 @@ import { BuyStoreItemErrorCode } from "../Store";
2
2
  import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWSpinErrorCode } from "../MiniGames";
3
3
  import { TournamentRegistrationError, TournamentRegistrationStatusName, TournamentRegistrationTypeName } from "../Tournaments";
4
4
  import { LeaderBoardPeriodType } from "../Leaderboard";
5
+ import { AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter } from "../CustomSections";
5
6
  type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string;
6
7
  /**
7
8
  * TMiniGamePrize describes the information of prize in the array of prizes in the TMiniGameTemplate
@@ -434,6 +435,8 @@ export interface TMissionOrBadge {
434
435
  completed_this_week?: boolean;
435
436
  /** Flag for mission/badge indicating that mission/badge completed this month */
436
437
  completed_this_month?: boolean;
438
+ /** ID of specific Custom Section type */
439
+ custom_section_type_id?: number;
437
440
  }
438
441
  export interface AchRelatedGame {
439
442
  /** The ID of the related game */
@@ -586,4 +589,26 @@ export interface TSegmentCheckResult {
586
589
  segment_id: number;
587
590
  is_matching: boolean;
588
591
  }
592
+ export interface TUICustomSection {
593
+ /** The body of the custom section */
594
+ body?: string;
595
+ /** The image of the custom section */
596
+ menu_img?: string;
597
+ /** The name of the custom section */
598
+ menu_name?: string;
599
+ /** Custom images for custom section */
600
+ custom_skin_images?: string;
601
+ /** The particular type of custom section, can be Missions, Tournaments, Lootbox and etc */
602
+ section_type_id?: AchCustomSectionType;
603
+ /** Theme of the custom section */
604
+ theme?: AchCustomLayoutTheme;
605
+ /** Custom css for the custom section */
606
+ generic_custom_css?: string;
607
+ /** Tabs that can be shown in custom section, e.g Overview, No Overview, All tabs */
608
+ mission_tabs_options?: AchMissionsTabsOptions;
609
+ /** Filter that allow to show missions by criteria */
610
+ overview_missions_filter?: AchOverviewMissionsFilter;
611
+ /** Quantity of missions to be shown in overview */
612
+ overview_missions_count?: number;
613
+ }
589
614
  export {};