@smartico/public-api 0.0.56 → 0.0.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,14 @@
1
1
  export declare enum SAWSpinErrorCode {
2
+ /** No error */
2
3
  SAW_OK = 0,
4
+ /** User doesn't have 'spin attempts' to play. In case buy in type for the game is 'spins' based */
3
5
  SAW_NO_SPINS = 40001,
6
+ /** The are no prizes left to play the game */
4
7
  SAW_PRIZE_POOL_EMPTY = 40002,
8
+ /** User doesn't have enough points to play. In case buy in type for the game is 'points' based */
5
9
  SAW_NOT_ENOUGH_POINTS = 40003,
10
+ /** User reached max number of game attempts defined in the BackOffice */
6
11
  SAW_FAILED_MAX_SPINS_REACHED = 40004,
12
+ /** Special code for the 'visitor' mode */
7
13
  SAW_VISITOR_STOP_SPIN_REQUEST = -40001
8
14
  }
@@ -53,7 +53,7 @@ declare class SmarticoAPI {
53
53
  }>;
54
54
  sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode?: boolean): Promise<SAWGetTemplatesResponse>;
55
55
  sawGetTemplatesT(user_ext_id: string): Promise<TMiniGameTemplate[]>;
56
- sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id: number): Promise<SAWDoSpinResponse>;
56
+ sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse>;
57
57
  inboxGetMessages(user_ext_id: string, limit?: number, offset?: number): Promise<GetInboxMessagesResponse>;
58
58
  storeGetItems(user_ext_id: string): Promise<GetStoreItemsResponse>;
59
59
  storeGetItemsT(user_ext_id: string): Promise<TStoreItem[]>;
@@ -1,12 +1,12 @@
1
1
  import { SmarticoAPI } from "../SmarticoAPI";
