@smartico/public-api 0.0.432 → 0.0.433
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/Jackpots/GetJackpotWinnersResponse.d.ts +28 -0
- package/dist/SmarticoAPI.d.ts +2 -1
- package/dist/WSAPI/WSAPIJackpots.d.ts +76 -0
- package/dist/index.js +389 -278
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +93 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/README.md +3 -0
- package/docs/api/classes/WSAPIJackpots.md +100 -0
- package/docs/api/interfaces/GetJackpotWinnersResponse.md +8 -0
- package/docs/api/interfaces/JackpotWin.md +25 -0
- package/docs/api/interfaces/JackpotWinStats.md +25 -0
- package/docs/api/interfaces/TGetJackpotWinStatsResponse.md +17 -0
- package/docs/capabilities/getJackpotWinStats.md +111 -0
- package/package.json +1 -1
- package/src/Jackpots/GetJackpotWinnersResponse.ts +41 -0
- package/src/SmarticoAPI.ts +11 -1
- package/src/WSAPI/WSAPIJackpots.ts +89 -0
package/docs/api/README.md
CHANGED
|
@@ -123,6 +123,9 @@
|
|
|
123
123
|
- [GetJackpotWinnersRequest](interfaces/GetJackpotWinnersRequest.md)
|
|
124
124
|
- [GetJackpotWinnersResponse](interfaces/GetJackpotWinnersResponse.md)
|
|
125
125
|
- [JackpotWinnerHistory](interfaces/JackpotWinnerHistory.md)
|
|
126
|
+
- [JackpotWinStats](interfaces/JackpotWinStats.md)
|
|
127
|
+
- [JackpotWin](interfaces/JackpotWin.md)
|
|
128
|
+
- [TGetJackpotWinStatsResponse](interfaces/TGetJackpotWinStatsResponse.md)
|
|
126
129
|
- [GetJackpotsPotsRequest](interfaces/GetJackpotsPotsRequest.md)
|
|
127
130
|
- [GetJackpotsPotsResponse](interfaces/GetJackpotsPotsResponse.md)
|
|
128
131
|
- [GetJackpotsRequest](interfaces/GetJackpotsRequest.md)
|
|
@@ -364,6 +364,106 @@ console.log('[smartico] render', winners.length, 'recent winner rows (amounts in
|
|
|
364
364
|
|
|
365
365
|
***
|
|
366
366
|
|
|
367
|
+
### getJackpotWinStats()
|
|
368
|
+
|
|
369
|
+
> **getJackpotWinStats**(`__namedParameters`): `Promise`\<[`TGetJackpotWinStatsResponse`](../interfaces/TGetJackpotWinStatsResponse.md)\>
|
|
370
|
+
|
|
371
|
+
Returns past winners of a specific jackpot template, paginated, together
|
|
372
|
+
with the win statistics of that template: total number of wins, the
|
|
373
|
+
biggest win and the most recent win. Use it for a jackpot info modal /
|
|
374
|
+
tooltip that shows "Total wins", "Highest win" and "Latest win" next to
|
|
375
|
+
the winners list.
|
|
376
|
+
|
|
377
|
+
#### Parameters
|
|
378
|
+
|
|
379
|
+
##### \_\_namedParameters
|
|
380
|
+
|
|
381
|
+
###### limit?
|
|
382
|
+
|
|
383
|
+
`number`
|
|
384
|
+
|
|
385
|
+
Page size of the winners list (default 20).
|
|
386
|
+
|
|
387
|
+
###### offset?
|
|
388
|
+
|
|
389
|
+
`number`
|
|
390
|
+
|
|
391
|
+
Pagination offset of the winners list (default 0).
|
|
392
|
+
|
|
393
|
+
###### jp_template_id?
|
|
394
|
+
|
|
395
|
+
`number`
|
|
396
|
+
|
|
397
|
+
Jackpot template ID (required).
|
|
398
|
+
|
|
399
|
+
#### Returns
|
|
400
|
+
|
|
401
|
+
`Promise`\<[`TGetJackpotWinStatsResponse`](../interfaces/TGetJackpotWinStatsResponse.md)\>
|
|
402
|
+
|
|
403
|
+
[TGetJackpotWinStatsResponse](../interfaces/TGetJackpotWinStatsResponse.md) —
|
|
404
|
+
`{ winners: JackpotWinnerHistory[], win_stats: JackpotWinStats }`.
|
|
405
|
+
|
|
406
|
+
#### Remarks
|
|
407
|
+
|
|
408
|
+
**Preconditions**
|
|
409
|
+
- User must be authenticated. Visitor mode not supported.
|
|
410
|
+
- `jp_template_id` is mandatory.
|
|
411
|
+
- The consumer SHOULD check
|
|
412
|
+
`JackpotDetails.expose_winners_over_api` before calling, since
|
|
413
|
+
the server does not enforce it.
|
|
414
|
+
|
|
415
|
+
**Statistics**
|
|
416
|
+
- `win_stats` describes the whole jackpot template and does not depend
|
|
417
|
+
on `limit` / `offset`. Pass `limit: 1` when only the statistics are needed.
|
|
418
|
+
- Only issued wins are counted — a pot that exploded but still waits for
|
|
419
|
+
manual approval is not included.
|
|
420
|
+
- `highest_win` / `last_win` are `null` while the jackpot has no wins,
|
|
421
|
+
`total_wins` is `0` in that case.
|
|
422
|
+
- `public_username` of `highest_win` / `last_win` is masked by the same
|
|
423
|
+
label setting as the winners list, and is `null` when the template
|
|
424
|
+
doesn't expose winners over API.
|
|
425
|
+
- The server refreshes the statistics once per minute.
|
|
426
|
+
|
|
427
|
+
**Currency caveat**
|
|
428
|
+
All amounts (`win_stats.*.winning_amount`,
|
|
429
|
+
`winners[].winner.winning_amount_jp_currency`) are in the jackpot's
|
|
430
|
+
NATIVE currency, NOT the user's wallet currency.
|
|
431
|
+
|
|
432
|
+
**Refresh**
|
|
433
|
+
- The SDK caches each page separately (per `jp_template_id` +
|
|
434
|
+
`limit` + `offset`) for 30 seconds.
|
|
435
|
+
- Caches clear on jackpot-win push events and on opt-in / opt-out.
|
|
436
|
+
|
|
437
|
+
**Error handling**
|
|
438
|
+
Non-zero `errCode` on control-group users or generic server errors. The
|
|
439
|
+
SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
|
|
440
|
+
surface `errMsg` on failure.
|
|
441
|
+
|
|
442
|
+
**Visitor mode**: not supported.
|
|
443
|
+
|
|
444
|
+
#### Example
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
|
|
448
|
+
|
|
449
|
+
if (!jp || !jp.expose_winners_over_api) {
|
|
450
|
+
console.log('[smartico] winners hidden by operator config — hide the stats');
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const { winners, win_stats } = await window._smartico.api.getJackpotWinStats({
|
|
455
|
+
jp_template_id: 42,
|
|
456
|
+
limit: 10,
|
|
457
|
+
offset: 0,
|
|
458
|
+
});
|
|
459
|
+
console.log('[smartico] total wins', win_stats.total_wins);
|
|
460
|
+
console.log('[smartico] highest win', win_stats.highest_win?.winning_amount, jp.jp_currency);
|
|
461
|
+
console.log('[smartico] latest win', win_stats.last_win?.public_username, win_stats.last_win?.win_date_ts);
|
|
462
|
+
console.log('[smartico] render', winners.length, 'recent winner rows');
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
***
|
|
466
|
+
|
|
367
467
|
### getJackpotEligibleGames()
|
|
368
468
|
|
|
369
469
|
> **getJackpotEligibleGames**(`__namedParameters`): `Promise`\<[`TGetJackpotEligibleGamesResponse`](../interfaces/TGetJackpotEligibleGamesResponse.md)\>
|
|
@@ -69,3 +69,11 @@ The list of jackpot winners
|
|
|
69
69
|
> **has\_more**: `boolean`
|
|
70
70
|
|
|
71
71
|
Whether there are more winners to fetch
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### win\_stats?
|
|
76
|
+
|
|
77
|
+
> `optional` **win\_stats?**: [`JackpotWinStats`](JackpotWinStats.md)
|
|
78
|
+
|
|
79
|
+
Win statistics of the jackpot template
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Interface: JackpotWin
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### winning\_amount
|
|
6
|
+
|
|
7
|
+
> **winning\_amount**: `number`
|
|
8
|
+
|
|
9
|
+
Won amount in the Jackpot currency
|
|
10
|
+
|
|
11
|
+
***
|
|
12
|
+
|
|
13
|
+
### win\_date\_ts
|
|
14
|
+
|
|
15
|
+
> **win\_date\_ts**: `number`
|
|
16
|
+
|
|
17
|
+
Date of winning in milliseconds
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### public\_username
|
|
22
|
+
|
|
23
|
+
> **public\_username**: `string`
|
|
24
|
+
|
|
25
|
+
Name of the winner, masked by default. `null` when the jackpot template doesn't expose winners over API
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Interface: JackpotWinStats
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### total\_wins
|
|
6
|
+
|
|
7
|
+
> **total\_wins**: `number`
|
|
8
|
+
|
|
9
|
+
Total number of issued wins of the jackpot template. Wins waiting for manual approval are not counted
|
|
10
|
+
|
|
11
|
+
***
|
|
12
|
+
|
|
13
|
+
### highest\_win
|
|
14
|
+
|
|
15
|
+
> **highest\_win**: [`JackpotWin`](JackpotWin.md)
|
|
16
|
+
|
|
17
|
+
The biggest win of the jackpot template, `null` when there are no wins yet
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### last\_win
|
|
22
|
+
|
|
23
|
+
> **last\_win**: [`JackpotWin`](JackpotWin.md)
|
|
24
|
+
|
|
25
|
+
The most recent win of the jackpot template, `null` when there are no wins yet
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: TGetJackpotWinStatsResponse
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### winners
|
|
6
|
+
|
|
7
|
+
> **winners**: [`JackpotWinnerHistory`](JackpotWinnerHistory.md)[]
|
|
8
|
+
|
|
9
|
+
The list of jackpot winners
|
|
10
|
+
|
|
11
|
+
***
|
|
12
|
+
|
|
13
|
+
### win\_stats
|
|
14
|
+
|
|
15
|
+
> **win\_stats**: [`JackpotWinStats`](JackpotWinStats.md)
|
|
16
|
+
|
|
17
|
+
Win statistics of the jackpot template
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# getJackpotWinStats — API (TGetJackpotWinStatsResponse)
|
|
2
|
+
|
|
3
|
+
> Returns past winners of a specific jackpot template, paginated, together with the win statistics of that template: total number of wins, the biggest win and the most recent win.
|
|
4
|
+
> Import: `import { TGetJackpotWinStatsResponse } from '@smartico/public-api'`
|
|
5
|
+
> Search terms: getJackpotWinStats, jackpots, TGetJackpotWinStatsResponse, JackpotWinnerHistory, JackPotWinner, JackpotWinStats, JackpotWin
|
|
6
|
+
|
|
7
|
+
## Signature
|
|
8
|
+
```ts
|
|
9
|
+
_smartico.api.getJackpotWinStats({
|
|
10
|
+
limit,
|
|
11
|
+
offset,
|
|
12
|
+
jp_template_id,
|
|
13
|
+
}: {
|
|
14
|
+
/** Page size of the winners list (default 20). */
|
|
15
|
+
limit?: number;
|
|
16
|
+
/** Pagination offset of the winners list (default 0). */
|
|
17
|
+
offset?: number;
|
|
18
|
+
/** Jackpot template ID (required). */
|
|
19
|
+
jp_template_id?: number;
|
|
20
|
+
}): Promise<TGetJackpotWinStatsResponse>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Parameters
|
|
24
|
+
_None._
|
|
25
|
+
|
|
26
|
+
## Returns — `Promise<TGetJackpotWinStatsResponse>`
|
|
27
|
+
`TGetJackpotWinStatsResponse`:
|
|
28
|
+
- `winners` (JackpotWinnerHistory[]) — The list of jackpot winners
|
|
29
|
+
- `jp_pot_id` (number) — Id of the jackpot pot
|
|
30
|
+
- `win_date_ts` (number) — Date of winning in milliseconds
|
|
31
|
+
- `winner` (JackPotWinner) — Info about jackpot winner
|
|
32
|
+
- `is_me` (boolean) — Flag indicating that this winner is the currently logged in user
|
|
33
|
+
- `public_username` (string) — Name of the winner, note that for all users except is_me, the name is masked by default, but masking can be disabled by request to Smartico AM team
|
|
34
|
+
- `winning_amount_jp_currency` (number) — Won amount in the Jackpot currency
|
|
35
|
+
- `winning_amount_wallet_currency` (number) — Won amount in the user Wallet currency
|
|
36
|
+
- `winning_position` (number) — Position of the winner. Relevant for jackpots where there could be multiple winners
|
|
37
|
+
- `avatar_id` (string) — Avatar image URL of the winner
|
|
38
|
+
- `avatar_real_id` (number | null) — Numeric ID of the winner's avatar; `null` when the winner has not picked one
|
|
39
|
+
- `win_stats` (JackpotWinStats) — Win statistics of the jackpot template
|
|
40
|
+
- `total_wins` (number) — Total number of issued wins of the jackpot template. Wins waiting for manual approval are not counted
|
|
41
|
+
- `highest_win` (JackpotWin | null) — The biggest win of the jackpot template, `null` when there are no wins yet
|
|
42
|
+
- `winning_amount` (number) — Won amount in the Jackpot currency
|
|
43
|
+
- `win_date_ts` (number) — Date of winning in milliseconds
|
|
44
|
+
- `public_username` (string | null) — Name of the winner, masked by default. `null` when the jackpot template doesn't expose winners over API
|
|
45
|
+
- `last_win` (JackpotWin | null) — The most recent win of the jackpot template, `null` when there are no wins yet
|
|
46
|
+
- `winning_amount` (number) — Won amount in the Jackpot currency
|
|
47
|
+
- `win_date_ts` (number) — Date of winning in milliseconds
|
|
48
|
+
- `public_username` (string | null) — Name of the winner, masked by default. `null` when the jackpot template doesn't expose winners over API
|
|
49
|
+
|
|
50
|
+
## Behavioral contract
|
|
51
|
+
**Preconditions**
|
|
52
|
+
- User must be authenticated. Visitor mode not supported.
|
|
53
|
+
- `jp_template_id` is mandatory.
|
|
54
|
+
- The consumer SHOULD check
|
|
55
|
+
`JackpotDetails.expose_winners_over_api` before calling, since
|
|
56
|
+
the server does not enforce it.
|
|
57
|
+
|
|
58
|
+
**Statistics**
|
|
59
|
+
- `win_stats` describes the whole jackpot template and does not depend
|
|
60
|
+
on `limit` / `offset`. Pass `limit: 1` when only the statistics are needed.
|
|
61
|
+
- Only issued wins are counted — a pot that exploded but still waits for
|
|
62
|
+
manual approval is not included.
|
|
63
|
+
- `highest_win` / `last_win` are `null` while the jackpot has no wins,
|
|
64
|
+
`total_wins` is `0` in that case.
|
|
65
|
+
- `public_username` of `highest_win` / `last_win` is masked by the same
|
|
66
|
+
label setting as the winners list, and is `null` when the template
|
|
67
|
+
doesn't expose winners over API.
|
|
68
|
+
- The server refreshes the statistics once per minute.
|
|
69
|
+
|
|
70
|
+
**Currency caveat**
|
|
71
|
+
All amounts (`win_stats.*.winning_amount`,
|
|
72
|
+
`winners[].winner.winning_amount_jp_currency`) are in the jackpot's
|
|
73
|
+
NATIVE currency, NOT the user's wallet currency.
|
|
74
|
+
|
|
75
|
+
**Refresh**
|
|
76
|
+
- The SDK caches each page separately (per `jp_template_id` +
|
|
77
|
+
`limit` + `offset`) for 30 seconds.
|
|
78
|
+
- Caches clear on jackpot-win push events and on opt-in / opt-out.
|
|
79
|
+
|
|
80
|
+
**Error handling**
|
|
81
|
+
Non-zero `errCode` on control-group users or generic server errors. The
|
|
82
|
+
SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
|
|
83
|
+
surface `errMsg` on failure.
|
|
84
|
+
|
|
85
|
+
**Visitor mode**: not supported.
|
|
86
|
+
|
|
87
|
+
## Example
|
|
88
|
+
```ts
|
|
89
|
+
const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
|
|
90
|
+
|
|
91
|
+
if (!jp || !jp.expose_winners_over_api) {
|
|
92
|
+
console.log('[smartico] winners hidden by operator config — hide the stats');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const { winners, win_stats } = await window._smartico.api.getJackpotWinStats({
|
|
97
|
+
jp_template_id: 42,
|
|
98
|
+
limit: 10,
|
|
99
|
+
offset: 0,
|
|
100
|
+
});
|
|
101
|
+
console.log('[smartico] total wins', win_stats.total_wins);
|
|
102
|
+
console.log('[smartico] highest win', win_stats.highest_win?.winning_amount, jp.jp_currency);
|
|
103
|
+
console.log('[smartico] latest win', win_stats.last_win?.public_username, win_stats.last_win?.win_date_ts);
|
|
104
|
+
console.log('[smartico] render', winners.length, 'recent winner rows');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Errors
|
|
108
|
+
See this method's TSDoc / the mutation pages for `err_code` handling.
|
|
109
|
+
|
|
110
|
+
## Related
|
|
111
|
+
- `TGetJackpotWinStatsResponse`
|
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@ export interface GetJackpotWinnersResponse extends ProtocolResponse {
|
|
|
6
6
|
winners: JackpotWinnerHistory[];
|
|
7
7
|
/** Whether there are more winners to fetch */
|
|
8
8
|
has_more: boolean;
|
|
9
|
+
/** Win statistics of the jackpot template */
|
|
10
|
+
win_stats?: JackpotWinStats;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export interface JackpotWinnerHistory {
|
|
@@ -17,6 +19,31 @@ export interface JackpotWinnerHistory {
|
|
|
17
19
|
winner: JackPotWinner;
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
export interface JackpotWinStats {
|
|
23
|
+
/** Total number of issued wins of the jackpot template. Wins waiting for manual approval are not counted */
|
|
24
|
+
total_wins: number;
|
|
25
|
+
/** The biggest win of the jackpot template, `null` when there are no wins yet */
|
|
26
|
+
highest_win: JackpotWin | null;
|
|
27
|
+
/** The most recent win of the jackpot template, `null` when there are no wins yet */
|
|
28
|
+
last_win: JackpotWin | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface JackpotWin {
|
|
32
|
+
/** Won amount in the Jackpot currency */
|
|
33
|
+
winning_amount: number;
|
|
34
|
+
/** Date of winning in milliseconds */
|
|
35
|
+
win_date_ts: number;
|
|
36
|
+
/** Name of the winner, masked by default. `null` when the jackpot template doesn't expose winners over API */
|
|
37
|
+
public_username: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface TGetJackpotWinStatsResponse {
|
|
41
|
+
/** The list of jackpot winners */
|
|
42
|
+
winners: JackpotWinnerHistory[];
|
|
43
|
+
/** Win statistics of the jackpot template */
|
|
44
|
+
win_stats: JackpotWinStats;
|
|
45
|
+
}
|
|
46
|
+
|
|
20
47
|
/**
|
|
21
48
|
* @ignore
|
|
22
49
|
*/
|
|
@@ -31,3 +58,17 @@ export const GetJackpotWinnersResponseTransform = (items: JackpotWinnerHistory[]
|
|
|
31
58
|
return winnerInfo;
|
|
32
59
|
});
|
|
33
60
|
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
export const GetJackpotWinStatsResponseTransform = (response: GetJackpotWinnersResponse): TGetJackpotWinStatsResponse => {
|
|
66
|
+
return {
|
|
67
|
+
winners: GetJackpotWinnersResponseTransform(response.winners ?? []),
|
|
68
|
+
win_stats: {
|
|
69
|
+
total_wins: response.win_stats?.total_wins ?? 0,
|
|
70
|
+
highest_win: response.win_stats?.highest_win ?? null,
|
|
71
|
+
last_win: response.win_stats?.last_win ?? null,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
};
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -146,7 +146,13 @@ import { GetAvatarsCustomizedResponse, avatarCustomizedTransform } from './Avata
|
|
|
146
146
|
import { GetAvatarPromptsResponse, avatarPromptTransform } from './Avatars/GetAvatarPromptsResponse';
|
|
147
147
|
import { SetAvatarRequest, SetAvatarResponse } from './Avatars';
|
|
148
148
|
import { AvatarCustomizeResponse } from './Avatars/AvatarCustomizeResponse';
|
|
149
|
-
import {
|
|
149
|
+
import {
|
|
150
|
+
GetJackpotWinnersResponse,
|
|
151
|
+
GetJackpotWinnersResponseTransform,
|
|
152
|
+
GetJackpotWinStatsResponseTransform,
|
|
153
|
+
JackpotWinnerHistory,
|
|
154
|
+
TGetJackpotWinStatsResponse,
|
|
155
|
+
} from './Jackpots/GetJackpotWinnersResponse';
|
|
150
156
|
import { GetJackpotWinnersRequest } from './Jackpots/GetJackpotWinnersRequest';
|
|
151
157
|
import { GetJackpotEligibleGamesRequest } from './Jackpots/GetJackpotEligibleGamesRequest';
|
|
152
158
|
import { GetJackpotEligibleGamesResponse, GetJackpotEligibleGamesResponseTransform, JackpotEligibleGame, TGetJackpotEligibleGamesResponse } from './Jackpots/GetJackpotEligibleGamesResponse';
|
|
@@ -611,6 +617,10 @@ class SmarticoAPI {
|
|
|
611
617
|
return GetJackpotWinnersResponseTransform((await this.getJackpotWinners(user_ext_id, limit, offset, jp_template_id)).winners);
|
|
612
618
|
}
|
|
613
619
|
|
|
620
|
+
public async getJackpotWinStatsT(user_ext_id: string, limit: number = 20, offset: number = 0, jp_template_id: number): Promise<TGetJackpotWinStatsResponse> {
|
|
621
|
+
return GetJackpotWinStatsResponseTransform(await this.getJackpotWinners(user_ext_id, limit, offset, jp_template_id));
|
|
622
|
+
}
|
|
623
|
+
|
|
614
624
|
public async getJackpotEligibleGames(user_ext_id: string, { jp_template_id }: { jp_template_id: number }): Promise<GetJackpotEligibleGamesResponse> {
|
|
615
625
|
const message = this.buildMessage<GetJackpotEligibleGamesRequest, GetJackpotEligibleGamesResponse>(
|
|
616
626
|
user_ext_id,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '../Jackpots';
|
|
9
9
|
import { IntUtils } from '../IntUtils';
|
|
10
10
|
import { TGetJackpotEligibleGamesResponse } from '../Jackpots/GetJackpotEligibleGamesResponse';
|
|
11
|
+
import { TGetJackpotWinStatsResponse } from '../Jackpots/GetJackpotWinnersResponse';
|
|
11
12
|
import {
|
|
12
13
|
JACKPOT_TEMPLATE_CACHE_SEC,
|
|
13
14
|
JACKPOT_POT_CACHE_SEC,
|
|
@@ -390,6 +391,94 @@ export class WSAPIJackpots extends WSAPIClans {
|
|
|
390
391
|
);
|
|
391
392
|
}
|
|
392
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Returns past winners of a specific jackpot template, paginated, together
|
|
396
|
+
* with the win statistics of that template: total number of wins, the
|
|
397
|
+
* biggest win and the most recent win. Use it for a jackpot info modal /
|
|
398
|
+
* tooltip that shows "Total wins", "Highest win" and "Latest win" next to
|
|
399
|
+
* the winners list.
|
|
400
|
+
*
|
|
401
|
+
* @remarks
|
|
402
|
+
* **Preconditions**
|
|
403
|
+
* - User must be authenticated. Visitor mode not supported.
|
|
404
|
+
* - `jp_template_id` is mandatory.
|
|
405
|
+
* - The consumer SHOULD check
|
|
406
|
+
* `JackpotDetails.expose_winners_over_api` before calling, since
|
|
407
|
+
* the server does not enforce it.
|
|
408
|
+
*
|
|
409
|
+
* **Statistics**
|
|
410
|
+
* - `win_stats` describes the whole jackpot template and does not depend
|
|
411
|
+
* on `limit` / `offset`. Pass `limit: 1` when only the statistics are needed.
|
|
412
|
+
* - Only issued wins are counted — a pot that exploded but still waits for
|
|
413
|
+
* manual approval is not included.
|
|
414
|
+
* - `highest_win` / `last_win` are `null` while the jackpot has no wins,
|
|
415
|
+
* `total_wins` is `0` in that case.
|
|
416
|
+
* - `public_username` of `highest_win` / `last_win` is masked by the same
|
|
417
|
+
* label setting as the winners list, and is `null` when the template
|
|
418
|
+
* doesn't expose winners over API.
|
|
419
|
+
* - The server refreshes the statistics once per minute.
|
|
420
|
+
*
|
|
421
|
+
* **Currency caveat**
|
|
422
|
+
* All amounts (`win_stats.*.winning_amount`,
|
|
423
|
+
* `winners[].winner.winning_amount_jp_currency`) are in the jackpot's
|
|
424
|
+
* NATIVE currency, NOT the user's wallet currency.
|
|
425
|
+
*
|
|
426
|
+
* **Refresh**
|
|
427
|
+
* - The SDK caches each page separately (per `jp_template_id` +
|
|
428
|
+
* `limit` + `offset`) for 30 seconds.
|
|
429
|
+
* - Caches clear on jackpot-win push events and on opt-in / opt-out.
|
|
430
|
+
*
|
|
431
|
+
* **Error handling**
|
|
432
|
+
* Non-zero `errCode` on control-group users or generic server errors. The
|
|
433
|
+
* SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
|
|
434
|
+
* surface `errMsg` on failure.
|
|
435
|
+
*
|
|
436
|
+
* **Visitor mode**: not supported.
|
|
437
|
+
*
|
|
438
|
+
* @returns {@link TGetJackpotWinStatsResponse} —
|
|
439
|
+
* `{ winners: JackpotWinnerHistory[], win_stats: JackpotWinStats }`.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
|
|
444
|
+
*
|
|
445
|
+
* if (!jp || !jp.expose_winners_over_api) {
|
|
446
|
+
* console.log('[smartico] winners hidden by operator config — hide the stats');
|
|
447
|
+
* return;
|
|
448
|
+
* }
|
|
449
|
+
*
|
|
450
|
+
* const { winners, win_stats } = await window._smartico.api.getJackpotWinStats({
|
|
451
|
+
* jp_template_id: 42,
|
|
452
|
+
* limit: 10,
|
|
453
|
+
* offset: 0,
|
|
454
|
+
* });
|
|
455
|
+
* console.log('[smartico] total wins', win_stats.total_wins);
|
|
456
|
+
* console.log('[smartico] highest win', win_stats.highest_win?.winning_amount, jp.jp_currency);
|
|
457
|
+
* console.log('[smartico] latest win', win_stats.last_win?.public_username, win_stats.last_win?.win_date_ts);
|
|
458
|
+
* console.log('[smartico] render', winners.length, 'recent winner rows');
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
public async getJackpotWinStats({
|
|
462
|
+
limit,
|
|
463
|
+
offset,
|
|
464
|
+
jp_template_id,
|
|
465
|
+
}: {
|
|
466
|
+
/** Page size of the winners list (default 20). */
|
|
467
|
+
limit?: number;
|
|
468
|
+
/** Pagination offset of the winners list (default 0). */
|
|
469
|
+
offset?: number;
|
|
470
|
+
/** Jackpot template ID (required). */
|
|
471
|
+
jp_template_id?: number;
|
|
472
|
+
}): Promise<TGetJackpotWinStatsResponse> {
|
|
473
|
+
const cacheKey = `${onUpdateContextKey.JackpotWinners}stats:${jp_template_id}:${limit}:${offset}`;
|
|
474
|
+
return OCache.use(
|
|
475
|
+
cacheKey,
|
|
476
|
+
ECacheContext.WSAPI,
|
|
477
|
+
() => this.api.getJackpotWinStatsT(this.userExtId, limit, offset, jp_template_id),
|
|
478
|
+
JACKPOT_WINNERS_CACHE_SEC,
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
|
|
393
482
|
/**
|
|
394
483
|
* Returns the casino games eligible to contribute to a specific jackpot —
|
|
395
484
|
* the catalog the user must play to grow the pot. Use to power an
|