@smartico/public-api 0.0.173 → 0.0.174

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/docs/README.md CHANGED
@@ -60,6 +60,7 @@
60
60
  - [TUICustomSection](interfaces/TUICustomSection.md)
61
61
  - [TBonus](interfaces/TBonus.md)
62
62
  - [TClaimBonusResult](interfaces/TClaimBonusResult.md)
63
+ - [TSawHistory](interfaces/TSawHistory.md)
63
64
 
64
65
  ## General API
65
66
 
@@ -415,6 +415,42 @@ _smartico.vapi('EN').getMiniGames().then((result) => {
415
415
 
416
416
  ___
417
417
 
418
+ ### getMiniGamesHistory
419
+
420
+ ▸ **getMiniGamesHistory**(`«destructured»?`): `Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
421
+
422
+ Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
423
+ The maximum number of items per request is limited to 20.
424
+ You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
425
+ 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 getMiniGamesHistory with a new onUpdate callback, the old one will be overwritten by the new one.
426
+ Updated templates will be passed to onUpdate callback.
427
+
428
+ **Example**:
429
+ ```
430
+ _smartico.api.getMiniGamesHistory().then((result) => {
431
+ console.log(result);
432
+ });
433
+ ```
434
+
435
+ **Visitor mode: not supported**
436
+
437
+ #### Parameters
438
+
439
+ | Name | Type |
440
+ | :------ | :------ |
441
+ | `«destructured»` | `Object` |
442
+ | › `limit?` | `number` |
443
+ | › `offset?` | `number` |
444
+ | › `saw_template_id?` | `number` |
445
+ | › `onUpdate?` | (`data`: [`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]) => `void` |
446
+
447
+ #### Returns
448
+
449
+ `Promise`\<[`TSawHistory`](../interfaces/TSawHistory.md)[]\>
450
+
451
+ ___
452
+
453
+
418
454
  ### playMiniGame
419
455
 
