@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/dist/Base/ClassId.d.ts +2 -0
- package/dist/Jackpots/JackpotType.d.ts +2 -1
- package/dist/MiniGames/SAWPrize.d.ts +3 -0
- package/dist/MiniGames/SAWWinningHistoryRequest.d.ts +7 -0
- package/dist/MiniGames/SAWWinningHistoryResponse.d.ts +15 -0
- package/dist/MiniGames/index.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +3 -1
- package/dist/WSAPI/WSAPI.d.ts +23 -1
- package/dist/WSAPI/WSAPITypes.d.ts +18 -1
- package/dist/index.js +301 -214
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +61 -2
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +35 -0
- package/docs/enums/JackpotType.md +6 -0
- package/docs/interfaces/JackpotDetails.md +1 -1
- package/docs/interfaces/TMiniGamePrize.md +18 -0
- package/docs/interfaces/TSawHistory.md +49 -0
- package/package.json +1 -1
- package/src/Base/ClassId.ts +3 -0
- package/src/Jackpots/JackpotType.ts +1 -0
- package/src/MiniGames/SAWGetTemplatesResponse.ts +3 -0
- package/src/MiniGames/SAWPrize.ts +3 -0
- package/src/MiniGames/SAWWinningHistoryRequest.ts +8 -0
- package/src/MiniGames/SAWWinningHistoryResponse.ts +31 -0
- package/src/MiniGames/index.ts +2 -0
- package/src/SmarticoAPI.ts +18 -0
- package/src/WSAPI/WSAPI.ts +40 -2
- package/src/WSAPI/WSAPITypes.ts +22 -1
package/docs/README.md
CHANGED
package/docs/classes/WSAPI.md
CHANGED
|
@@ -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)\>
|
|
@@ -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
package/src/Base/ClassId.ts
CHANGED
|
@@ -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
|
}),
|
|
@@ -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
|
+
|
package/src/MiniGames/index.ts
CHANGED
|
@@ -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';
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -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');
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -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.
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -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
|
+
}
|