@smartico/public-api 0.0.383 → 0.0.385

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.
@@ -900,6 +900,9 @@ const InboxMessagesTransform = items => {
900
900
  };
901
901
 
902
902
  const InboxMessageBodyTransform = item => {
903
+ if (!item) {
904
+ return null;
905
+ }
903
906
  const x = {
904
907
  action: item.action,
905
908
  icon: item.image,
@@ -1882,7 +1885,7 @@ TournamentUtils.getPrizeTransformed = prize => {
1882
1885
  };
1883
1886
 
1884
1887
  const TournamentItemsTransform = items => {
1885
- return items.filter(r => r.tournamentId >= 1).map(r => {
1888
+ return items.filter(r => r != null && r.tournamentId >= 1).map(r => {
1886
1889
  const x = _extends({
1887
1890
  instance_id: r.tournamentInstanceId,
1888
1891
  tournament_id: r.tournamentId,
@@ -2182,7 +2185,7 @@ class WSAPIBase {
2182
2185
  async updateEntity(contextKey, payload) {
2183
2186
  OCache.set(contextKey, payload, ECacheContext.WSAPI);
2184
2187
  const onUpdate = this.onUpdateCallback.get(contextKey);
2185
- if (onUpdate) {
2188
+ if (typeof onUpdate === 'function') {
2186
2189
  onUpdate(payload);
2187
2190
  }
2188
2191
  }
@@ -2935,7 +2938,7 @@ class WSAPIUser extends WSAPIBase {
2935
2938
  to,
2936
2939
  onUpdate
2937
2940
  }) {
2938
- if (onUpdate) {
2941
+ if (typeof onUpdate === 'function') {
2939
2942
  this.onUpdateCallback.set(onUpdateContextKey.ActivityLog, onUpdate);
2940
2943
  }
2941
2944
  return await OCache.use(onUpdateContextKey.ActivityLog, ECacheContext.WSAPI, () => this.api.getActivityLogT(this.userExtId, startTimeSeconds, endTimeSeconds, from, to), CACHE_DATA_SEC);
@@ -3257,7 +3260,7 @@ class WSAPIMissions extends WSAPIGeneral {
3257
3260
  async getMissions({
3258
3261
  onUpdate
3259
3262
  } = {}) {
3260
- if (onUpdate) {
3263
+ if (typeof onUpdate === 'function') {
3261
3264
  this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
3262
3265
  }
3263
3266
  return OCache.use(onUpdateContextKey.Missions, ECacheContext.WSAPI, () => this.api.missionsGetItemsT(this.userExtId), CACHE_DATA_SEC);
@@ -3796,7 +3799,7 @@ class WSAPIBonuses extends WSAPIMissions {
3796
3799
  async getBonuses({
3797
3800
  onUpdate
3798
3801
  } = {}) {
3799
- if (onUpdate) {
3802
+ if (typeof onUpdate === 'function') {
3800
3803
  this.onUpdateCallback.set(onUpdateContextKey.Bonuses, onUpdate);
3801
3804
  }
3802
3805
  return OCache.use(onUpdateContextKey.Bonuses, ECacheContext.WSAPI, () => this.api.bonusesGetItemsT(this.userExtId), CACHE_DATA_SEC);
@@ -4115,7 +4118,7 @@ class WSAPIStore extends WSAPIBonuses {
4115
4118
  async getStoreItems({
4116
4119
  onUpdate
4117
4120
  } = {}) {
4118
- if (onUpdate) {
4121
+ if (typeof onUpdate === 'function') {
4119
4122
  this.onUpdateCallback.set(onUpdateContextKey.StoreItems, onUpdate);
4120
4123
  }
4121
4124
  return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetItemsT(this.userExtId), CACHE_DATA_SEC);
@@ -4601,7 +4604,7 @@ class WSAPIStore extends WSAPIBonuses {
4601
4604
  const requestLimit = limit === undefined ? 20 : limit;
4602
4605
  const requestOffset = offset === undefined ? 0 : offset;
4603
4606
  const cacheKey = this.storeHistoryCacheKey(requestLimit, requestOffset);
4604
- if (onUpdate) {
4607
+ if (typeof onUpdate === 'function') {
4605
4608
  this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
4606
4609
  this.storeHistoryOnUpdateParams = {
4607
4610
  limit: requestLimit,
@@ -4754,7 +4757,7 @@ class WSAPITournaments extends WSAPIStore {
4754
4757
  async getTournamentsList({
4755
4758
  onUpdate
4756
4759
  } = {}) {
4757
- if (onUpdate) {
4760
+ if (typeof onUpdate === 'function') {
4758
4761
  this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
4759
4762
  }
4760
4763
  return OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, () => this.api.tournamentsGetLobbyT(this.userExtId), CACHE_DATA_SEC);
@@ -5270,7 +5273,7 @@ class WSAPIClans extends WSAPITournaments {
5270
5273
  async getClans({
5271
5274
  onUpdate
5272
5275
  } = {}) {
5273
- if (onUpdate) {
5276
+ if (typeof onUpdate === 'function') {
5274
5277
  this.onUpdateCallback.set(onUpdateContextKey.Clans, onUpdate);
5275
5278
  }
5276
5279
  return OCache.use(onUpdateContextKey.Clans, ECacheContext.WSAPI, () => this.api.clansGetListT(this.userExtId), CACHE_DATA_SEC);
@@ -5643,6 +5646,9 @@ class WSAPIJackpots extends WSAPIClans {
5643
5646
  let pots = [];
5644
5647
  jackpots = await OCache.use(onUpdateContextKey.Jackpots, ECacheContext.WSAPI, async function () {
5645
5648
  const _jackpots = await _this.api.jackpotGet(_this.userExtId, filter);
5649
+ if (!(_jackpots != null && _jackpots.items)) {
5650
+ return [];
5651
+ }
5646
5652
  const _pots = _jackpots.items.map(jp => jp.pot);
5647
5653
  _jackpots.items.forEach(jp => {
5648
5654
  jp.jp_public_meta.custom_data = IntUtils.JsonOrText(jp.jp_public_meta.custom_data);
@@ -5924,7 +5930,7 @@ class WSAPIJackpots extends WSAPIClans {
5924
5930
  jp_template_id,
5925
5931
  onUpdate
5926
5932
  }) {
5927
- if (onUpdate) {
5933
+ if (typeof onUpdate === 'function') {
5928
5934
  this.onUpdateCallback.set(onUpdateContextKey.JackpotEligibleGames, onUpdate);
5929
5935
  }
5930
5936
  return OCache.use(onUpdateContextKey.JackpotEligibleGames + jp_template_id, ECacheContext.WSAPI, () => this.api.getJackpotEligibleGamesT(this.userExtId, {
@@ -6050,7 +6056,7 @@ class WSAPIRaffles extends WSAPIJackpots {
6050
6056
  async getRaffles({
6051
6057
  onUpdate
6052
6058
  } = {}) {
6053
- if (onUpdate) {
6059
+ if (typeof onUpdate === 'function') {
6054
6060
  this.onUpdateCallback.set(onUpdateContextKey.Raffles, onUpdate);
6055
6061
  }
6056
6062
  return OCache.use(onUpdateContextKey.Raffles, ECacheContext.WSAPI, () => this.api.getRafflesT(this.userExtId), CACHE_DATA_SEC);
@@ -6707,7 +6713,7 @@ class WSAPIMiniGames extends WSAPIRaffles {
6707
6713
  async getMiniGames({
6708
6714
  onUpdate
6709
6715
  } = {}) {
6710
- if (onUpdate) {
6716
+ if (typeof onUpdate === 'function') {
6711
6717
  this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
6712
6718
  }
6713
6719
  return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(this.userExtId), CACHE_DATA_SEC);
@@ -6951,7 +6957,7 @@ class WSAPIMiniGames extends WSAPIRaffles {
6951
6957
  async playMiniGame(template_id, {
6952
6958
  onUpdate
6953
6959
  } = {}) {
6954
- if (onUpdate) {
6960
+ if (typeof onUpdate === 'function') {
6955
6961
  this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
6956
6962
  }
6957
6963
  const r = await this.api.sawSpinRequest(this.userExtId, template_id);
@@ -7133,7 +7139,7 @@ class WSAPIMiniGames extends WSAPIRaffles {
7133
7139
  async playMiniGameBatch(template_id, spin_count, {
7134
7140
  onUpdate
7135
7141
  } = {}) {
7136
- if (onUpdate) {
7142
+ if (typeof onUpdate === 'function') {
7137
7143
  this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
7138
7144
  }
7139
7145
  const response = await this.api.sawSpinBatchRequest(this.userExtId, template_id, spin_count);
@@ -7151,6 +7157,9 @@ class WSAPIMiniGames extends WSAPIRaffles {
7151
7157
  async updateOnSpin(data) {
7152
7158
  const templates = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(this.userExtId), CACHE_DATA_SEC);
7153
7159
  const index = templates.findIndex(t => t.id === data.saw_template_id);
7160
+ if (index === -1) {
7161
+ return;
7162
+ }
7154
7163
  templates[index].spin_count = data.spin_count;
7155
7164
  this.updateEntity(onUpdateContextKey.Saw, templates);
7156
7165
  }
@@ -8494,7 +8503,7 @@ class WSAPIInbox extends WSAPILeaderBoard {
8494
8503
  read_status,
8495
8504
  onUpdate
8496
8505
  } = {}) {
8497
- if (onUpdate) {
8506
+ if (typeof onUpdate === 'function') {
8498
8507
  this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
8499
8508
  }
8500
8509
  return await this.api.getInboxMessagesT(this.userExtId, from, to, onlyFavorite, categoryId, read_status);
@@ -8551,7 +8560,7 @@ class WSAPIInbox extends WSAPILeaderBoard {
8551
8560
  async getInboxUnreadCount({
8552
8561
  onUpdate
8553
8562
  } = {}) {
8554
- if (onUpdate) {
8563
+ if (typeof onUpdate === 'function') {
8555
8564
  this.onUpdateCallback.set(onUpdateContextKey.InboxUnreadCount, onUpdate);
8556
8565
  }
8557
8566
  return OCache.use(onUpdateContextKey.InboxUnreadCount, ECacheContext.WSAPI, () => this.api.getInboxUnreadCountT(this.userExtId), CACHE_DATA_SEC);