420
456
  ▸ **playMiniGame**(`template_id`, `«destructured»?`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
@@ -0,0 +1,53 @@
1
+ # Interface: TSawHistory
2
+
3
+ TSawHistory describes the information of the history of mini-games.
4
+
5
+ ## Properties
6
+
7
+ ### template
8
+
9
+ • **template**: `SAWTemplate`
10
+
11
+ The initial information about mini-game.
12
+
13
+ ___
14
+
15
+ ### saw_template_id
16
+
17
+ • **saw_template_id**: `number`
18
+
19
+ ID of the mini-game template.
20
+
21
+ ___
22
+
23
+ ### saw_prize_id
24
+
25
+ • **saw_prize_id**: `number`
26
+
27
+ The saw_prize_id that user won, details of the prize can be found in the mini-game definition.
28
+
29
+ ___
30
+
31
+ ### prize_amount
32
+
33
+ • **prize_amount**: `number`
34
+
35
+ Amount of prizes in stock.
36
+
37
+ ___
38
+
39
+ ### client_request_id
40
+
41
+ • **client_request_id**: `string`
42
+
43
+ Request ID that client is sending to show history.
44
+
45
+ ___
46
+
47
+ ### is_claimed
48
+
49
+ • **is_claimed**: `boolean`
50
+
51
+ Flag indicating to show whether prize in the mini-game claimed or not.
52
+
53
+ ___
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.173",
3
+ "version": "0.0.174",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -126,6 +126,9 @@ export enum ClassId {
126
126
  SAW_AKNOWLEDGE_BATCH_REQUEST = 714,
127
127
  SAW_AKNOWLEDGE_BATCH_RESPONSE = 715,
128
128
 
129
+ GET_SAW_HISTORY_REQUEST = 716,
130
+ GET_SAW_HISTORY_RESPONSE = 717,
131
+
129
132
  /*
130
133
  !Important, if adding new messages that are 'acting' on behalf of the client,
131
134
  you need to include them in the CLASS_ID_IGNORE_FOR_SIMULATION
@@ -52,6 +52,9 @@ export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[]
52
52
  pool: p.pool,
53
53
  pool_initial: p.pool_initial,
54
54
  wins_count: p.wins_count,
55
+ weekdays: p.weekdays,
56
+ active_from_ts: p.active_from_ts,
57
+ active_till_ts: p.active_till_ts,
55
58
  };
56
59
  return y;
57
60
  }),
@@ -12,4 +12,7 @@ export interface SAWPrize {
12
12
  pool?: number;
13
13
  pool_initial?: number;
14
14
  wins_count?: number;
15
+ weekdays?: number[];
16
+ active_from_ts?: number;
17
+ active_till_ts?: number;
15
18
  }
@@ -0,0 +1,8 @@
1
+ import { ProtocolMessage } from "../Base/ProtocolMessage";
2
+
3
+ export interface SAWWinningHistoryRequest extends ProtocolMessage {
4
+ limit: number;
5
+ offset: number;
6
+ saw_template_id?: number;
7
+ only_claimed?: boolean;
8
+ }
@@ -0,0 +1,31 @@
1
+ import { ProtocolResponse } from "../SmarticoLib";
2
+ import { TSawHistory } from "../WSAPI/WSAPITypes";
3
+ import { SAWTemplate } from "./SAWTemplate";
4
+
5
+ export interface SAWWinningHistoryResponse extends ProtocolResponse {
6
+ prizes: SAWPrizesHistory[];
7
+ }
8
+
9
+ export interface SAWPrizesHistory {
10
+ template: SAWTemplate,
11
+ saw_template_id: number,
12
+ saw_prize_id: number,
13
+ prize_amount: number,
14
+ client_request_id: string,
15
+ is_claimed: boolean,
16
+ }
17
+
18
+ export const SAWHistoryTransform = (items: SAWPrizesHistory[]): TSawHistory[] => {
19
+ return items.map((r) => {
20
+ const x: TSawHistory = {
21
+ template: r.template,
22
+ saw_template_id: r.saw_template_id,
23
+ saw_prize_id: r.saw_prize_id,
24
+ prize_amount: r.prize_amount,
25
+ client_request_id: r.client_request_id,
26
+ is_claimed: r.is_claimed
27
+ }
28
+ return x;
29
+ })
30
+ }
31
+
@@ -22,3 +22,5 @@ export * from './SAWPrizeDropAknowledgeRequest';
22
22
  export * from './SAWPrizeDropAknowledgeResponse';
23
23
  export * from './SAWEventSawPush';
24
24
  export * from './SAWAcknowledgeSpinPushRequest';
25
+ export * from './SAWWinningHistoryRequest';
26
+ export * from './SAWWinningHistoryResponse';
@@ -2,4 +2,5 @@ import { ProtocolMessage } from '../Base/ProtocolMessage';
2
2
 
3
3
  export interface GetRelatedAchTourRequest extends ProtocolMessage {
4
4
  related_game_id?: string;
5
+ force_language?: string;
5
6
  }
@@ -10,8 +10,13 @@ import {
10
10
  SAWDoAknowledgeResponse,
11
11
  SAWDoSpinRequest,
12
12
  SAWDoSpinResponse,
13
+ SAWHistoryTransform,
14
+ SAWPrizesHistory,
13
15
  SAWSpinErrorCode,
16
+ SAWTemplate,
14
17
  SAWTemplatesTransform,
18
+ SAWWinningHistoryRequest,
19
+ SAWWinningHistoryResponse,
15
20
  } from './MiniGames';
16
21
  import { ECacheContext, OCache } from './OCache';
17
22
  import {
@@ -89,6 +94,7 @@ import {
89
94
  TSegmentCheckResult,
90
95
  TUICustomSection,
91
96
  TBonus,
97
+ TSawHistory,
92
98
  } from './WSAPI/WSAPITypes';
93
99
  import { getLeaderBoardTransform } from './Leaderboard/LeaderBoards';
94
100
  import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
@@ -584,6 +590,18 @@ class SmarticoAPI {
584
590
  return { ...spinAttemptResponse };
585
591
  }
586
592
 
593
+ public async getSawWinningHistory(user_ext_id: string, limit: number = 20, offset: number = 0, saw_template_id: number): Promise<SAWWinningHistoryResponse> {
594
+ const message = this.buildMessage<SAWWinningHistoryRequest, SAWWinningHistoryResponse>(user_ext_id, ClassId.GET_SAW_HISTORY_REQUEST, {
595
+ limit, offset, saw_template_id
596
+ })
597
+
598
+ return await this.send<SAWWinningHistoryResponse>(message, ClassId.GET_SAW_HISTORY_RESPONSE);
599
+ }
600
+
601
+ public async getSawWinningHistoryT(user_ext_id: string, limit?: number, offset?: number, saw_template_id?: number): Promise<SAWPrizesHistory[]> {
602
+ return SAWHistoryTransform((await this.getSawWinningHistory(user_ext_id, limit, offset, saw_template_id)).prizes);
603
+ }
604
+
587
605
  public async missionOptIn(user_ext_id: string, mission_id: number) {
588
606
  if (!mission_id) {
589
607
  throw new Error('Missing mission id');
@@ -1075,7 +1093,7 @@ class SmarticoAPI {
1075
1093
  return new WSAPI(this);
1076
1094
  }
1077
1095
 
1078
- public async getRelatedItemsForGame(user_ext_id: string, related_game_id: string,): Promise<GetRelatedAchTourResponse> {
1096
+ public async getRelatedItemsForGame(user_ext_id: string, related_game_id: string, force_language?: string,): Promise<GetRelatedAchTourResponse> {
1079
1097
  const message = this.buildMessage< GetRelatedAchTourRequest, GetRelatedAchTourResponse>(
1080
1098
  user_ext_id,
1081
1099
  ClassId.GET_RELATED_ACH_N_TOURNAMENTS_REQUEST,
@@ -1084,7 +1102,7 @@ class SmarticoAPI {
1084
1102
  }
1085
1103
  );
1086
1104
 
1087
- return await this.send<GetRelatedAchTourResponse>(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE);
1105
+ return await this.send<GetRelatedAchTourResponse>(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE, force_language);
1088
1106
 
1089
1107
  }
1090
1108
  }
@@ -1,6 +1,6 @@
1
1
  import { ClassId } from '../Base/ClassId';
2
2
  import { CoreUtils } from '../Core';
3
- import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWGetTemplatesResponse, SAWSpinErrorCode, SAWSpinsCountPush } from '../MiniGames';
3
+ import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWGetTemplatesResponse, SAWSpinErrorCode, SAWSpinsCountPush, SAWWinningHistoryRequest, SAWWinningHistoryResponse } from '../MiniGames';
4
4
  import { ECacheContext, OCache } from '../OCache';
5
5
  import { SmarticoAPI } from '../SmarticoAPI';
6
6
  import {
@@ -27,7 +27,8 @@ import {
27
27
  TUserProfile,
28
28
  UserLevelExtraCountersT,TBonus,
29
29
  TClaimBonusResult,
30
- TMiniGamePlayBatchResult
30
+ TMiniGamePlayBatchResult,
31
+ TSawHistory
31
32
  } from './WSAPITypes';
32
33
  import { LeaderBoardPeriodType } from '../Leaderboard';
33
34
  import {
@@ -455,6 +456,42 @@ export class WSAPI {
455
456
  return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
456
457
  }
457
458
 
459
+ /**
460
+ * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
461
+ * The maximum number of items per request is limited to 20.
462
+ * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
463
+ * 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 getMiniGamesHistory with a new onUpdate callback, the old one will be overwritten by the new one.
464
+ * Updated templates will be passed to onUpdate callback.
465
+ *
466
+ * **Example**:
467
+ * ```
468
+ * _smartico.api.getMiniGamesHistory().then((result) => {
469
+ * console.log(result);
470
+ * });
471
+ * ```
472
+ *
473
+ * **Visitor mode: not supported**
474
+ */
475
+
476
+ public async getMiniGamesHistory({
477
+ limit,
478
+ offset,
479
+ saw_template_id,
480
+ onUpdate
481
+ } : { limit?: number, offset?: number, saw_template_id?: number, onUpdate?: (data: TMiniGameTemplate[]) => void }): Promise<TSawHistory[]> {
482
+
483
+ if (onUpdate) {
484
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
485
+ }
486
+
487
+ return OCache.use(
488
+ onUpdateContextKey.Saw,
489
+ ECacheContext.WSAPI,
490
+ () => this.api.getSawWinningHistoryT(null, limit, offset, saw_template_id),
491
+ CACHE_DATA_SEC,
492
+ );
493
+ }
494
+
458
495
  /**
459
496
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
460
497
  * After playMiniGame is called, you can call getMiniGames to get the list of mini-games.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 playMiniGame with a new onUpdate callback, the old one will be overwritten by the new one.
@@ -964,9 +1001,9 @@ export class WSAPI {
964
1001
  * });
965
1002
  * ```
966
1003
  */
967
- public async getRelatedItemsForGame(related_game_id: string): Promise<GetAchievementMapResponse> {
1004
+ public async getRelatedItemsForGame(related_game_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
968
1005
 
969
- const result = await this.api.getRelatedItemsForGame(null, related_game_id);
1006
+ const result = await this.api.getRelatedItemsForGame(null, related_game_id, force_language);
970
1007
  return result;
971
1008
 
972
1009
  }
@@ -1,5 +1,5 @@
1
1
  import { BuyStoreItemErrorCode } from '../Store';
2
- import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWSpinErrorCode } from '../MiniGames';
2
+ import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWSpinErrorCode, SAWTemplate } from '../MiniGames';
3
3
  import { TournamentRegistrationError, TournamentRegistrationStatusName, TournamentRegistrationTypeName } from '../Tournaments';
4
4
  import { AchCategory } from '../Missions';
5
5
  import { LeaderBoardPeriodType } from '../Leaderboard';
@@ -41,6 +41,12 @@ export interface TMiniGamePrize {
41
41
  pool_initial?: number;
42
42
  /* Number of wins in game */
43
43
  wins_count?: number;
44
+ /* Number of days of week, when the prize can be available */
45
+ weekdays?: number[];
46
+ /* Holds time from which prize will become available, for the prizes that are targeted to be available from specific date/time */
47
+ active_from_ts?: number;
48
+ /* Holds time till which prize will become available, for the prizes that are targeted to be available from specific date/time */
49
+ active_till_ts?: number;
44
50
  }
45
51
 
46
52
  /**
@@ -747,3 +753,18 @@ export interface TClaimBonusResult {
747
753
  /** If the bonus was claimed successfully, then success is true */
748
754
  success?: boolean;
749
755
  }
756
+
757
+ export interface TSawHistory {
758
+ /** The initial information about mini-game */
759
+ template: SAWTemplate,
760
+ /** ID of the mini-game template */
761
+ saw_template_id: number,
762
+ /** The saw_prize_id that user won, details of the prize can be found in the mini-game definition */
763
+ saw_prize_id: number,
764
+ /** Amount of prizes in stock */
765
+ prize_amount: number,
766
+ /** Request ID that client is sending to show history*/
767
+ client_request_id: string,
768
+ /** Flag indicating to show whether prize in the mini-game claimed or not */
769
+ is_claimed: boolean,
770
+ }