@smartico/public-api 0.0.69 → 0.0.71

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
@@ -23,6 +23,21 @@ _smartico.api.levelsGet().then( levels => {
23
23
 
24
24
  ```
25
25
 
26
+ Some methods can be called with onUpdate callback, which is executed when there are changes in the underlying data.
27
+ Example:
28
+
29
+ ```javascript
30
+
31
+ var miniGamesUpdates = (games) => {
32
+ console.log('There are ' + games.length + ' games available now');
33
+ }
34
+
35
+ _smartico.api.getMiniGames( { onUpdate: miniGamesUpdates} ).then( games => {
36
+ console.log('There are ' + games.length + ' games available');
37
+ });
38
+
39
+ ```
40
+
26
41
  See the [API documentation](docs/classes/WSAPI.md) for all available methods and returning data.
27
42
 
28
43
 
package/dist/OCache.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export declare enum ECacheContext {
2
2
  Translations = 0,
3
- LabelInfo = 1
3
+ LabelInfo = 1,
4
+ WSAPI = 2
4
5
  }
5
6
  export declare class OCache {
6
7
  private static cache;
8
+ private static init;
7
9
  static get<T>(oKey: any, cacheContext: ECacheContext): T | undefined;
8
10
  static set(oKey: any, o: any, cacheContext: ECacheContext, ttlSeconds?: number): void;
9
11
  static use<T>(oKey: any, cacheContext: ECacheContext, f: () => Promise<T>, ttlSeconds?: number): Promise<T>;
@@ -1,7 +1,7 @@
1
1
  import { ClassId } from "./Base/ClassId";
2
2
  import { SAWGetTemplatesResponse } from './MiniGames/SAWGetTemplatesResponse';
3
3
  import { ILogger } from './ILogger';
4
- import { SAWDoSpinResponse } from './MiniGames';
4
+ import { SAWDoAknowledgeResponse, SAWDoSpinResponse } from './MiniGames';
5
5
  import { GetTranslationsResponse, ResponseIdentify, TranslationArea } from './Core';
6
6
  import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
7
7
  import { GetInboxMessagesResponse } from './Inbox';
@@ -15,6 +15,7 @@ import { TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TStoreItem,
15
15
  interface Tracker {
16
16
  label_api_key: string;
17
17
  userPublicProps: any;
18
+ on: (callBackKey: ClassId, func: (data: any) => void) => void;
18
19
  }
19
20
  interface IOptions {
20
21
  logger?: ILogger;
@@ -53,6 +54,7 @@ declare class SmarticoAPI {
53
54
  }>;
54
55
  sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode?: boolean): Promise<SAWGetTemplatesResponse>;
55
56
  sawGetTemplatesT(user_ext_id: string): Promise<TMiniGameTemplate[]>;
57
+ doAcknowledgeRequest(user_ext_id: string, request_id: string): Promise<SAWDoAknowledgeResponse>;
56
58
  sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse>;
57
59
  inboxGetMessages(user_ext_id: string, limit?: number, offset?: number): Promise<GetInboxMessagesResponse>;
58
60
  storeGetItems(user_ext_id: string): Promise<GetStoreItemsResponse>;
@@ -3,26 +3,44 @@ import { TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOrBadge, TStore
3
3
  /** @group General API */
4
4
  export declare class WSAPI {
5
5
  private api;
6
+ private onUpdateCallback;
6
7
  /** @private */
7
8
  constructor(api: SmarticoAPI);
8
9
  /** Returns information about current user */
9
10
  getUserProfile(): TUserProfile;
10
11
  /** Returns all the levels available the current user */
11
12
  getLevels(): Promise<TLevel[]>;
12
- /** Returns all the missions available the current user */
13
- getMissions(): Promise<TMissionOrBadge[]>;
13
+ /** Returns all the missions available the current user.
14
+ * The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
15
+ * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
16
+ getMissions({ onUpdate }?: {
17
+ onUpdate?: (data: TMissionOrBadge[]) => void;
18
+ }): Promise<TMissionOrBadge[]>;
14
19
  /** Returns all the badges available the current user */
15
20
  getBadges(): Promise<TMissionOrBadge[]>;
16
21
  /** Returns all the store items available the current user */
17
22
  getStoreItems(): Promise<TStoreItem[]>;
18
23
  /** Returns store categories */
19
24
  getStoreCategories(): Promise<TStoreItem[]>;
20
- /** Returns the list of mini-games available for user */
21
- getMiniGames(): Promise<TMiniGameTemplate[]>;
25
+ /** Returns the list of mini-games available for user
26
+ * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
27
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one. Updated templates will be passed to onUpdate callback. */
28
+ getMiniGames({ onUpdate }?: {
29
+ onUpdate?: (data: TMiniGameTemplate[]) => void;
30
+ }): Promise<TMiniGameTemplate[]>;
22
31
  /** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */
23
32
  playMiniGame(template_id: number): Promise<TMiniGamePlayResult>;
24
- /** Returns all the active instances of tournaments */
25
- getTournamentsList(): Promise<TTournament[]>;
33
+ /** Returns all the active instances of tournaments
34
+ * The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
35
+ * The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
36
+ getTournamentsList({ onUpdate }?: {
37
+ onUpdate?: (data: TTournament[]) => void;
38
+ }): Promise<TTournament[]>;
26
39
  /** Returns details information of specific tournament instance, the response will includ tournamnet info and the leaderboard of players */
27
40
  getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed>;
41
+ private updateOnSpin;
42
+ private updateOnPrizeWin;
43
+ private updateMissionsOnOptIn;
44
+ private updateTournamentsOnRegistration;
45
+ private updateEntity;
28
46
  }
@@ -45,8 +45,11 @@ export interface TMiniGameTemplate {
45
45
  saw_game_type: SAWGameTypeName;
46
46
  /** How the user is charged for each game attempt e.g. Free, Points or Spin attempts */
47
47
  saw_buyin_type: SAWBuyInTypeName;
48
+ /** in case of charging type 'Points', what is the points amount will be deducted from user balance */
48
49
  buyin_cost_points: number;
50
+ /** in case of charging type 'Spin attempts', shows the current number of spin attempts that user has */
49
51
  spin_count?: number;
52
+ /** if the game is limit to the number of spins that user can do during period of time, this property shows the epoch time in UTC when the next attempt will be available */
50
53
  next_available_spin_ts: number;
51
54
  /** The message that should be shown to the user when he cannot play the game, server rejected attempt with error code SAWSpinErrorCode.SAW_FAILED_MAX_SPINS_REACHED */
52
55
  over_limit_message: string;