@smartico/public-api 0.0.84 → 0.0.86

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
@@ -17,7 +17,7 @@ As soon as the _smartico object is available in the global context and the user
17
17
 
18
18
  ```javascript
19
19
 
20
- _smartico.api.levelsGet().then( levels => {
20
+ _smartico.api.getLevels().then( levels => {
21
21
  console.log('There are ' + levels.length + ' levels available');
22
22
  });
23
23
 
@@ -31,4 +31,5 @@ export interface SAWTemplateUI {
31
31
  max_spins_period_ms?: number;
32
32
  show_countdown_for_next_availability?: boolean;
33
33
  disable_background_music?: boolean;
34
+ custom_section_id?: number;
34
35
  }
@@ -75,6 +75,7 @@ declare class SmarticoAPI {
75
75
  leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean): Promise<LeaderBoardDetails>;
76
76
  levelsGet(user_ext_id: string): Promise<GetLevelMapResponse>;
77
77
  levelsGetT(user_ext_id: string): Promise<TLevel[]>;
78
+ getTranslationsT(user_ext_id: string, lang_code: string, areas: TranslationArea[], cacheSec?: number): Promise<GetTranslationsResponse>;
78
79
  getWSCalls(): WSAPI;
79
80
  }
80
81
  export { SmarticoAPI, MessageSender };
@@ -1,5 +1,5 @@
1
1
  import { SmarticoAPI } from "../SmarticoAPI";
2
- import { TBuyStoreItemResult, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile } from "./WSAPITypes";
2
+ import { TBuyStoreItemResult, TGetTranslations, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile } from "./WSAPITypes";
3
3
  /** @group General API */
4
4
  export declare class WSAPI {
5
5
  private api;
@@ -54,6 +54,8 @@ export declare class WSAPI {
54
54
  getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed>;
55
55
  /** Requests registration for the specified tournament instance. Returns the err_code. */
56
56
  registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult>;
57
+ /** Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office. */
58
+ getTranslations(lang_code: string): Promise<TGetTranslations>;
57
59
  private updateOnSpin;
58
60
  private updateOnAddSpin;
59
61
  private updateOnPrizeWin;
@@ -369,4 +369,9 @@ export interface TBuyStoreItemResult {
369
369
  /** Optional error message */
370
370
  err_message: string;
371
371
  }
372
+ export interface TGetTranslations {
373
+ translations: {
374
+ [key: string]: string;
375
+ };
376
+ }
372
377
  export {};
package/dist/index.js CHANGED
@@ -1051,18 +1051,30 @@ var WSAPI = /*#__PURE__*/function () {
1051
1051
  } catch (e) {
1052
1052
  return Promise.reject(e);
1053
1053
  }
1054
+ } /** Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office. */;
1055
+ _proto.getTranslations = function getTranslations(lang_code) {
1056
+ try {
1057
+ var _this14 = this;
1058
+ return Promise.resolve(_this14.api.getTranslationsT(null, lang_code, [])).then(function (r) {
1059
+ return {
1060
+ translations: r.translations
1061
+ };
1062
+ });
1063
+ } catch (e) {
1064
+ return Promise.reject(e);
1065
+ }
1054
1066
  };
1055
1067
  _proto.updateOnSpin = function updateOnSpin(data) {
1056
1068
  try {
1057
- var _this14 = this;
1069
+ var _this15 = this;
1058
1070
  return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
1059
- return _this14.api.sawGetTemplatesT(null);
1071
+ return _this15.api.sawGetTemplatesT(null);
1060
1072
  }, CACHE_DATA_SEC)).then(function (templates) {
1061
1073
  var index = templates.findIndex(function (t) {
1062
1074
  return t.id === data.saw_template_id;
1063
1075
  });
1064
1076
  templates[index].spin_count = data.spin_count;
1065
- _this14.updateEntity(onUpdateContextKey.Saw, templates);
1077
+ _this15.updateEntity(onUpdateContextKey.Saw, templates);
1066
1078
  });
1067
1079
  } catch (e) {
1068
1080
  return Promise.reject(e);
@@ -1070,9 +1082,9 @@ var WSAPI = /*#__PURE__*/function () {
1070
1082
  };
1071
1083
  _proto.updateOnAddSpin = function updateOnAddSpin() {
1072
1084
  try {
1073
- var _this15 = this;
1074
- return Promise.resolve(_this15.api.sawGetTemplatesT(null)).then(function (payload) {
1075
- _this15.updateEntity(onUpdateContextKey.Saw, payload);
1085
+ var _this16 = this;
1086
+ return Promise.resolve(_this16.api.sawGetTemplatesT(null)).then(function (payload) {
1087
+ _this16.updateEntity(onUpdateContextKey.Saw, payload);
1076
1088
  });
1077
1089
  } catch (e) {
1078
1090
  return Promise.reject(e);
@@ -1080,11 +1092,11 @@ var WSAPI = /*#__PURE__*/function () {
1080
1092
  };
1081
1093
  _proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
1082
1094
  try {
1083
- var _this16 = this;
1095
+ var _this17 = this;
1084
1096
  var _temp5 = function () {
1085
1097
  if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
1086
1098
  return Promise.resolve(OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, function () {
1087
- return _this16.api.sawGetTemplatesT(null);
1099
+ return _this17.api.sawGetTemplatesT(null);
1088
1100
  }, CACHE_DATA_SEC)).then(function (templates) {
1089
1101
  var _template$prizes$find;
1090
1102
  var template = templates.find(function (t) {
@@ -1097,8 +1109,8 @@ var WSAPI = /*#__PURE__*/function () {
1097
1109
  })) == null ? void 0 : _template$prizes$find.prize_type;
1098
1110
  var _temp4 = function () {
1099
1111
  if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === exports.MiniGamePrizeTypeName.JACKPOT || prizeType === exports.MiniGamePrizeTypeName.SPIN) {
1100
- return Promise.resolve(_this16.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
1101
- _this16.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
1112
+ return Promise.resolve(_this17.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
1113
+ _this17.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
1102
1114
  });
1103
1115
  }
1104
1116
  }();
@@ -1113,9 +1125,9 @@ var WSAPI = /*#__PURE__*/function () {
1113
1125
  };
1114
1126
  _proto.updateMissionsOnOptIn = function updateMissionsOnOptIn() {
1115
1127
  try {
1116
- var _this17 = this;
1117
- return Promise.resolve(_this17.api.missionsGetItemsT(null)).then(function (payload) {
1118
- _this17.updateEntity(onUpdateContextKey.Missions, payload);
1128
+ var _this18 = this;
1129
+ return Promise.resolve(_this18.api.missionsGetItemsT(null)).then(function (payload) {
1130
+ _this18.updateEntity(onUpdateContextKey.Missions, payload);
1119
1131
  });
1120
1132
  } catch (e) {
1121
1133
  return Promise.reject(e);
@@ -1123,9 +1135,9 @@ var WSAPI = /*#__PURE__*/function () {
1123
1135
  };
1124
1136
  _proto.updateTournamentsOnRegistration = function updateTournamentsOnRegistration() {
1125
1137
  try {
1126
- var _this18 = this;
1127
- return Promise.resolve(_this18.api.tournamentsGetLobbyT(null)).then(function (payload) {
1128
- _this18.updateEntity(onUpdateContextKey.TournamentList, payload);
1138
+ var _this19 = this;
1139
+ return Promise.resolve(_this19.api.tournamentsGetLobbyT(null)).then(function (payload) {
1140
+ _this19.updateEntity(onUpdateContextKey.TournamentList, payload);
1129
1141
  });
1130
1142
  } catch (e) {
1131
1143
  return Promise.reject(e);
@@ -1133,9 +1145,9 @@ var WSAPI = /*#__PURE__*/function () {
1133
1145
  };
1134
1146
  _proto.updateEntity = function updateEntity(contextKey, payload) {
1135
1147
  try {
1136
- var _this19 = this;
1148
+ var _this20 = this;
1137
1149
  OCache.set(contextKey, payload, ECacheContext.WSAPI);
1138
- var onUpdate = _this19.onUpdateCallback.get(contextKey);
1150
+ var onUpdate = _this20.onUpdateCallback.get(contextKey);
1139
1151
  if (onUpdate) {
1140
1152
  onUpdate(payload);
1141
1153
  }
@@ -1748,6 +1760,14 @@ var SmarticoAPI = /*#__PURE__*/function () {
1748
1760
  return Promise.reject(e);
1749
1761
  }
1750
1762
  };
1763
+ _proto.getTranslationsT = function getTranslationsT(user_ext_id, lang_code, areas, cacheSec) {
1764
+ try {
1765
+ var _this30 = this;
1766
+ return Promise.resolve(_this30.coreGetTranslations(user_ext_id, lang_code, areas, 30));
1767
+ } catch (e) {
1768
+ return Promise.reject(e);
1769
+ }
1770
+ };
1751
1771
  _proto.getWSCalls = function getWSCalls() {
1752
1772
  return new WSAPI(this);
1753
1773
  };