@smartico/public-api 0.0.126 → 0.0.128

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.126",
3
+ "version": "0.0.128",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,4 +4,5 @@ import { ProtocolMessage } from "../Base/ProtocolMessage";
4
4
  export interface GetJackpotsRequest extends ProtocolMessage {
5
5
 
6
6
  related_game_id?: string;
7
+ jp_template_id?: number;
7
8
  }
@@ -4,6 +4,6 @@ import { JackpotDetails } from "./JackpotDetails";
4
4
 
5
5
  export interface GetJackpotsResponse extends ProtocolResponse {
6
6
 
7
- jackpots: JackpotDetails[];
7
+ items: JackpotDetails[];
8
8
  }
9
9
 
@@ -0,0 +1,6 @@
1
+ interface JackpotHtmlTemplate {
2
+ id: string;
3
+ content: string;
4
+ }
5
+
6
+ export { JackpotHtmlTemplate };
@@ -4,7 +4,6 @@ interface JackpotPot {
4
4
  jp_pot_id: number;
5
5
  current_pot_amount: number;
6
6
  explode_date_ts: number;
7
- // last_exploded_pot?: JackpotPot;
8
7
  }
9
8
 
10
9
  export { JackpotPot }
@@ -1,7 +1,10 @@
1
+ import { JackpotHtmlTemplate } from './JackpotHtmlTemplate';
1
2
  interface JackpotPublicMeta {
2
3
  name: string;
3
4
  description: string;
4
5
  image_url: string;
6
+ winner_template: JackpotHtmlTemplate;
7
+ not_winner_template: JackpotHtmlTemplate;
5
8
  }
6
9
 
7
10
 
@@ -12,4 +12,5 @@ export * from './JackpotWinPush';
12
12
  export * from './JackpotsOptinRequest';
13
13
  export * from './JackpotsOptinResponse';
14
14
  export * from './JackpotsOptoutRequest';
15
- export * from './JackpotsOptoutResponse';
15
+ export * from './JackpotsOptoutResponse';
16
+ export * from './JackpotHtmlTemplate';
package/src/NodeCache.ts CHANGED
@@ -35,6 +35,13 @@ class NodeCache {
35
35
  }
36
36
  }
37
37
 
38
+ public remove(key: string) {
39
+ if (NodeCache.cache.hasOwnProperty(key)) {
40
+ delete NodeCache.cache[key];
41
+
42
+ }
43
+ }
44
+
38
45
  public flushAll() {
39
46
  NodeCache.cache = {};
40
47
  }
package/src/OCache.ts CHANGED
@@ -53,7 +53,15 @@ export class OCache {
53
53
  }
54
54
  }
55
55
 
56
- public static async clear(cacheContext: ECacheContext) {
56
+ public static async clear(cacheContext: ECacheContext, oKey: any) {
57
+ const key = cacheContext.toString() + '_' + JSON.stringify(oKey);
58
+
59
+ if (this.cache[cacheContext]) {
60
+ this.cache[cacheContext].remove(key);
61
+ }
62
+ }
63
+
64
+ public static async clearContext(cacheContext: ECacheContext) {
57
65
  if (this.cache[cacheContext]) {
58
66
  this.cache[cacheContext].flushAll();
59
67
  }
@@ -22,6 +22,7 @@ import { getLeaderBoardTransform } from "./Leaderboard/LeaderBoards";
22
22
  import { GetAchievementsUserInfoResponse } from "./Core/GetAchievementsUserInfoResponse";
23
23
  import { CheckSegmentMatchResponse } from "./Core/CheckSegmentMatchResponse";
24
24
  import { CheckSegmentMatchRequest } from "./Core/CheckSegmentMatchRequest";
25
+ import { GetJackpotsPotsRequest, GetJackpotsPotsResponse, GetJackpotsRequest, GetJackpotsResponse, JackpotDetails, JackpotPot, JackpotsOptinRequest, JackpotsOptinResponse, JackpotsOptoutRequest, JackpotsOptoutResponse } from "./Jackpots";
25
26
 
26
27
  const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
27
28
  const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
@@ -282,9 +283,31 @@ class SmarticoAPI {
282
283
  const results = await this.send<CheckSegmentMatchResponse>(message, ClassId.CHECK_SEGMENT_MATCH_RESPONSE);
283
284
 
284
285
  return results.segments || [];
285
- }
286
+ }
287
+
288
+ public async jackpotGet(user_ext_id: string, filter?: { related_game_id?: string, jp_template_id?: number }): Promise<JackpotDetails[]> {
289
+ const message = this.buildMessage<GetJackpotsRequest, GetJackpotsResponse>(user_ext_id, ClassId.JP_GET_JACKPOTS_REQUEST, filter);
290
+ const response = await this.send<GetJackpotsResponse>(message, ClassId.JP_GET_JACKPOTS_RESPONSE);
291
+
292
+ return response?.items || [];
293
+ }
286
294
 
295
+ public async potGet(user_ext_id: string, filter: { jp_template_ids: number[] }): Promise<JackpotPot[]> {
296
+ const message = this.buildMessage<GetJackpotsPotsRequest, GetJackpotsPotsResponse>(user_ext_id, ClassId.JP_GET_JACKPOTS_REQUEST, filter);
297
+ const response = await this.send<GetJackpotsPotsResponse>(message, ClassId.JP_GET_LATEST_POTS_RESPONSE);
287
298
 
299
+ return response?.items || [];
300
+ }
301
+
302
+ public async jackpotOptIn(user_ext_id: string, payload: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
303
+ const message = this.buildMessage<JackpotsOptinRequest, JackpotsOptinResponse>(user_ext_id, ClassId.JP_OPTIN_REQUEST, payload);
304
+ return await this.send<JackpotsOptinResponse>(message, ClassId.JP_OPTIN_RESPONSE);
305
+ }
306
+
307
+ public async jackpotOptOut(user_ext_id: string, payload: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
308
+ const message = this.buildMessage<JackpotsOptoutRequest, JackpotsOptoutResponse>(user_ext_id, ClassId.JP_OPTOUT_REQUEST, payload);
309
+ return await this.send<JackpotsOptoutResponse>(message, ClassId.JP_OPTOUT_RESPONSE);
310
+ }
288
311
 
289
312
  public async sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode: boolean = false): Promise<SAWGetTemplatesResponse> {
290
313