@smartico/public-api 0.0.173 → 0.0.175

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,41 @@ _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
+
418
453
  ### playMiniGame
419
454
 
420
455
  ▸ **playMiniGame**(`template_id`, `«destructured»?`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
@@ -5,3 +5,9 @@
5
5
  ### Main
6
6
 
7
7
  • **Main** = ``1``
8
+
9
+ ___
10
+
11
+ ### Personal
12
+
13
+ • **Personal** = ``2``
@@ -16,7 +16,7 @@ ___
16
16
 
17
17
  ### jp\_type\_id
18
18
 
19
- • **jp\_type\_id**: [`Main`](../enums/JackpotType.md#main)
19
+ • **jp\_type\_id**: [`JackpotType`](../enums/JackpotType.md)
20
20
 
21
21
  type of jackpot logic
22
22
 
@@ -99,3 +99,21 @@ ___
99
99
  ### wins\_count
100
100
 
101
101
  • `Optional` **wins\_count**: `number`
102
+
103
+ ___
104
+
105
+ ### weekdays
106
+
107
+ • `Optional` **weekdays**: `number`[]
108
+
109
+ ___
110
+
111
+ ### active\_from\_ts
112
+
113
+ • `Optional` **active\_from\_ts**: `number`
114
+
115
+ ___
116
+
117
+ ### active\_till\_ts
118
+
119
+ • `Optional` **active\_till\_ts**: `number`
@@ -0,0 +1,49 @@
1
+ # Interface: TSawHistory
2
+
3
+ ## Properties
4
+
5
+ ### template
6
+
7
+ • **template**: `SAWTemplate`
8
+
9
+ The initial information about mini-game
10
+
11
+ ___
12
+
13
+ ### saw\_template\_id
14
+
15
+ • **saw\_template\_id**: `number`
16
+
17
+ ID of the mini-game template
18
+
19
+ ___
20
+
21
+ ### saw\_prize\_id
22
+
23
+ • **saw\_prize\_id**: `number`
24
+
25
+ The saw_prize_id that user won, details of the prize can be found in the mini-game definition
26
+
27
+ ___
28
+
29
+ ### prize\_amount
30
+
31
+ • **prize\_amount**: `number`
32
+
33
+ Amount of prizes in stock
34
+
35
+ ___
36
+
37
+ ### client\_request\_id
38
+
39
+ • **client\_request\_id**: `string`
40
+
41
+ Request ID that client is sending to show history
42
+
43
+ ___
44
+
45
+ ### is\_claimed
46
+
47
+ • **is\_claimed**: `boolean`
48
+
49
+ Flag indicating to show whether prize in the mini-game claimed or not
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.175",
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
@@ -1,5 +1,6 @@
1
1
  enum JackpotType {
2
2
  Main = 1,
3
+ Personal = 2,
3
4
  }
4
5
 
5
6
  export { JackpotType };
@@ -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';
@@ -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');
@@ -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 {
@@ -92,6 +93,7 @@ export class WSAPI {
92
93
  on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
93
94
  on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
94
95
  on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache());
96
+ on(ClassId.JP_OPTIN_RESPONSE, (data: JackpotsOptinResponse) => this.jackpotClearCache());
95
97
  on(ClassId.CLAIM_BONUS_RESPONSE, () => this.updateBonuses());
96
98
  on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => this.updateOnAddSpin());
97
99
  }
@@ -455,6 +457,42 @@ export class WSAPI {
455
457
  return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
456
458
  }
457
459
 
460
+ /**
461
+ * Returns the list of mini-games based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
462
+ * The maximum number of items per request is limited to 20.
463
+ * You can leave this params empty and by default it will return list of mini-games ranging from 0 to 20.
464
+ * 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.
465
+ * Updated templates will be passed to onUpdate callback.
466
+ *
467
+ * **Example**:
468
+ * ```
469
+ * _smartico.api.getMiniGamesHistory().then((result) => {
470
+ * console.log(result);
471
+ * });
472
+ * ```
473
+ *
474
+ * **Visitor mode: not supported**
475
+ */
476
+
477
+ public async getMiniGamesHistory({
478
+ limit,
479
+ offset,
480
+ saw_template_id,
481
+ onUpdate
482
+ } : { limit?: number, offset?: number, saw_template_id?: number, onUpdate?: (data: TMiniGameTemplate[]) => void }): Promise<TSawHistory[]> {
483
+
484
+ if (onUpdate) {
485
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
486
+ }
487
+
488
+ return OCache.use(
489
+ onUpdateContextKey.Saw,
490
+ ECacheContext.WSAPI,
491
+ () => this.api.getSawWinningHistoryT(null, limit, offset, saw_template_id),
492
+ CACHE_DATA_SEC,
493
+ );
494
+ }
495
+
458
496
  /**
459
497
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
460
498
  * 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.
@@ -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
+ }