@smartico/public-api 0.0.137 → 0.0.138

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.
@@ -83,8 +83,8 @@ declare class SmarticoAPI {
83
83
  storeGetItemsT(user_ext_id: string): Promise<TStoreItem[]>;
84
84
  storeGetCategories(user_ext_id: string): Promise<GetCategoriesStoreResponse>;
85
85
  storeGetCategoriesT(user_ext_id: string): Promise<TStoreCategory[]>;
86
- storeGetPurchasedItems(user_ext_id: string): Promise<GetStoreHistoryResponse>;
87
- storeGetPurchasedItemsT(user_ext_id: string): Promise<TStoreItem[]>;
86
+ storeGetPurchasedItems(user_ext_id: string, limit?: number, offset?: number): Promise<GetStoreHistoryResponse>;
87
+ storeGetPurchasedItemsT(user_ext_id: string, limit?: number, offset?: number): Promise<TStoreItem[]>;
88
88
  missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse>;
89
89
  missionsGetItemsT(user_ext_id: string): Promise<TMissionOrBadge[]>;
90
90
  getUserGamificationInfo(user_ext_id: string): Promise<GetAchievementsUserInfoResponse>;
@@ -1,5 +1,5 @@
1
1
  import { ProtocolMessage } from "../Base/ProtocolMessage";
2
2
  export interface GetStoreHistoryRequest extends ProtocolMessage {
3
- offset?: number;
4
3
  limit?: number;
4
+ offset?: number;
5
5
  }
@@ -2,5 +2,5 @@ import { ProtocolResponse } from "../Base/ProtocolResponse";
2
2
  import { StoreItemPurchased } from "./StoreItemPurchased";
3
3
  export interface GetStoreHistoryResponse extends ProtocolResponse {
4
4
  items: StoreItemPurchased[];
5
- hasMore: boolean;
5
+ hasMore?: boolean;
6
6
  }
@@ -93,15 +93,21 @@ export declare class WSAPI {
93
93
  buyStoreItem(item_id: number): Promise<TBuyStoreItemResult>;
94
94
  /** Returns store categories */
95
95
  getStoreCategories(): Promise<TStoreCategory[]>;
96
- /** Returns all the purchased store items available the current user
97
- * Example usage:
98
- * ```
99
- * _smartico.api.getStorePurchasedItems().then((result) => {
100
- * console.log(result);
101
- * });
102
- * ```
103
- */
104
- getStorePurchasedItems(): Promise<TStoreItem[]>;
96
+ /** Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
97
+ * The maximum number of items per request is limited to 20.
98
+ * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
99
+ * Example usage:
100
+ * ```
101
+ * _smartico.api.getStorePurchasedItems().then((result) => {
102
+ * console.log(result);
103
+ * });
104
+ * ```
105
+ */
106
+ getStorePurchasedItems({ limit, offset, onUpdate }?: {
107
+ limit?: number;
108
+ offset?: number;
109
+ onUpdate?: (data: TStoreItem[]) => void;
110
+ }): Promise<TStoreItem[]>;
105
111
  /** Returns missions & badges categories */
106
112
  getAchCategories(): Promise<TAchCategory[]>;
107
113
  /** Returns the list of mini-games available for user
package/dist/index.js CHANGED
@@ -1347,7 +1347,9 @@ var WSAPI = /*#__PURE__*/function () {
1347
1347
  return Promise.reject(e);
1348
1348
  }
1349
1349
  }
1350
- /** Returns all the purchased store items available the current user
1350
+ /** Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
1351
+ * The maximum number of items per request is limited to 20.
1352
+ * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
1351
1353
  * Example usage:
1352
1354
  * ```
1353
1355
  * _smartico.api.getStorePurchasedItems().then((result) => {
@@ -1356,11 +1358,18 @@ var WSAPI = /*#__PURE__*/function () {
1356
1358
  * ```
1357
1359
  */
1358
1360
  ;
1359
- _proto.getStorePurchasedItems = function getStorePurchasedItems() {
1361
+ _proto.getStorePurchasedItems = function getStorePurchasedItems(_temp2) {
1362
+ var _ref2 = _temp2 === void 0 ? {} : _temp2,
1363
+ limit = _ref2.limit,
1364
+ offset = _ref2.offset,
1365
+ onUpdate = _ref2.onUpdate;
1360
1366
  try {
1361
1367
  var _this11 = this;
1362
- return Promise.resolve(OCache.use(onUpdateContextKey.StoreItems, exports.ECacheContext.WSAPI, function () {
1363
- return _this11.api.storeGetPurchasedItemsT(null);
1368
+ if (onUpdate) {
1369
+ _this11.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
1370
+ }
1371
+ return Promise.resolve(OCache.use(onUpdateContextKey.StoreHistory, exports.ECacheContext.WSAPI, function () {
1372
+ return _this11.api.storeGetPurchasedItemsT(null, limit, offset);
1364
1373
  }, CACHE_DATA_SEC));
1365
1374
  } catch (e) {
1366
1375
  return Promise.reject(e);
@@ -1384,9 +1393,9 @@ var WSAPI = /*#__PURE__*/function () {
1384
1393
  * @param params
1385
1394
  */
1386
1395
  ;
1387
- _proto.getMiniGames = function getMiniGames(_temp2) {
1388
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
1389
- onUpdate = _ref2.onUpdate;
1396
+ _proto.getMiniGames = function getMiniGames(_temp3) {
1397
+ var _ref3 = _temp3 === void 0 ? {} : _temp3,
1398
+ onUpdate = _ref3.onUpdate;
1390
1399
  try {
1391
1400
  var _this13 = this;
1392
1401
  if (onUpdate) {
@@ -1450,9 +1459,9 @@ var WSAPI = /*#__PURE__*/function () {
1450
1459
  * @param params
1451
1460
  */
1452
1461
  ;
1453
- _proto.getTournamentsList = function getTournamentsList(_temp3) {
1454
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
1455
- onUpdate = _ref3.onUpdate;
1462
+ _proto.getTournamentsList = function getTournamentsList(_temp4) {
1463
+ var _ref4 = _temp4 === void 0 ? {} : _temp4,
1464
+ onUpdate = _ref4.onUpdate;
1456
1465
  try {
1457
1466
  var _this17 = this;
1458
1467
  if (onUpdate) {
@@ -1512,12 +1521,12 @@ var WSAPI = /*#__PURE__*/function () {
1512
1521
  * @param params
1513
1522
  */
1514
1523
  ;
1515
- _proto.getInboxMessages = function getInboxMessages(_temp4) {
1516
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
1517
- from = _ref4.from,
1518
- to = _ref4.to,
1519
- onlyFavorite = _ref4.onlyFavorite,
1520
- onUpdate = _ref4.onUpdate;
1524
+ _proto.getInboxMessages = function getInboxMessages(_temp5) {
1525
+ var _ref5 = _temp5 === void 0 ? {} : _temp5,
1526
+ from = _ref5.from,
1527
+ to = _ref5.to,
1528
+ onlyFavorite = _ref5.onlyFavorite,
1529
+ onUpdate = _ref5.onUpdate;
1521
1530
  try {
1522
1531
  var _this21 = this;
1523
1532
  if (onUpdate) {
@@ -1642,7 +1651,7 @@ var WSAPI = /*#__PURE__*/function () {
1642
1651
  _proto.updateOnPrizeWin = function updateOnPrizeWin(data) {
1643
1652
  try {
1644
1653
  var _this31 = this;
1645
- var _temp6 = function () {
1654
+ var _temp7 = function () {
1646
1655
  if (data.errCode === exports.SAWSpinErrorCode.SAW_OK) {
1647
1656
  return Promise.resolve(OCache.use(onUpdateContextKey.Saw, exports.ECacheContext.WSAPI, function () {
1648
1657
  return _this31.api.sawGetTemplatesT(null);
@@ -1656,18 +1665,18 @@ var WSAPI = /*#__PURE__*/function () {
1656
1665
  var prizeType = (_template$prizes$find = template.prizes.find(function (p) {
1657
1666
  return p.id === data.saw_prize_id;
1658
1667
  })) == null ? void 0 : _template$prizes$find.prize_type;
1659
- var _temp5 = function () {
1668
+ var _temp6 = function () {
1660
1669
  if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === exports.MiniGamePrizeTypeName.JACKPOT || prizeType === exports.MiniGamePrizeTypeName.SPIN) {
1661
1670
  return Promise.resolve(_this31.api.sawGetTemplatesT(null)).then(function (updatedTemplates) {
1662
1671
  _this31.updateEntity(onUpdateContextKey.Saw, updatedTemplates);
1663
1672
  });
1664
1673
  }
1665
1674
  }();
1666
- if (_temp5 && _temp5.then) return _temp5.then(function () {});
1675
+ if (_temp6 && _temp6.then) return _temp6.then(function () {});
1667
1676
  });
1668
1677
  }
1669
1678
  }();
1670
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
1679
+ return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
1671
1680
  } catch (e) {
1672
1681
  return Promise.reject(e);
1673
1682
  }
@@ -1759,7 +1768,7 @@ var WSAPI = /*#__PURE__*/function () {
1759
1768
  return Promise.reject(e);
1760
1769
  }
1761
1770
  }, JACKPOT_TEMPLATE_CACHE_SEC)).then(function (_OCache$use) {
1762
- function _temp8() {
1771
+ function _temp9() {
1763
1772
  return jackpots.map(function (jp) {
1764
1773
  var _jp = _extends({}, jp, {
1765
1774
  pot: pots.find(function (p) {
@@ -1770,7 +1779,7 @@ var WSAPI = /*#__PURE__*/function () {
1770
1779
  });
1771
1780
  }
1772
1781
  jackpots = _OCache$use;
1773
- var _temp7 = function () {
1782
+ var _temp8 = function () {
1774
1783
  if (jackpots.length > 0) {
1775
1784
  return Promise.resolve(OCache.use(onUpdateContextKey.Pots, exports.ECacheContext.WSAPI, function () {
1776
1785
  try {
@@ -1788,7 +1797,7 @@ var WSAPI = /*#__PURE__*/function () {
1788
1797
  });
1789
1798
  }
1790
1799
  }();
1791
- return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
1800
+ return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
1792
1801
  });
1793
1802
  } catch (e) {
1794
1803
  return Promise.reject(e);
@@ -2409,19 +2418,28 @@ var SmarticoAPI = /*#__PURE__*/function () {
2409
2418
  return Promise.reject(e);
2410
2419
  }
2411
2420
  };
2412
- _proto.storeGetPurchasedItems = function storeGetPurchasedItems(user_ext_id) {
2421
+ _proto.storeGetPurchasedItems = function storeGetPurchasedItems(user_ext_id, limit, offset) {
2422
+ if (limit === void 0) {
2423
+ limit = 20;
2424
+ }
2425
+ if (offset === void 0) {
2426
+ offset = 0;
2427
+ }
2413
2428
  try {
2414
2429
  var _this25 = this;
2415
- var message = _this25.buildMessage(user_ext_id, exports.ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST);
2430
+ var message = _this25.buildMessage(user_ext_id, exports.ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST, {
2431
+ limit: limit,
2432
+ offset: offset
2433
+ });
2416
2434
  return Promise.resolve(_this25.send(message, exports.ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE));
2417
2435
  } catch (e) {
2418
2436
  return Promise.reject(e);
2419
2437
  }
2420
2438
  };
2421
- _proto.storeGetPurchasedItemsT = function storeGetPurchasedItemsT(user_ext_id) {
2439
+ _proto.storeGetPurchasedItemsT = function storeGetPurchasedItemsT(user_ext_id, limit, offset) {
2422
2440
  try {
2423
2441
  var _this26 = this;
2424
- return Promise.resolve(_this26.storeGetPurchasedItems(user_ext_id)).then(function (_this26$storeGetPurch) {
2442
+ return Promise.resolve(_this26.storeGetPurchasedItems(user_ext_id, limit, offset)).then(function (_this26$storeGetPurch) {
2425
2443
  return StoreItemPurchasedTransform(_this26$storeGetPurch.items);
2426
2444
  });
2427
2445
  } catch (e) {