@smartico/public-api 0.0.172 → 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,11 +415,49 @@ _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
- ▸ **playMiniGame**(`template_id`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
456
+ ▸ **playMiniGame**(`template_id`, `«destructured»?`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
421
457
 
422
458
  Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
459
+ * 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.
460
+ 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, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
423
461
 
424
462
  **Example**:
425
463
  ```
@@ -435,6 +473,8 @@ _smartico.api.playMiniGame(55).then((result) => {
435
473
  | Name | Type |
436
474
  | :------ | :------ |
437
475
  | `template_id` | `number` |
476
+ | `«destructured»` | `Object` |
477
+ | › `onUpdate?` | (`data`: [`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]) => `void` |
438
478
 
439
479
  #### Returns
440
480
 
@@ -444,9 +484,11 @@ ___
444
484
 
445
485
  ### playMiniGameBatch
446
486
 
447
- ▸ **playMiniGameBatch**(`template_id`, `spin_count`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
487
+ ▸ **playMiniGameBatch**(`template_id`, `spin_count`, `«destructured»?`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
448
488
 
449
489
  Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
490
+ After playMiniGameBatch 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 playMiniGameBatch with a new onUpdate callback, the old one will be overwritten by the new one.
491
+ 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, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
450
492
 
451
493
  **Example**:
452
494
  ```
@@ -462,6 +504,8 @@ _smartico.api.playMiniGameBatch(55, 10).then((result) => {
462
504
  | :------ | :------ |
463
505
  | `template_id` | `number` |
464
506
  | `spin_count` | `number` |
507
+ | `«destructured»` | `Object` |
508
+ | › `onUpdate?` | (`data`: [`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]) => `void` |
465
509
 
466
510
  #### Returns
467
511
 
@@ -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.172",
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 {
@@ -93,6 +94,7 @@ export class WSAPI {
93
94
  on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
94
95
  on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache());
95
96
  on(ClassId.CLAIM_BONUS_RESPONSE, () => this.updateBonuses());
97
+ on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => this.updateOnAddSpin());
96
98
  }
97
99
  }
98
100
 
@@ -454,9 +456,47 @@ export class WSAPI {
454
456
  return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
455
457
  }
456
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
+
457
495
  /**
458
496
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
459
- *
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.
498
+ * 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, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
499
+ *
460
500
  * **Example**:
461
501
  * ```
462
502
  * _smartico.api.playMiniGame(55).then((result) => {
@@ -466,7 +506,12 @@ export class WSAPI {
466
506
  *
467
507
  * **Visitor mode: not supported**
468
508
  */
469
- public async playMiniGame(template_id: number): Promise<TMiniGamePlayResult> {
509
+ public async playMiniGame(template_id: number, { onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMiniGamePlayResult> {
510
+
511
+ if (onUpdate) {
512
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
513
+ }
514
+
470
515
  const r = await this.api.sawSpinRequest(null, template_id);
471
516
  this.api.doAcknowledgeRequest(null, r.request_id);
472
517
 
@@ -481,7 +526,9 @@ export class WSAPI {
481
526
 
482
527
  /**
483
528
  * Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
484
- *
529
+ * After playMiniGameBatch 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 playMiniGameBatch with a new onUpdate callback, the old one will be overwritten by the new one.
530
+ * 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, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
531
+ *
485
532
  * **Example**:
486
533
  * ```
487
534
  * _smartico.api.playMiniGameBatch(55, 10).then((result) => {
@@ -490,7 +537,12 @@ export class WSAPI {
490
537
  * ```
491
538
  * **Visitor mode: not supported**
492
539
  */
493
- public async playMiniGameBatch(template_id: number, spin_count: number): Promise<TMiniGamePlayBatchResult[]> {
540
+ public async playMiniGameBatch(template_id: number, spin_count: number, { onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMiniGamePlayBatchResult[]> {
541
+
542
+ if (onUpdate) {
543
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
544
+ }
545
+
494
546
  const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
495
547
 
496
548
  const request_ids = response.results.map((result) => result.request_id);
@@ -949,9 +1001,9 @@ export class WSAPI {
949
1001
  * });
950
1002
  * ```
951
1003
  */
952
- public async getRelatedItemsForGame(related_game_id: string): Promise<GetAchievementMapResponse> {
1004
+ public async getRelatedItemsForGame(related_game_id: string, force_language?: string): Promise<GetAchievementMapResponse> {
953
1005
 
954
- const result = await this.api.getRelatedItemsForGame(null, related_game_id);
1006
+ const result = await this.api.getRelatedItemsForGame(null, related_game_id, force_language);
955
1007
  return result;
956
1008
 
957
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
+ }