@smartico/public-api 0.0.46 → 0.0.48

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/.nvmrc CHANGED
@@ -1 +1 @@
1
- v13.13.0
1
+ v18.16.1
package/README.md CHANGED
@@ -1,20 +1,49 @@
1
1
  # Smartico Public API
2
- API allows you to build and manage Smartico Gamification context on behalf of the user. It can be used in the JS/TS based frontend or in NodeJS backend
2
+ API allows you to build custom Gamification UI using smartico.ai as a backend system.
3
3
 
4
- # Installation
4
+
5
+ ```
6
+ Please contact your Smartico account manager to get the API keys
7
+ and for terms of API usage
8
+ ```
9
+
10
+
11
+
12
+ ## Front-end usage
13
+
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
+
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.
17
+
18
+ ```javascript
19
+
20
+ _smartico.api.levelsGet().then( levels => {
21
+ console.log('There are ' + levels.length + ' levels available');
22
+ });
23
+
24
+ ```
25
+
26
+ See the [API documentation](docs/classes/WSAPI.md) for all available methods and returning data.
27
+
28
+
29
+ ## Backend usage (NodeJS context)
30
+
31
+ ### Installation
5
32
 
6
33
  ```bash
7
34
  npm install --save @smartico/public-api
8
35
  ```
9
36
 
10
- ## Usage
37
+ ### Usage
11
38
 
12
39
  ```typescript
13
40
  import { SmarticoAPI } from '@smartico/public-api';
14
41
 
15
- const SAPI = new SmarticoAPI( 'your-label-api-key', 'your-brand-key', { logger: console });
42
+ const SAPI = new SmarticoAPI( 'your-label-api-key', 'your-brand-key', 'your-message-sender', { logger: console });
43
+
44
+ const userExtId = 'John1984'
16
45
 
17
- const response = await SAPI.miniGamesGetTemplates(rsUser.user_ext_id);
46
+ const response = await SAPI.miniGamesGetTemplates(userExtId);
18
47
 
19
48
  response.templates.forEach( t => {
20
49
  console.log(t.saw_template_ui_definition.name)
@@ -22,7 +51,6 @@ response.templates.forEach( t => {
22
51
 
23
52
  ```
24
53
 
25
-
26
54
  ## Development and publishing process
27
55
 
28
56
  ### Publishing process
@@ -34,9 +62,9 @@ npm version patch
34
62
  npm run pub
35
63
  ```
36
64
 
37
- ### Debug locally
65
+ ### To debug locally
38
66
 
39
- In the public-api project console:
67
+ In the public-api project:
40
68
 
41
69
  ```sh
42
70
  npm link
@@ -44,7 +72,7 @@ npm link
44
72
  npm unlink
45
73
  ```
46
74
 
47
- Consumer project console:
75
+ In the target project
48
76
  ```bash
49
77
  npm link @smartico/public-api --legacy-peer-deps
50
78
 
@@ -4,5 +4,6 @@ declare class IntUtils {
4
4
  static isNotEmpty(val: string): boolean;
5
5
  static replaceAll(value: string, regex: string, replacement: string | number): string;
6
6
  static escapeRegExp(v: string): string;
7
+ static JsonOrText: (str: string) => any;
7
8
  }
8
9
  export { IntUtils };
@@ -1,5 +1,7 @@
1
1
  import { ProtocolResponse } from "../Base/ProtocolResponse";
2
+ import { TLevel } from "../WSAPI/WSAPITypes";
2
3
  import { Level } from "./Level";
3
4
  export interface GetLevelMapResponse extends ProtocolResponse {
4
5
  levels: Level[];
5
6
  }
7
+ export declare const GetLevelMapResponseTransform: (levels: GetLevelMapResponse) => TLevel[];
@@ -1,3 +1,4 @@
1
+ import { TMissionOrBadge } from "../WSAPI/WSAPITypes";
1
2
  import { AchievementPublicMeta } from "./AchievementPublicMeta";
2
3
  import { AchievementStatus } from "./AchievementStatus";
3
4
  import { AchievementType } from "./AchievementType";
