@smartico/public-api 0.0.47 → 0.0.49

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/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
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,10 +51,6 @@ response.templates.forEach( t => {
22
51
 
23
52
  ```
24
53
 
25
- ## API
26
- ### To learn more about the capabilities of our API, go to the [API documentation](docs_test/modules.md)
27
-
28
-
29
54
  ## Development and publishing process
30
55
 
31
56
  ### Publishing process
@@ -37,9 +62,9 @@ npm version patch
37
62
  npm run pub
38
63
  ```
39
64
 
40
- ### Debug locally
65
+ ### To debug locally
41
66
 
42
- In the public-api project console:
67
+ In the public-api project:
43
68
 
44
69
  ```sh
45
70
  npm link
@@ -47,7 +72,7 @@ npm link
47
72
  npm unlink
48
73
  ```
49
74
 
50
- Consumer project console:
75
+ In the target project
51
76
  ```bash
52
77
  npm link @smartico/public-api --legacy-peer-deps
53
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";
@@ -11,6 +12,7 @@ export interface UserAchievement {
11
12
  requiresOptin?: boolean;
12
13
  isOptedIn?: boolean;
13
14
  start_date?: string;
15
+ start_date_ts?: number;
14
16
  time_limit_ms?: number;
15
17
  progress?: number;
16
18
  complete_date?: string;
@@ -19,3 +21,4 @@ export interface UserAchievement {
19
21
  achievementTasks?: UserAchievementTask[];
20
22
  ach_status_id?: AchievementStatus;
21
23
  }
24
+ export declare const UserAchievementTransform: (items: UserAchievement[]) => TMissionOrBadge[];
@@ -11,10 +11,16 @@ import { GetTournamentInfoResponse, GetTournamentsResponse } from './Tournaments
11
11
  import { LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
12
12
  import { GetLevelMapResponse } from "./Level";
13
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
+ }
14
19
  interface IOptions {
15
20
  logger?: ILogger;
16
21
  logCIDs?: ClassId[];
17
22
  logHTTPTiming?: boolean;
23
+ tracker?: Tracker;
18
24
  }
19
25
  type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any>;
20
26
  declare class SmarticoAPI {
@@ -24,10 +30,11 @@ declare class SmarticoAPI {
24
30
  private publicUrl;
25
31
  private wsUrl;
26
32
  private partnerUrl;
27
- private avatarDomain;
33
+ avatarDomain: string;
28
34
  private logger;
29
35
  private logCIDs;
30
36
  private logHTTPTiming;
37
+ tracker?: Tracker;
31
38
  constructor(label_api_key: string, brand_api_key: string, messageSender: MessageSender, options?: IOptions);
32
39
  static getEnvId(label_api_key: string): string;
33
40
  static getCleanLabelApiKey(label_api_key: string): string;
@@ -48,11 +55,13 @@ declare class SmarticoAPI {
48
55
  inboxGetMessages(user_ext_id: string, limit?: number, offset?: number): Promise<GetInboxMessagesResponse>;
49
56
  storeGetItems(user_ext_id: string): Promise<GetStoreItemsResponse>;
50
57
  missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse>;
58
+ missionsGetItemsT(user_ext_id?: string): Promise<TMissionOrBadge[]>;
51
59
  badgetsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse>;
52
60
  tournamentsGetLobby(user_ext_id: string): Promise<GetTournamentsResponse>;
53
61
  tournamentsGetInfo(user_ext_id: string, tournamentInstanceId: number): Promise<GetTournamentInfoResponse>;
54
62
  leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean): Promise<LeaderBoardDetails>;
55
63
  levelsGet(user_ext_id?: string): Promise<GetLevelMapResponse>;
64
+ levelsGetT(user_ext_id?: string): Promise<TLevel[]>;
56
65
  getWSCalls(): WSAPI;
57
66
  }
58
67
  export { SmarticoAPI, MessageSender };
@@ -1,9 +1,14 @@
1
1
  import { SmarticoAPI } from "../SmarticoAPI";
2
- import { GetLevelMapClearedResponse } from "./WSAPITypes";
2
+ import { TLevel, TMissionOrBadge, TUserProfile } from "./WSAPITypes";
3
3
  /** @group General API */
4
4
  export declare class WSAPI {
5
- private static api;
5
+ private api;
6
6
  /** @private */
7
7
  constructor(api: SmarticoAPI);
8
- getLevelsTransformed(): Promise<GetLevelMapClearedResponse[]>;
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[]>;
9
14
  }
@@ -1,13 +1,132 @@
1
- import { GetLevelMapResponse } from "../Level";
2
- /** @group Levels response */
3
- export interface GetLevelMapClearedResponse {
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 */
4
40
  id: number;
41
+ /** The name of the Level, translated to the user language */
5
42
  name: string;
43
+ /** The description of the Level, translated to the user language */
6
44
  description: string;
45
+ /** The URL of the image of the Level */
7
46
  image: string;
47
+ /** The amount of points required to reach the Level */
8
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
+ */
9
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
+ */
10
64
  required_level_counter_2: number;
11
65
  }
12
- /** @hidden */
13
- export declare const levelCleaner: (levels: GetLevelMapResponse) => GetLevelMapClearedResponse[];
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,8 +440,46 @@ exports.AchievementType = void 0;
430
440
  AchievementType[AchievementType["Badge"] = 2] = "Badge";
431
441
  })(exports.AchievementType || (exports.AchievementType = {}));
432
442
 
433
- /** @hidden */
434
- var levelCleaner = function levelCleaner(levels) {
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_ts,
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) {
435
483
  return levels == null ? void 0 : levels.levels.map(function (l) {
436
484
  return {
437
485
  id: l.level_id,
@@ -439,6 +487,7 @@ var levelCleaner = function levelCleaner(levels) {
439
487
  description: l.level_public_meta.description,
440
488
  image: l.level_public_meta.image_url,
441
489
  required_points: l.required_points,
490
+ visibility_points: parseInt(l.level_public_meta.visibility_points),
442
491
  required_level_counter_1: l.required_level_counter_1,
443
492
  required_level_counter_2: l.required_level_counter_2
444
493
  };
@@ -449,19 +498,43 @@ var levelCleaner = function levelCleaner(levels) {
449
498
  var WSAPI = /*#__PURE__*/function () {
450
499
  /** @private */
451
500
  function WSAPI(api) {
452
- WSAPI.api = api;
501
+ this.api = void 0;
502
+ this.api = api;
453
503
  }
504
+ /** Returns all the levels available the current user */
454
505
  var _proto = WSAPI.prototype;
455
- _proto.getLevelsTransformed = function getLevelsTransformed() {
506
+ _proto.getUserProfile = function getUserProfile() {
456
507
  try {
457
- return Promise.resolve(WSAPI.api.levelsGet(null)).then(levelCleaner);
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));
458
532
  } catch (e) {
459
533
  return Promise.reject(e);
460
534
  }
461
535
  };
462
536
  return WSAPI;
463
537
  }();
464
- WSAPI.api = void 0;
465
538
 
466
539
  function _catch(body, recover) {
467
540
  try {
@@ -480,6 +553,7 @@ var AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
480
553
  var DEFAULT_LANG_EN = "EN";
481
554
  var SmarticoAPI = /*#__PURE__*/function () {
482
555
  function SmarticoAPI(label_api_key, brand_api_key, messageSender, options) {
556
+ var _options$tracker;
483
557
  if (options === void 0) {
484
558
  options = {};
485
559
  }
@@ -493,6 +567,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
493
567
  this.logger = void 0;
494
568
  this.logCIDs = void 0;
495
569
  this.logHTTPTiming = void 0;
570
+ this.tracker = void 0;
496
571
  this.label_api_key = label_api_key;
497
572
  this.brand_api_key = brand_api_key;
498
573
  this.messageSender = messageSender;
@@ -502,9 +577,10 @@ var SmarticoAPI = /*#__PURE__*/function () {
502
577
  }
503
578
  this.logCIDs = options.logCIDs || [];
504
579
  this.logHTTPTiming = options.logHTTPTiming || false;
580
+ this.tracker = options.tracker;
505
581
  this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
506
582
  this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
507
- 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));
508
584
  this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key);
509
585
  }
510
586
  SmarticoAPI.getEnvId = function getEnvId(label_api_key) {
@@ -650,7 +726,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
650
726
  hash_code: 0,
651
727
  areas: areas
652
728
  });
653
- return Promise.resolve(_this3.send(tsBaseRQ)).then(function (trBase) {
729
+ return Promise.resolve(_this3.send(tsBaseRQ, exports.ClassId.GET_TRANSLATIONS_RESPONSE)).then(function (trBase) {
654
730
  var _temp3 = function () {
655
731
  if (lang_code !== DEFAULT_LANG_EN) {
656
732
  var trUserRQ = _this3.buildMessage(user_ext_id, exports.ClassId.GET_TRANSLATIONS_REQUEST, {
@@ -658,7 +734,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
658
734
  hash_code: 0,
659
735
  areas: areas
660
736
  });
661
- return Promise.resolve(_this3.send(trUserRQ)).then(function (trUser) {
737
+ return Promise.resolve(_this3.send(trUserRQ, exports.ClassId.GET_TRANSLATIONS_RESPONSE)).then(function (trUser) {
662
738
  var _trUser$translations;
663
739
  Object.keys((_trUser$translations = trUser == null ? void 0 : trUser.translations) != null ? _trUser$translations : {}).forEach(function (k) {
664
740
  trBase.translations[k] = trUser.translations[k];
@@ -733,7 +809,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
733
809
  } : {
734
810
  is_visitor_mode: is_visitor_mode
735
811
  });
736
- return Promise.resolve(_this7.send(message)).then(function (response) {
812
+ return Promise.resolve(_this7.send(message, exports.ClassId.SAW_GET_SPINS_RESPONSE)).then(function (response) {
737
813
  if (response && response.templates) {
738
814
  response.templates.forEach(function (t) {
739
815
  if (t.jackpot_current !== undefined && t.jackpot_current !== null) {
@@ -792,7 +868,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
792
868
  limit: limit,
793
869
  offset: offset
794
870
  });
795
- return Promise.resolve(_this9.send(message));
871
+ return Promise.resolve(_this9.send(message, exports.ClassId.GET_INBOX_MESSAGES_RESPONSE));
796
872
  } catch (e) {
797
873
  return Promise.reject(e);
798
874
  }
@@ -801,7 +877,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
801
877
  try {
802
878
  var _this10 = this;
803
879
  var message = _this10.buildMessage(user_ext_id, exports.ClassId.GET_SHOP_ITEMS_REQUEST);
804
- return Promise.resolve(_this10.send(message));
880
+ return Promise.resolve(_this10.send(message, exports.ClassId.GET_SHOP_ITEMS_RESPONSE));
805
881
  } catch (e) {
806
882
  return Promise.reject(e);
807
883
  }
@@ -810,7 +886,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
810
886
  try {
811
887
  var _this11 = this;
812
888
  var message = _this11.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
813
- return Promise.resolve(_this11.send(message)).then(function (response) {
889
+ return Promise.resolve(_this11.send(message, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
814
890
  if (response.achievements) {
815
891
  response.achievements = response.achievements.filter(function (a) {
816
892
  return a.ach_type_id === exports.AchievementType.Mission;
@@ -822,11 +898,21 @@ var SmarticoAPI = /*#__PURE__*/function () {
822
898
  return Promise.reject(e);
823
899
  }
824
900
  };
825
- _proto.badgetsGetItems = function badgetsGetItems(user_ext_id) {
901
+ _proto.missionsGetItemsT = function missionsGetItemsT(user_ext_id) {
826
902
  try {
827
903
  var _this12 = this;
828
- var message = _this12.buildMessage(user_ext_id, exports.ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
829
- 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, exports.ClassId.GET_ACHIEVEMENT_MAP_RESPONSE)).then(function (response) {
830
916
  if (response.achievements) {
831
917
  response.achievements = response.achievements.filter(function (a) {
832
918
  return a.ach_type_id === exports.AchievementType.Badge;
@@ -840,27 +926,27 @@ var SmarticoAPI = /*#__PURE__*/function () {
840
926
  };
841
927
  _proto.tournamentsGetLobby = function tournamentsGetLobby(user_ext_id) {
842
928
  try {
843
- var _this13 = this;
844
- var message = _this13.buildMessage(user_ext_id, exports.ClassId.GET_TOURNAMENT_LOBBY_REQUEST);
845
- 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, exports.ClassId.GET_TOURNAMENT_LOBBY_RESPONSE));
846
932
  } catch (e) {
847
933
  return Promise.reject(e);
848
934
  }
849
935
  };
850
936
  _proto.tournamentsGetInfo = function tournamentsGetInfo(user_ext_id, tournamentInstanceId) {
851
937
  try {
852
- var _this14 = this;
853
- 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, {
854
940
  tournamentInstanceId: tournamentInstanceId
855
941
  });
856
- return Promise.resolve(_this14.send(message)).then(function (response) {
942
+ return Promise.resolve(_this15.send(message, exports.ClassId.GET_TOURNAMENT_LOBBY_RESPONSE)).then(function (response) {
857
943
  var _response$userPositio, _response$tournamentI;
858
944
  if ((_response$userPositio = response.userPosition) != null && _response$userPositio.avatar_id) {
859
- 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);
860
946
  }
861
947
  if ((_response$tournamentI = response.tournamentInfo.players) != null && _response$tournamentI.length) {
862
948
  response.tournamentInfo.players.forEach(function (p) {
863
- p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this14.avatarDomain);
949
+ p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this15.avatarDomain);
864
950
  });
865
951
  }
866
952
  return response;
@@ -874,13 +960,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
874
960
  prevPeriod = false;
875
961
  }
876
962
  try {
877
- var _this15 = this;
878
- 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, {
879
965
  period_type_id: period_type_id,
880
966
  snapshot_offset: prevPeriod ? 1 : 0,
881
967
  include_users: true
882
968
  });
883
- return Promise.resolve(_this15.send(message)).then(function (response) {
969
+ return Promise.resolve(_this16.send(message, exports.ClassId.GET_LEADERS_BOARD_RESPONSE)).then(function (response) {
884
970
  var _response$map$boardKe, _response$map$boardKe2, _response$map$boardKe3, _response$map$boardKe4;
885
971
  var boardKey = Object.keys(response.map).find(function (k) {
886
972
  return period_type_id === undefined || k === (period_type_id == null ? void 0 : period_type_id.toString());
@@ -889,11 +975,11 @@ var SmarticoAPI = /*#__PURE__*/function () {
889
975
  return undefined;
890
976
  }
891
977
  if ((_response$map$boardKe = response.map[boardKey]) != null && (_response$map$boardKe2 = _response$map$boardKe.userPosition) != null && _response$map$boardKe2.avatar_id) {
892
- 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);
893
979
  }
894
980
  if ((_response$map$boardKe3 = response.map[boardKey]) != null && (_response$map$boardKe4 = _response$map$boardKe3.positions) != null && _response$map$boardKe4.length) {
895
981
  response.map[boardKey].positions.forEach(function (p) {
896
- p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this15.avatarDomain);
982
+ p.avatar_url = CoreUtils.avatarUrl(p.avatar_id, _this16.avatarDomain);
897
983
  });
898
984
  }
899
985
  return response.map[boardKey];
@@ -904,9 +990,17 @@ var SmarticoAPI = /*#__PURE__*/function () {
904
990
  };
905
991
  _proto.levelsGet = function levelsGet(user_ext_id) {
906
992
  try {
907
- var _this16 = this;
908
- var message = _this16.buildMessage(user_ext_id, exports.ClassId.GET_LEVEL_MAP_REQUEST);
909
- return Promise.resolve(_this16.send(message, exports.ClassId.GET_LEVEL_MAP_RESPONSE));
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));
996
+ } catch (e) {
997
+ return Promise.reject(e);
998
+ }
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);
910
1004
  } catch (e) {
911
1005
  return Promise.reject(e);
912
1006
  }
@@ -1070,6 +1164,7 @@ TournamentUtils.isUpcoming = function (tournament) {
1070
1164
 
1071
1165
  exports.CookieStore = CookieStore;
1072
1166
  exports.CoreUtils = CoreUtils;
1167
+ exports.GetLevelMapResponseTransform = GetLevelMapResponseTransform;
1073
1168
  exports.SAWBuyInTypeName = SAWBuyInTypeName;
1074
1169
  exports.SAWGameTypeName = SAWGameTypeName;
1075
1170
  exports.SAWUtils = SAWUtils;
@@ -1077,4 +1172,5 @@ exports.SAWWinSoundFiles = SAWWinSoundFiles;
1077
1172
  exports.SmarticoAPI = SmarticoAPI;
1078
1173
  exports.TournamentInstanceStatusName = TournamentInstanceStatusName;
1079
1174
  exports.TournamentUtils = TournamentUtils;
1175
+ exports.UserAchievementTransform = UserAchievementTransform;
1080
1176
  //# sourceMappingURL=index.js.map