@smartico/public-api 0.0.167 → 0.0.168
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 +4 -0
- package/dist/MiniGames/SAWDoAcknowledgeBatchRequest.d.ts +4 -0
- package/dist/MiniGames/SAWDoAcknowledgeBatchResponse.d.ts +8 -0
- package/dist/MiniGames/SAWDoSpinBatchRequest.d.ts +7 -0
- package/dist/MiniGames/SAWDoSpinBatchResponse.d.ts +7 -0
- package/dist/Quiz/MarketsPerSport.d.ts +1 -1
- package/dist/SmarticoAPI.d.ts +4 -0
- package/dist/WSAPI/WSAPI.d.ts +7 -1
- package/dist/WSAPI/WSAPITypes.d.ts +15 -0
- package/dist/index.js +273 -194
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +54 -0
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +21 -0
- package/docs/interfaces/TMiniGamePlayBatchResult.md +43 -0
- package/package.json +1 -1
- package/src/Base/ClassId.ts +4 -0
- package/src/MiniGames/SAWDoAcknowledgeBatchRequest.ts +5 -0
- package/src/MiniGames/SAWDoAcknowledgeBatchResponse.ts +5 -0
- package/src/MiniGames/SAWDoSpinBatchRequest.ts +5 -0
- package/src/MiniGames/SAWDoSpinBatchResponse.ts +8 -0
- package/src/SmarticoAPI.ts +45 -0
- package/src/WSAPI/WSAPI.ts +24 -1
- package/src/WSAPI/WSAPITypes.ts +16 -0
package/docs/README.md
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
- [JackpotsOptoutResponse](interfaces/JackpotsOptoutResponse.md)
|
|
33
33
|
- [TMiniGamePrize](interfaces/TMiniGamePrize.md)
|
|
34
34
|
- [TMiniGamePlayResult](interfaces/TMiniGamePlayResult.md)
|
|
35
|
+
- [TMiniGamePlayBatchResult](interfaces/TMiniGamePlayBatchResult.md)
|
|
35
36
|
- [TMiniGameTemplate](interfaces/TMiniGameTemplate.md)
|
|
36
37
|
- [TUserProfile](interfaces/TUserProfile.md)
|
|
37
38
|
- [TLevel](interfaces/TLevel.md)
|
package/docs/classes/WSAPI.md
CHANGED
|
@@ -435,6 +435,27 @@ Plays the specified by template_id mini-game on behalf of user and returns prize
|
|
|
435
435
|
|
|
436
436
|
___
|
|
437
437
|
|
|
438
|
+
### playMiniGameBatch
|
|
439
|
+
|
|
440
|
+
▸ **playMiniGameBatch**(`template_id`, `spin_count`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
|
|
441
|
+
|
|
442
|
+
Plays the specified by template_id mini-game on behalf of user {count} times and returns prizes or err_code
|
|
443
|
+
|
|
444
|
+
**Visitor mode: not supported**
|
|
445
|
+
|
|
446
|
+
#### Parameters
|
|
447
|
+
|
|
448
|
+
| Name | Type |
|
|
449
|
+
| :------ | :------ |
|
|
450
|
+
| `template_id` | `number` |
|
|
451
|
+
| `spin_count` | `number` |
|
|
452
|
+
|
|
453
|
+
#### Returns
|
|
454
|
+
|
|
455
|
+
`Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
|
|
456
|
+
|
|
457
|
+
___
|
|
458
|
+
|
|
438
459
|
### requestMissionOptIn
|
|
439
460
|
|
|
440
461
|
▸ **requestMissionOptIn**(`mission_id`): `Promise`\<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Interface: TMiniGamePlayBatchResult
|
|
2
|
+
|
|
3
|
+
TMiniGamePlayBatchResult describes the response of call to _smartico.api.playMiniGameBatch(template_id, spin_count) method
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### saw\_prize\_id
|
|
8
|
+
|
|
9
|
+
• **saw\_prize\_id**: `number`
|
|
10
|
+
|
|
11
|
+
The saw_prize_id that user won, details of the prize can be found in the mini-game definition
|
|
12
|
+
|
|
13
|
+
___
|
|
14
|
+
|
|
15
|
+
### errCode
|
|
16
|
+
|
|
17
|
+
• **errCode**: [`SAWSpinErrorCode`](../enums/SAWSpinErrorCode.md)
|
|
18
|
+
|
|
19
|
+
Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0
|
|
20
|
+
|
|
21
|
+
___
|
|
22
|
+
|
|
23
|
+
### errMessage
|
|
24
|
+
|
|
25
|
+
• `Optional` **errMessage**: `string`
|
|
26
|
+
|
|
27
|
+
Optional error message
|
|
28
|
+
|
|
29
|
+
___
|
|
30
|
+
|
|
31
|
+
### jackpot\_amount
|
|
32
|
+
|
|
33
|
+
• `Optional` **jackpot\_amount**: `number`
|
|
34
|
+
|
|
35
|
+
Jackpot amount what user won
|
|
36
|
+
|
|
37
|
+
___
|
|
38
|
+
|
|
39
|
+
### first\_spin\_in\_period
|
|
40
|
+
|
|
41
|
+
• `Optional` **first\_spin\_in\_period**: `number`
|
|
42
|
+
|
|
43
|
+
Period in miliseconds from last spin
|
package/package.json
CHANGED
package/src/Base/ClassId.ts
CHANGED
|
@@ -121,6 +121,10 @@ export enum ClassId {
|
|
|
121
121
|
SAW_PRIZE_DROP_WIN_AKNOWLEDGE_REQUEST = 709,
|
|
122
122
|
SAW_PRIZE_DROP_WIN_AKNOWLEDGE_RESPONSE = 710,
|
|
123
123
|
SAW_AKNOWLEDGE_SPIN_PUSH = 711,
|
|
124
|
+
SAW_DO_SPIN_BATCH_REQUEST = 712,
|
|
125
|
+
SAW_DO_SPIN_BATCH_RESPONSE = 713,
|
|
126
|
+
SAW_AKNOWLEDGE_BATCH_REQUEST = 714,
|
|
127
|
+
SAW_AKNOWLEDGE_BATCH_RESPONSE = 715,
|
|
124
128
|
|
|
125
129
|
/*
|
|
126
130
|
!Important, if adding new messages that are 'acting' on behalf of the client,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProtocolResponse } from '../Base/ProtocolResponse';
|
|
2
|
+
import { SAWDoSpinResponse } from './SAWDoSpinResponse';
|
|
3
|
+
import { SAWSpinErrorCode } from './SAWSpinErrorCode';
|
|
4
|
+
|
|
5
|
+
export interface SAWDoSpinBatchResponse extends ProtocolResponse {
|
|
6
|
+
results: SAWDoSpinResponse[];
|
|
7
|
+
errCode: SAWSpinErrorCode,
|
|
8
|
+
}
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -109,6 +109,10 @@ import {
|
|
|
109
109
|
import { GetCustomSectionsRequest, GetCustomSectionsResponse, UICustomSectionTransform } from './CustomSections';
|
|
110
110
|
import { BonusItemsTransform, ClaimBonusRequest, ClaimBonusResponse, GetBonusesResponse } from './Bonuses';
|
|
111
111
|
import { GetBonusesRequest } from './Bonuses/GetBonusesRequest';
|
|
112
|
+
import { SAWDoSpinBatchResponse } from './MiniGames/SAWDoSpinBatchResponse';
|
|
113
|
+
import { SAWDoSpinBatchRequest } from './MiniGames/SAWDoSpinBatchRequest';
|
|
114
|
+
import { SAWDoAcknowledgeBatchRequest } from './MiniGames/SAWDoAcknowledgeBatchRequest';
|
|
115
|
+
import { SAWDoAcknowledgeBatchResponse } from './MiniGames/SAWDoAcknowledgeBatchResponse';
|
|
112
116
|
import { GetRelatedAchTourRequest } from './Missions/GetRelatedAchTourRequest';
|
|
113
117
|
import { GetRelatedAchTourResponse } from './Missions/GetRelatedAchTourResponse';
|
|
114
118
|
|
|
@@ -539,6 +543,47 @@ class SmarticoAPI {
|
|
|
539
543
|
return { ...spinAttemptResponse, request_id };
|
|
540
544
|
}
|
|
541
545
|
|
|
546
|
+
|
|
547
|
+
public async doAcknowledgeBatchRequest(user_ext_id: string, request_ids: string[]): Promise<SAWDoAcknowledgeBatchResponse> {
|
|
548
|
+
const message = this.buildMessage<SAWDoAcknowledgeBatchRequest, SAWDoAcknowledgeBatchResponse>(
|
|
549
|
+
user_ext_id,
|
|
550
|
+
ClassId.SAW_AKNOWLEDGE_REQUEST,
|
|
551
|
+
{
|
|
552
|
+
request_ids,
|
|
553
|
+
},
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
return await this.send<SAWDoAcknowledgeBatchResponse>(message, ClassId.SAW_AKNOWLEDGE_BATCH_RESPONSE);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
public async sawSpinBatchRequest(user_ext_id: string, saw_template_id: number, spins_count: number): Promise<SAWDoSpinBatchResponse> {
|
|
560
|
+
|
|
561
|
+
const spins = [];
|
|
562
|
+
for (let i = 0; i < spins_count; i++) {
|
|
563
|
+
const request_id = IntUtils.uuid();
|
|
564
|
+
spins.push({ request_id, saw_template_id })
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const message = this.buildMessage<SAWDoSpinBatchRequest, SAWDoSpinBatchResponse>(user_ext_id, ClassId.SAW_DO_SPIN_BATCH_REQUEST, { spins });
|
|
568
|
+
const spinAttemptResponse = await this.send<SAWDoSpinBatchResponse>(message, ClassId.SAW_DO_SPIN_BATCH_RESPONSE);
|
|
569
|
+
|
|
570
|
+
// If one response is 'OK' we consider that whole result is 'OK'
|
|
571
|
+
const result = spinAttemptResponse.results.find((res) => res.errCode === 0);
|
|
572
|
+
|
|
573
|
+
let status = 'OK';
|
|
574
|
+
if (!result) {
|
|
575
|
+
status = 'BATCH FAIL';
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
await this.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
579
|
+
saw_template_id,
|
|
580
|
+
status,
|
|
581
|
+
spins_count,
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
return { ...spinAttemptResponse };
|
|
585
|
+
}
|
|
586
|
+
|
|
542
587
|
public async missionOptIn(user_ext_id: string, mission_id: number) {
|
|
543
588
|
if (!mission_id) {
|
|
544
589
|
throw new Error('Missing mission id');
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -26,7 +26,8 @@ import {
|
|
|
26
26
|
TUICustomSection,
|
|
27
27
|
TUserProfile,
|
|
28
28
|
UserLevelExtraCountersT,TBonus,
|
|
29
|
-
TClaimBonusResult
|
|
29
|
+
TClaimBonusResult,
|
|
30
|
+
TMiniGamePlayBatchResult
|
|
30
31
|
} from './WSAPITypes';
|
|
31
32
|
import { LeaderBoardPeriodType } from '../Leaderboard';
|
|
32
33
|
import {
|
|
@@ -471,6 +472,28 @@ export class WSAPI {
|
|
|
471
472
|
return o;
|
|
472
473
|
}
|
|
473
474
|
|
|
475
|
+
/**
|
|
476
|
+
* Plays the specified by template_id mini-game on behalf of user {count} times and returns prizes or err_code
|
|
477
|
+
*
|
|
478
|
+
* **Visitor mode: not supported**
|
|
479
|
+
*/
|
|
480
|
+
public async playMiniGameBatch(template_id: number, spin_count: number): Promise<TMiniGamePlayBatchResult[]> {
|
|
481
|
+
const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
|
|
482
|
+
|
|
483
|
+
const request_ids = response.results.map((result) => result.request_id);
|
|
484
|
+
this.api.doAcknowledgeBatchRequest(null, request_ids);
|
|
485
|
+
|
|
486
|
+
const o: TMiniGamePlayBatchResult[] = response.results.map((result) => ({
|
|
487
|
+
errCode: result.errCode,
|
|
488
|
+
errMessage: result.errMsg,
|
|
489
|
+
saw_prize_id: result.saw_prize_id,
|
|
490
|
+
jackpot_amount: result.jackpot_amount,
|
|
491
|
+
first_spin_in_period: result.first_spin_in_period,
|
|
492
|
+
}));
|
|
493
|
+
|
|
494
|
+
return o;
|
|
495
|
+
}
|
|
496
|
+
|
|
474
497
|
/**
|
|
475
498
|
* Requests an opt-in for the specified mission_id. Returns the err_code.
|
|
476
499
|
*
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -55,6 +55,22 @@ export interface TMiniGamePlayResult {
|
|
|
55
55
|
prize_id: number;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* TMiniGamePlayBatchResult describes the response of call to _smartico.api.playMiniGameBatch(template_id, spin_count) method
|
|
60
|
+
*/
|
|
61
|
+
export interface TMiniGamePlayBatchResult {
|
|
62
|
+
/** The saw_prize_id that user won, details of the prize can be found in the mini-game definition */
|
|
63
|
+
saw_prize_id: number;
|
|
64
|
+
/** Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0 */
|
|
65
|
+
errCode: SAWSpinErrorCode;
|
|
66
|
+
/** Optional error message */
|
|
67
|
+
errMessage?: string;
|
|
68
|
+
/** Jackpot amount what user won */
|
|
69
|
+
jackpot_amount?: number;
|
|
70
|
+
/** Period in miliseconds from last spin */
|
|
71
|
+
first_spin_in_period?: number,
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
/**
|
|
59
75
|
* TMiniGameTemplate describes the information of mini-games available for the user
|
|
60
76
|
*/
|