@@ -19,3 +20,4 @@ export interface UserAchievement {
19
20
  achievementTasks?: UserAchievementTask[];
20
21
  ach_status_id?: AchievementStatus;
21
22
  }
23
+ export declare const UserAchievementTransform: (items: UserAchievement[]) => TMissionOrBadge[];
@@ -10,12 +10,19 @@ import { GetAchievementMapResponse } from './Missions';
10
10
  import { GetTournamentInfoResponse, GetTournamentsResponse } from './Tournaments';
11
11
  import { LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
12
12
  import { GetLevelMapResponse } from "./Level";
13
+ import { WSAPI } from "./WSAPI/WSAPI";
14
+ import { TLevel, TMissionOrBadge } from "./WSAPI/WSAPITypes";
15
+ interface Tracker {
16
+ label_api_key: string;
17
+ userPublicProps: any;
18
+ }
13
19
  interface IOptions {
14
20
  logger?: ILogger;
15
21
  logCIDs?: ClassId[];
16
22
  logHTTPTiming?: boolean;
23
+ tracker?: Tracker;
17
24
  }
18
- type MessageSender = (message: any, publicApuUrl: string) => Promise<any>;
25
+ type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any>;
19
26
  declare class SmarticoAPI {
20
27
  private label_api_key;
21
28
  private brand_api_key;
@@ -23,10 +30,11 @@ declare class SmarticoAPI {
23
30
  private publicUrl;
24
31
  private wsUrl;
25
32
  private partnerUrl;
26
- private avatarDomain;
33
+ avatarDomain: string;
27
34
  private logger;
28
35
  private logCIDs;
29
36
  private logHTTPTiming;
37
+ tracker?: Tracker;
30
38
  constructor(label_api_key: string, brand_api_key: string, messageSender: MessageSender, options?: IOptions);
31
39
  static getEnvId(label_api_key: string): string;
32
40
  static getCleanLabelApiKey(label_api_key: string): string;
@@ -47,10 +55,13 @@ declare class SmarticoAPI {
47
55
  inboxGetMessages(user_ext_id: string, limit?: number, offset?: number): Promise<GetInboxMessagesResponse>;
48
56
  storeGetItems(user_ext_id: string): Promise<GetStoreItemsResponse>;
49
57
  missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse>;
58
+ missionsGetItemsT(user_ext_id?: string): Promise<TMissionOrBadge[]>;
50
59
  badgetsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse>;
51
60
  tournamentsGetLobby(user_ext_id: string): Promise<GetTournamentsResponse>;
52
61
  tournamentsGetInfo(user_ext_id: string, tournamentInstanceId: number): Promise<GetTournamentInfoResponse>;
53
62
  leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean): Promise<LeaderBoardDetails>;
54
- levelsGet(user_ext_id: string): Promise<GetLevelMapResponse>;
63
+ levelsGet(user_ext_id?: string): Promise<GetLevelMapResponse>;
64
+ levelsGetT(user_ext_id?: string): Promise<TLevel[]>;
65
+ getWSCalls(): WSAPI;
55
66
  }
56
67
  export { SmarticoAPI, MessageSender };
@@ -0,0 +1,14 @@
1
+ import { SmarticoAPI } from "../SmarticoAPI";
2
+ import { TLevel, TMissionOrBadge, TUserProfile } from "./WSAPITypes";
3
+ /** @group General API */
4
+ export declare class WSAPI {
5
+ private api;
6
+ /** @private */
7
+ constructor(api: SmarticoAPI);
8
+ /** Returns all the levels available the current user */
9
+ getUserProfile(): Promise<TUserProfile>;
10
+ /** Returns all the levels available the current user */
11
+ getLevels(): Promise<TLevel[]>;
12
+ /** Returns all the missions available the current user */
13
+ getMissions(): Promise<TMissionOrBadge[]>;
14
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * TUser interface describes the information of the user
3
+ * The user object is returned by _smartico.api.getUserProfile() method.
4
+ * If you want to track the changes of the user profile, you can subscribe to the callback in the following way
5
+ * _smartico.on('props_change', () => console.log(_smartico.api.getUserProfile()) );
6
+ */
7
+ export interface TUserProfile {
8
+ /** The language of the user */
9
+ core_user_language: string;
10
+ /** The current points balance that user can use in the Store, Mini-games, Tournaments, etc.. */
11
+ ach_points_balance: number;
12
+ /** The amount of points that user collected in total */
13
+ ach_points_ever: number;
14
+ /**
15
+ * The array of the public tags set on the user object.
16
+ * They can be treated as server-based cookies.
17
+ * You can set tags using following method _smartico.event('core_public_tags_update', { core_public_tags: ['A', 'B'] } );
18
+ * And then you can check for the tags
19
+ */
20
+ core_public_tags: string[];
21
+ /** The ID of the current level of the user */
22
+ ach_level_current_id?: number;
23
+ /** The indicator if user is marked as test user */
24
+ core_is_test_account?: boolean;
25
+ /** The URL to the user avatar */
26
+ avatar_url?: string;
27
+ /** The username of current user */
28
+ public_username?: string;
29
+ /** THe number of unread inbox messages */
30
+ core_inbox_unread_count?: number;
31
+ }
32
+ /**
33
+ * TLevel interface describes the information of each level defined in the system
34
+ * There is no order of the levels, but it can be calculated using required_points property
35
+ * The current level of user can be taken from the user object using ach_level_current_id property
36
+ * The progress to the next level can be calculated using ach_points_ever and required_points properties of next level
37
+ */
38
+ export interface TLevel {
39
+ /** The ID of the Level */
40
+ id: number;
41
+ /** The name of the Level, translated to the user language */
42
+ name: string;
43
+ /** The description of the Level, translated to the user language */
44
+ description: string;
45
+ /** The URL of the image of the Level */
46
+ image: string;
47
+ /** The amount of points required to reach the Level */
48
+ required_points: number;
49
+ /** Number of points that user should collect in order to see this level */
50
+ visibility_points: number;
51
+ /**
52
+ * The counter of 1st metric used to reach the Level.
53
+ * Relevant in case of using advanced leveling logic
54
+ * https://help.smartico.ai/welcome/more/release-notes/september-2022#new-logic-for-leveling-users
55
+ *
56
+ */
57
+ required_level_counter_1: number;
58
+ /**
59
+ * The counter of 2nd metric used to reach the Level.
60
+ * Relevant in case of using advanced leveling logic
61
+ * https://help.smartico.ai/welcome/more/release-notes/september-2022#new-logic-for-leveling-users
62
+ *
63
+ */
64
+ required_level_counter_2: number;
65
+ }
66
+ /**
67
+ * TMissionOrBadge interface describes the information of mission or badge defined in the system
68
+ */
69
+ export interface TMissionOrBadge {
70
+ /** ID of the mission or badge */
71
+ id: number;
72
+ /** Type of entity. Can be 'mission' or 'badge' */
73
+ type: 'mission' | 'badge';
74
+ /** Name of the mission or badge, translated to the user language */
75
+ name: string;
76
+ /** Description of the mission or badge, translated to the user language */
77
+ desription: string;
78
+ /** Description of the mission reward if defined */
79
+ reward: string;
80
+ /** URL of the image of the mission or badge */
81
+ image: string;
82
+ /** Indicator if the mission is completed or badge is granted */
83
+ is_completed: boolean;
84
+ /** Indicator if the mission is locked. Means that it's visible to the user, but he cannot progress in it until it's unlocked.
85
+ * Mission may optionally contain the explanation of what should be done to unlock it in the unlock_mission_description property
86
+ */
87
+ is_locked: boolean;
88
+ /** Optional explaination of what should be done to unlock the mission */
89
+ unlock_mission_description: string;
90
+ /** Indicator if the mission requires opt-in. Means that user should explicitly opt-in to the mission in order to start progressing in it */
91
+ is_requires_optin: boolean;
92
+ /** Indicator if the user opted-in to the mission */
93
+ is_opted_in: boolean;
94
+ /** The amount of time in milliseconds that user has to complete the mission */
95
+ time_limit_ms: number;
96
+ /** The date when the mission was started, relevant for the time limited missions */
97
+ dt_start: number;
98
+ /** The progress of the mission in percents calculated as the aggregated relative percentage of all tasks */
99
+ progress: number;
100
+ /**
101
+ * The action that should be performed when user clicks on the mission or badge
102
+ * Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.do(cta_action);
103
+ * The 'dp' function will handle the CTA and will execute it in the most safe way
104
+ */
105
+ cta_action: string;
106
+ /** The text of the CTA button, e.g. 'Make a deposit' */
107
+ cta_text: string;
108
+ /**
109
+ * The ID of the custom section where the mission or badge is assigned
110
+ * The list of custom sections can be retrieved using _smartico.api.getCustomSections() method (TODO-API)
111
+ */
112
+ custom_section_id: number;
113
+ /** The indicator if the mission or badge is visible only in the custom section and should be hidden from the main overview of missions/badges */
114
+ only_in_custom_section: boolean;
115
+ /** The custom data of the mission or badge defined by operator. Can be a JSON object, string or number */
116
+ custom_data: any;
117
+ /** The list of tasks of the mission or badge */
118
+ tasks: TMissionOrBadgeTask[];
119
+ }
120
+ /**
121
+ * TMissionOrBadgeTask interface describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
122
+ */
123
+ export interface TMissionOrBadgeTask {
124
+ /** ID of the task */
125
+ id: number;
126
+ /** Name of the task, translated to the user language */
127
+ name: string;
128
+ /** Indicator if the task is completed */
129
+ is_completed: boolean;
130
+ /** The progress of the task in percents */
131
+ progress: number;
132
+ }
package/dist/index.js CHANGED
@@ -154,6 +154,16 @@ var IntUtils = /*#__PURE__*/function () {
154
154
  };
155
155
  return IntUtils;
156
156
  }();
157
+ IntUtils.JsonOrText = function (str) {
158
+ if (str && str.includes && (str.includes('{') || str.includes('['))) {
159
+ try {
160
+ return JSON.parse(str);
161
+ } catch (e) {
162
+ return str;
163
+ }
164
+ }
165
+ return str;
166
+ };
157
167
 
158
168
  var _SAWBuyInTypeName;
159
169
  exports.SAWBuyInType = void 0;
@@ -430,6 +440,102 @@ exports.AchievementType = void 0;
430
440
  AchievementType[AchievementType["Badge"] = 2] = "Badge";
431
441
  })(exports.AchievementType || (exports.AchievementType = {}));
