@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.
@@ -203,12 +203,14 @@ ___
203
203
 
204
204
  ▸ **getStorePurchasedItems**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
205
205
 
206
- Returns all the purchased store items available the current user
206
+ Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
207
+ The maximum number of items per request is limited to 20.
208
+ You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
207
209
  Example usage:
208
210
  ```
209
211
  _smartico.api.getStorePurchasedItems().then((result) => {
210
212
  console.log(result);
211
- });
213
+ });
212
214
  ```
213
215
 
214
216
  #### Returns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.137",
3
+ "version": "0.0.138",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -465,14 +465,18 @@ class SmarticoAPI {
465
465
  return StoreCategoryTransform((await this.storeGetCategories(user_ext_id)).categories);
466
466
  }
467
467
 
468
- public async storeGetPurchasedItems(user_ext_id: string): Promise<GetStoreHistoryResponse> {
468
+ public async storeGetPurchasedItems(user_ext_id: string, limit: number = 20, offset: number = 0): Promise<GetStoreHistoryResponse> {
469
+
470
+ const message = this.buildMessage<GetStoreHistoryRequest, GetStoreHistoryResponse>(user_ext_id, ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST, {
471
+ limit,
472
+ offset
473
+ });
469
474
 
470
- const message = this.buildMessage<any, GetStoreHistoryResponse>(user_ext_id, ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST);
471
475
  return await this.send<GetStoreHistoryResponse>(message, ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE);
472
476
  }
473
477
 
474
- public async storeGetPurchasedItemsT(user_ext_id: string): Promise<TStoreItem[]> {
475
- return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id)).items);
478
+ public async storeGetPurchasedItemsT(user_ext_id: string, limit?: number, offset?: number): Promise<TStoreItem[]> {
479
+ return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items);
476
480
  }
477
481
 
478
482
  public async missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse> {
@@ -1,6 +1,6 @@
1
1
  import { ProtocolMessage } from "../Base/ProtocolMessage";
2
2
 
3
3
  export interface GetStoreHistoryRequest extends ProtocolMessage {
4
- offset?: number;
5
4
  limit?: number;
5
+ offset?: number;
6
6
  }
@@ -3,5 +3,5 @@ import { StoreItemPurchased } from "./StoreItemPurchased";
3
3
 
4
4
  export interface GetStoreHistoryResponse extends ProtocolResponse {
5
5
  items: StoreItemPurchased[];
6
- hasMore: boolean;
6
+ hasMore?: boolean;
7
7
  }
@@ -6,7 +6,6 @@ import { SmarticoAPI } from "../SmarticoAPI";
6
6
  import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
7
7
  import { LeaderBoardPeriodType } from "../Leaderboard";
8
8
  import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutResponse } from "../Jackpots";
9
- import { AchRelatedGame } from "src/Base/AchRelatedGame";
10
9
 
11
10
  /** @hidden */
12
11
  const CACHE_DATA_SEC = 30;
@@ -51,7 +50,7 @@ export class WSAPI {
51
50
  on(ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, () => this.updateInboxMessages());
52
51
  on(ClassId.LOGOUT_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
53
52
  on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
54
- on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache())
53
+ on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
55
54
  }
56
55
 
57
56
  /** Returns information about current user
@@ -189,7 +188,9 @@ export class WSAPI {
189
188
  return OCache.use(onUpdateContextKey.StoreCategories, ECacheContext.WSAPI, () => this.api.storeGetCategoriesT(null), CACHE_DATA_SEC);
190
189
  }
191
190
 
192
- /** Returns all the purchased store items available the current user
191
+ /** Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
192
+ * The maximum number of items per request is limited to 20.
193
+ * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
193
194
  * Example usage:
194
195
  * ```
195
196
  * _smartico.api.getStorePurchasedItems().then((result) => {
@@ -198,8 +199,11 @@ export class WSAPI {
198
199
  * ```
199
200
  */
200
201
 
201
- public async getStorePurchasedItems(): Promise<TStoreItem[]> {
202
- return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetPurchasedItemsT(null), CACHE_DATA_SEC);
202
+ public async getStorePurchasedItems({ limit, offset, onUpdate } : { limit?: number, offset?: number, onUpdate?: (data: TStoreItem[]) => void} = {}): Promise<TStoreItem[]> {
203
+ if (onUpdate) {
204
+ this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
205
+ }
206
+ return OCache.use(onUpdateContextKey.StoreHistory, ECacheContext.WSAPI, () => this.api.storeGetPurchasedItemsT(null, limit, offset), CACHE_DATA_SEC);
203
207
  }
204
208
 
205
209
  /** Returns missions & badges categories */