2
- import { TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
2
+ import { TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
3
3
  /** @group General API */
4
4
  export declare class WSAPI {
5
5
  private api;
6
6
  /** @private */
7
7
  constructor(api: SmarticoAPI);
8
8
  /** Returns information about current user */
9
- getUserProfile(): Promise<TUserProfile>;
9
+ getUserProfile(): TUserProfile;
10
10
  /** Returns all the levels available the current user */
11
11
  getLevels(): Promise<TLevel[]>;
12
12
  /** Returns all the missions available the current user */
@@ -19,6 +19,8 @@ export declare class WSAPI {
19
19
  getStoreCategories(): Promise<TStoreItem[]>;
20
20
  /** Returns the list of mini-games available for user */
21
21
  getMiniGames(): Promise<TMiniGameTemplate[]>;
22
+ /** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */
23
+ playMiniGame(template_id: number): Promise<TMiniGamePlayResult>;
22
24
  /** Returns all the active instances of tournaments */
23
25
  getTournamentsList(): Promise<TTournament[]>;
24
26
  /** Returns details information of specific tournament instance, the response will includ tournamnet info and the leaderboard of players */
@@ -1,8 +1,8 @@
1
- import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName } from "../MiniGames";
1
+ import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWSpinErrorCode } from "../MiniGames";
2
2
  import { TournamentRegistrationStatusName, TournamentRegistrationTypeName } from "../Tournaments";
3
3
  type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string;
4
4
  /**
5
- * TMiniGamePrize interface describes the information of prize in the array of prizes in the TMiniGameTemplate
5
+ * TMiniGamePrize describes the information of prize in the array of prizes in the TMiniGameTemplate
6
6
  */
7
7
  export interface TMiniGamePrize {
8
8
  /** ID of the prize */
@@ -19,7 +19,18 @@ export interface TMiniGamePrize {
19
19
  icon?: string;
20
20
  }
21
21
  /**
22
- * TMiniGameTemplate interface describes the information of mini-games available for the user
22
+ * TMiniGamePlayResult describes the response of call to _smartico.api.playMiniGame(template_id) method
23
+ */
24
+ export interface TMiniGamePlayResult {
25
+ /** Name of the mini-game template, translated to the user language */
26
+ err_code: SAWSpinErrorCode;
27
+ /** Name of the mini-game template, translated to the user language */
28
+ err_message: string;
29
+ /** The prize_id that user won, details of the prize can be found in the mini-game definition */
30
+ prize_id: number;
31
+ }
32
+ /**
33
+ * TMiniGameTemplate describes the information of mini-games available for the user
23
34
  */
24
35
  export interface TMiniGameTemplate {
25
36
  /** ID of the mini-game template */
@@ -50,7 +61,7 @@ export interface TMiniGameTemplate {
50
61
  prizes: TMiniGamePrize[];
51
62
  }
52
63
  /**
53
- * TUser interface describes the information of the user
64
+ * TUser describes the information of the user
54
65
  * The user object is returned by _smartico.api.getUserProfile() method.
55
66
  * If you want to track the changes of the user profile, you can subscribe to the callback in the following way
56
67
  * _smartico.on('props_change', () => console.log(_smartico.api.getUserProfile()) );
@@ -81,7 +92,7 @@ export interface TUserProfile {
81
92
  core_inbox_unread_count?: number;
82
93
  }
83
94
  /**
84
- * TLevel interface describes the information of each level defined in the system
95
+ * TLevel describes the information of each level defined in the system
85
96
  * There is no order of the levels, but it can be calculated using required_points property
86
97
  * The current level of user can be taken from the user object using ach_level_current_id property
87
98
  * The progress to the next level can be calculated using ach_points_ever and required_points properties of next level
@@ -115,7 +126,7 @@ export interface TLevel {
115
126
  required_level_counter_2: number;
116
127
  }
117
128
  /**
118
- * TTournament interface describes the general information of the tournament item
129
+ * TTournament describes the general information of the tournament item
119
130
  */
120
131
  export interface TTournament {
121
132
  /** ID of tournament instance. Generated every time when tournament based on specific template is scheduled for run */
@@ -177,7 +188,7 @@ export interface TTournament {
177
188
  is_upcoming: boolean;
178
189
  }
179
190
  /**
180
- * TTournamentDetailed interface describes the information of the tournament item and includes list of participants, their scores and position in the tournament leaderboard
191
+ * TTournamentDetailed describes the information of the tournament item and includes list of participants, their scores and position in the tournament leaderboard
181
192
  */
182
193
  export interface TTournamentDetailed extends TTournament {
183
194
  /** The list of the tournament participants */
@@ -206,7 +217,7 @@ export interface TTournamentDetailed extends TTournament {
206
217
  };
207
218
  }
208
219
  /**
209
- * TStoreCategory interface describes the store category item. Each store item can be assigned to 1 or more categories
220
+ * TStoreCategory describes the store category item. Each store item can be assigned to 1 or more categories
210
221
  */
211
222
  export interface TStoreCategory {
212
223
  id: number;
@@ -214,7 +225,7 @@ export interface TStoreCategory {
214
225
  order: number;
215
226
  }
216
227
  /**
217
- * TStoreItem interface describes the information of the store item defined in the system
228
+ * TStoreItem describes the information of the store item defined in the system
218
229
  */
219
230
  export interface TStoreItem {
220
231
  /** ID of the store item */
@@ -249,7 +260,7 @@ export interface TStoreItem {
249
260
  category_ids: number[];
250
261
  }
251
262
  /**
252
- * TMissionOrBadge interface describes the information of mission or badge defined in the system
263
+ * TMissionOrBadge describes the information of mission or badge defined in the system
253
264
  */
254
265
  export interface TMissionOrBadge {
255
266
  /** ID of the mission or badge */
@@ -303,7 +314,7 @@ export interface TMissionOrBadge {
303
314
  tasks: TMissionOrBadgeTask[];
304
315
  }
305
316
  /**
306
- * TMissionOrBadgeTask interface describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
317
+ * TMissionOrBadgeTask describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
307
318
  */
308
319
  export interface TMissionOrBadgeTask {
309
320
  /** ID of the task */
package/dist/index.js CHANGED
@@ -304,14 +304,23 @@ var SAWTemplatesTransform = function SAWTemplatesTransform(items) {
304
304
  });
305
305
  };
306
306
 
307
+ /*
308
+ * Possible error codes for the mini-games attempts
309
+ */
307
310
  exports.SAWSpinErrorCode = void 0;
308
311
  (function (SAWSpinErrorCode) {
312
+ /** No error */
309
313
  SAWSpinErrorCode[SAWSpinErrorCode["SAW_OK"] = 0] = "SAW_OK";
314
+ /** User doesn't have 'spin attempts' to play. In case buy in type for the game is 'spins' based */
310
315
  SAWSpinErrorCode[SAWSpinErrorCode["SAW_NO_SPINS"] = 40001] = "SAW_NO_SPINS";
316
+ /** The are no prizes left to play the game */
311
317
  SAWSpinErrorCode[SAWSpinErrorCode["SAW_PRIZE_POOL_EMPTY"] = 40002] = "SAW_PRIZE_POOL_EMPTY";
318
+ /** User doesn't have enough points to play. In case buy in type for the game is 'points' based */
312
319
  SAWSpinErrorCode[SAWSpinErrorCode["SAW_NOT_ENOUGH_POINTS"] = 40003] = "SAW_NOT_ENOUGH_POINTS";
320
+ /** User reached max number of game attempts defined in the BackOffice */
313
321
  SAWSpinErrorCode[SAWSpinErrorCode["SAW_FAILED_MAX_SPINS_REACHED"] = 40004] = "SAW_FAILED_MAX_SPINS_REACHED";
314
- SAWSpinErrorCode[SAWSpinErrorCode["SAW_VISITOR_STOP_SPIN_REQUEST"] = -40001] = "SAW_VISITOR_STOP_SPIN_REQUEST"; // special code for visitor game mode to stop spin request
322
+ /** Special code for the 'visitor' mode */
323
+ SAWSpinErrorCode[SAWSpinErrorCode["SAW_VISITOR_STOP_SPIN_REQUEST"] = -40001] = "SAW_VISITOR_STOP_SPIN_REQUEST";
315
324
  })(exports.SAWSpinErrorCode || (exports.SAWSpinErrorCode = {}));
316
325
 
317
326
  var _SAWWinSoundFiles;
@@ -809,63 +818,74 @@ var WSAPI = /*#__PURE__*/function () {
809
818
  /** Returns information about current user */
810
819
  var _proto = WSAPI.prototype;
811
820
  _proto.getUserProfile = function getUserProfile() {
812
- try {
813
- var _this = this;
814
- if (_this.api.tracker) {
815
- var o = Object.assign({}, _this.api.tracker.userPublicProps);
816
- o.avatar_url = CoreUtils.avatarUrl(_this.api.tracker.userPublicProps.avatar_id, _this.api.avatarDomain);
817
- return Promise.resolve(o);
818
- } else {
819
- throw new Error('Tracker is not initialized, cannot getUserProfile');
820
- }
821
- } catch (e) {
822
- return Promise.reject(e);
821
+ if (this.api.tracker) {
822
+ var o = Object.assign({}, this.api.tracker.userPublicProps);
823
+ o.avatar_url = CoreUtils.avatarUrl(this.api.tracker.userPublicProps.avatar_id, this.api.avatarDomain);
824
+ return o;
825
+ } else {
826
+ throw new Error('Tracker is not initialized, cannot getUserProfile');
823
827
  }
824
- } /** Returns all the levels available the current user */;
828
+ }
829
+ /** Returns all the levels available the current user */;
825
830
  _proto.getLevels = function getLevels() {
826
831
  try {
827
- var _this2 = this;
828
- return Promise.resolve(_this2.api.levelsGetT(null));
832
+ var _this = this;
833
+ return Promise.resolve(_this.api.levelsGetT(null));
829
834
  } catch (e) {
830
835
  return Promise.reject(e);
831
836
  }
832
837
  } /** Returns all the missions available the current user */;
833
838
  _proto.getMissions = function getMissions() {
834
839
  try {
835
- var _this3 = this;
836
- return Promise.resolve(_this3.api.missionsGetItemsT(null));
840
+ var _this2 = this;
841
+ return Promise.resolve(_this2.api.missionsGetItemsT(null));
837
842
  } catch (e) {
838
843
  return Promise.reject(e);
839
844
  }
840
845
  } /** Returns all the badges available the current user */;
841
846
  _proto.getBadges = function getBadges() {
842
847
  try {
843
- var _this4 = this;
844
- return Promise.resolve(_this4.api.badgetsGetItemsT(null));
848
+ var _this3 = this;
849
+ return Promise.resolve(_this3.api.badgetsGetItemsT(null));
845
850
  } catch (e) {
846
851
  return Promise.reject(e);
847
852
  }
848
853
  } /** Returns all the store items available the current user */;
849
854
  _proto.getStoreItems = function getStoreItems() {
850
855
  try {
851
- var _this5 = this;
852
- return Promise.resolve(_this5.api.storeGetItemsT(null));
856
+ var _this4 = this;
857
+ return Promise.resolve(_this4.api.storeGetItemsT(null));
853
858
  } catch (e) {
854
859
  return Promise.reject(e);
855
860
  }
856
861
  } /** Returns store categories */;
857
862
  _proto.getStoreCategories = function getStoreCategories() {
858
863
  try {
859
- var _this6 = this;
860
- return Promise.resolve(_this6.api.storeGetItemsT(null));
864
+ var _this5 = this;
865
+ return Promise.resolve(_this5.api.storeGetItemsT(null));
861
866
  } catch (e) {
862
867
  return Promise.reject(e);
863
868
  }
864
869
  } /** Returns the list of mini-games available for user */;
865
870
  _proto.getMiniGames = function getMiniGames() {
871
+ try {
872
+ var _this6 = this;
873
+ return Promise.resolve(_this6.api.sawGetTemplatesT(null));
874
+ } catch (e) {
875
+ return Promise.reject(e);
876
+ }
877
+ } /** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */;
878
+ _proto.playMiniGame = function playMiniGame(template_id) {
866
879
  try {
867
880
  var _this7 = this;
868
- return Promise.resolve(_this7.api.sawGetTemplatesT(null));
881
+ return Promise.resolve(_this7.api.sawSpinRequest(null, template_id)).then(function (r) {
882
+ var o = {
883
+ err_code: r.errCode,
884
+ err_message: r.errMsg,
885
+ prize_id: r.saw_prize_id
886
+ };
887
+ return o;
888
+ });
869
889
  } catch (e) {
870
890
  return Promise.reject(e);
871
891
  }