432
442
 
443
+ var UserAchievementTransform = function UserAchievementTransform(items) {
444
+ return items.filter(function (r) {
445
+ return r.ach_id >= 1;
446
+ }).map(function (r) {
447
+ return {
448
+ id: r.ach_id,
449
+ name: r.ach_public_meta.name,
450
+ desription: r.ach_public_meta.description,
451
+ unlock_mission_description: r.ach_public_meta.unlock_mission_description,
452
+ image: r.ach_public_meta.image_url,
453
+ is_completed: r.isCompleted,
454
+ is_locked: r.isLocked,
455
+ is_requires_optin: r.requiresOptin,
456
+ is_opted_in: r.isOptedIn,
457
+ time_limit_ms: r.time_limit_ms,
458
+ dt_start: r.start_date,
459
+ reward: r.ach_public_meta.reward,
460
+ progress: r.progress,
461
+ type: r.ach_type_id === exports.AchievementType.Mission ? 'mission' : 'badge',
462
+ cta_action: r.ach_public_meta.cta_action,
463
+ cta_text: r.ach_public_meta.cta_text,
464
+ custom_section_id: r.ach_public_meta.custom_section_id,
465
+ only_in_custom_section: r.ach_public_meta.only_in_custom_section,
466
+ custom_data: IntUtils.JsonOrText(r.ach_public_meta.custom_data),
467
+ tasks: (r.achievementTasks || []).filter(function (t) {
468
+ return t.task_type_id === exports.AchievementTaskType.CompleteAchievement;
469
+ }).map(function (t) {
470
+ var _t$task_public_meta;
471
+ return {
472
+ id: t.task_id,
473
+ name: (_t$task_public_meta = t.task_public_meta) == null ? void 0 : _t$task_public_meta.name,
474
+ is_completed: t.isCompleted,
475
+ progress: t.userProgress
476
+ };
477
+ })
478
+ };
479
+ });
480
+ };
481
+
482
+ var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels) {
483
+ return levels == null ? void 0 : levels.levels.map(function (l) {
484
+ return {
485
+ id: l.level_id,
486
+ name: l.level_public_meta.name,
487
+ description: l.level_public_meta.description,
488
+ image: l.level_public_meta.image_url,
489
+ required_points: l.required_points,
490
+ visibility_points: l.level_public_meta.visibility_points,
491
+ required_level_counter_1: l.required_level_counter_1,
492
+ required_level_counter_2: l.required_level_counter_2
493
+ };
494
+ });
495
+ };
496
+
497
+ /** @group General API */
498
+ var WSAPI = /*#__PURE__*/function () {
499
+ /** @private */
500
+ function WSAPI(api) {
501
+ this.api = void 0;
502
+ this.api = api;
503
+ }
504
+ /** Returns all the levels available the current user */
505
+ var _proto = WSAPI.prototype;
506
+ _proto.getUserProfile = function getUserProfile() {
507
+ try {
508
+ var _this = this;
509
+ if (_this.api.tracker) {
510
+ var o = Object.assign({}, _this.api.tracker.userPublicProps);
511
+ o.avatar_url = CoreUtils.avatarUrl(_this.api.tracker.userPublicProps.avatar_id, _this.api.avatarDomain);
512
+ return Promise.resolve(o);
513
+ } else {
514
+ throw new Error('Tracker is not initialized, cannot getUserProfile');
515
+ }
516
+ } catch (e) {
517
+ return Promise.reject(e);
518
+ }
519
+ } /** Returns all the levels available the current user */;
520
+ _proto.getLevels = function getLevels() {
521
+ try {
522
+ var _this2 = this;
523
+ return Promise.resolve(_this2.api.levelsGetT(null));
524
+ } catch (e) {
525
+ return Promise.reject(e);
526
+ }
527
+ } /** Returns all the missions available the current user */;
528
+ _proto.getMissions = function getMissions() {
529
+ try {
530
+ var _this3 = this;
531
+ return Promise.resolve(_this3.api.missionsGetItemsT(null));
532
+ } catch (e) {
533
+ return Promise.reject(e);
534
+ }
535
+ };
536
+ return WSAPI;
537
+ }();
538
+
433
539
  function _catch(body, recover) {
434
540
  try {
435
541
  var result = body();
@@ -447,6 +553,7 @@ var AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
447
553
  var DEFAULT_LANG_EN = "EN";
448
554
  var SmarticoAPI = /*#__PURE__*/function () {
449
555
  function SmarticoAPI(label_api_key, brand_api_key, messageSender, options) {
556
+ var _options$tracker;
450
557
  if (options === void 0) {
451
558
  options = {};
452
559
  }
@@ -460,6 +567,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
460
567
  this.logger = void 0;
461
568
  this.logCIDs = void 0;
462
569
  this.logHTTPTiming = void 0;
570
+ this.tracker = void 0;
463
571
  this.label_api_key = label_api_key;
464
572
  this.brand_api_key = brand_api_key;
465
573
  this.messageSender = messageSender;
@@ -469,9 +577,10 @@ var SmarticoAPI = /*#__PURE__*/function () {
469
577
  }
470
578
  this.logCIDs = options.logCIDs || [];
471
579
  this.logHTTPTiming = options.logHTTPTiming || false;
580
+ this.tracker = options.tracker;
472
581
  this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
473
582
  this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
474
- this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key);
583
+ this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || ((_options$tracker = options.tracker) == null ? void 0 : _options$tracker.label_api_key));
475
584
  this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key);
476
585
  }
477
586
  SmarticoAPI.getEnvId = function getEnvId(label_api_key) {
@@ -546,7 +655,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
546
655
  var result;
547
656
  var _temp = _catch(function () {
548
657
  var timeStart = new Date().getTime();
549
- return Promise.resolve(_this.messageSender(message, _this.publicUrl)).then(function (_this$messageSender) {
658
+ return Promise.resolve(_this.messageSender(message, _this.publicUrl, expectCID)).then(function (_this$messageSender) {
550
659
  result = _this$messageSender;
551
660
  var timeEnd = new Date().getTime();
552
661
  if (_this.logHTTPTiming) {
@@ -789,11 +898,21 @@ var SmarticoAPI = /*#__PURE__*/function () {
789
898
  return Promise.reject(e);
790
899
  }
791
900
  };
792
- _proto.badgetsGetItems = function badgetsGetItems(user_ext_id) {
901
+ _proto.missionsGetItemsT = function missionsGetItemsT(user_ext_id) {
793
902
  try {
794
903
  var _this12 = this;
795
- var message = _this12.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
796
- return Promise.resolve(_this12.send(message)).then(function (response) {
904
+ return Promise.resolve(_this12.missionsGetItems(user_ext_id)).then(function (_this12$missionsGetIt) {
905
+ return UserAchievementTransform(_this12$missionsGetIt.achievements);
906
+ });
907
+ } catch (e) {
908
+ return Promise.reject(e);
909
+ }
910
+ };
911
+ _proto.badgetsGetItems = function badgetsGetItems(user_ext_id) {
912
+ try {
913
+ var _this13 = this;
914
+ var message = _this13.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
915
+ return Promise.resolve(_this13.send(message)).then(function (response) {
797
916
  if (response.achievements) {
798
917
  response.achievements = response.achievements.filter(function (a) {
799
918
  return a.ach_type_id === exports.AchievementType.Badge;
@@ -807,27 +926,27 @@ var SmarticoAPI = /*#__PURE__*/function () {
807
926
  };
808
927
  _proto.tournamentsGetLobby = function tournamentsGetLobby(user_ext_id) {
809
928
  try {
810
- var _this13 = this;
811
- var message = _this13.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
812
- return Promise.resolve(_this13.send(message));
929
+ var _this14 = this;
930
+ var message = _this14.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
931
+ return Promise.resolve(_this14.send(message));
813
932
  } catch (e) {
814
933
  return Promise.reject(e);
815
934
  }
816
935
  };
817
936
  _proto.tournamentsGetInfo = function tournamentsGetInfo(user_ext_id, tournamentInstanceId) {
818
937
  try {
819
- var _this14 = this;
820
- var message = _this14.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_INFO_REQUEST, {
938
+ var _this15 = this;
939
+ var message = _this15.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_INFO_REQUEST, {
821
940
  tournamentInstanceId: tournamentInstanceId
822
941
  });
823
- return Promise.resolve(_this14.send(message)).then(function (response) {
942
+ return Promise.resolve(_this15.send(message)).then(function (response) {
824
943
  var _response$userPositio, _response$tournamentI;
825
944
  if ((_response$userPositio = response.userPosition) != null && _response$userPositio.avatar_id) {
826
- response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, _this14.avatarDomain);
945
+ response.userPosition.avatar_url = CoreUtils.avatarUrl(response.userPosition.avatar_id, _this15.avatarDomain);
827
946
  }
828
947
  if ((_response$tournamentI = response.tournamentInfo.players) != null && _response$tournamentI.length) {
829
948
  response.tournamentInfo.players.forEach(function (p) {
830
- p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this14.avatarDomain);
949
+ p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this15.avatarDomain);
831
950
  });
832
951
  }
833
952
  return response;
@@ -841,13 +960,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
841
960
  prevPeriod = false;
842
961
  }
843
962
  try {
844
- var _this15 = this;
845
- var message = _this15.buildMessage(user_ext_id, exports.ClassId.GET_LEADERS_BOARD_REQUEST, {
963
+ var _this16 = this;
964
+ var message = _this16.buildMessage(user_ext_id, exports.ClassId.GET_LEADERS_BOARD_REQUEST, {
846
965
  period_type_id: period_type_id,
847
966
  snapshot_offset: prevPeriod ? 1 : 0,
848
967
  include_users: true
849
968
  });
850
- return Promise.resolve(_this15.send(message)).then(function (response) {
969
+ return Promise.resolve(_this16.send(message)).then(function (response) {
851
970
  var _response$map$boardKe, _response$map$boardKe2, _response$map$boardKe3, _response$map$boardKe4;
852
971
  var boardKey = Object.keys(response.map).find(function (k) {
853
972
  return period_type_id === undefined || k === (period_type_id == null ? void 0 : period_type_id.toString());
@@ -856,11 +975,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
856
975
  return undefined;
857
976
  }
858
977
  if ((_response$map$boardKe = response.map[boardKey]) != null && (_response$map$boardKe2 = _response$map$boardKe.userPosition) != null && _response$map$boardKe2.avatar_id) {
859
- response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(response.map[boardKey].userPosition.avatar_id, _this15.avatarDomain);
978
+ response.map[boardKey].userPosition.avatar_url = CoreUtils.avatarUrl(response.map[boardKey].userPosition.avatar_id, _this16.avatarDomain);
860
979
  }
861
980
  if ((_response$map$boardKe3 = response.map[boardKey]) != null && (_response$map$boardKe4 = _response$map$boardKe3.positions) != null && _response$map$boardKe4.length) {
862
981
  response.map[boardKey].positions.forEach(function (p) {
863
- p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this15.avatarDomain);
982
+ p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this16.avatarDomain);
864
983
  });
865
984
  }
866
985
  return response.map[boardKey];
@@ -871,13 +990,24 @@ var SmarticoAPI = /*#__PURE__*/function () {
871
990
  };
872
991
  _proto.levelsGet = function levelsGet(user_ext_id) {
873
992
  try {
874
- var _this16 = this;
875
- var message = _this16.buildMessage(user_ext_id, exports.ClassId.GET_LEVEL_MAP_REQUEST);
876
- return Promise.resolve(_this16.send(message));
993
+ var _this17 = this;
994
+ var message = _this17.buildMessage(user_ext_id, exports.ClassId.GET_LEVEL_MAP_REQUEST);
995
+ return Promise.resolve(_this17.send(message, exports.ClassId.GET_LEVEL_MAP_RESPONSE));
877
996
  } catch (e) {
878
997
  return Promise.reject(e);
879
998
  }
880
999
  };
1000
+ _proto.levelsGetT = function levelsGetT(user_ext_id) {
1001
+ try {
1002
+ var _this18 = this;
1003
+ return Promise.resolve(_this18.levelsGet(user_ext_id)).then(GetLevelMapResponseTransform);
1004
+ } catch (e) {
1005
+ return Promise.reject(e);
1006
+ }
1007
+ };
1008
+ _proto.getWSCalls = function getWSCalls() {
1009
+ return new WSAPI(this);
1010
+ };
881
1011
  return SmarticoAPI;
882
1012
  }();
883
1013
 
@@ -1034,6 +1164,7 @@ TournamentUtils.isUpcoming = function (tournament) {
1034
1164
 
1035
1165
  exports.CookieStore = CookieStore;
1036
1166
  exports.CoreUtils = CoreUtils;
1167
+ exports.GetLevelMapResponseTransform = GetLevelMapResponseTransform;
1037
1168
  exports.SAWBuyInTypeName = SAWBuyInTypeName;
1038
1169
  exports.SAWGameTypeName = SAWGameTypeName;
1039
1170
  exports.SAWUtils = SAWUtils;
@@ -1041,4 +1172,5 @@ exports.SAWWinSoundFiles = SAWWinSoundFiles;
1041
1172
  exports.SmarticoAPI = SmarticoAPI;
1042
1173
  exports.TournamentInstanceStatusName = TournamentInstanceStatusName;
1043
1174
  exports.TournamentUtils = TournamentUtils;
1175
+ exports.UserAchievementTransform = UserAchievementTransform;
1044
1176
  //# sourceMappingURL=index.js.map