@smartico/public-api 0.0.167 → 0.0.169
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/UserProfile/UserProfile.d.ts +3 -0
- package/dist/UserProfile/index.d.ts +1 -0
- package/dist/WSAPI/WSAPI.d.ts +20 -1
- package/dist/WSAPI/WSAPITypes.d.ts +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +286 -194
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +67 -0
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +34 -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/UserProfile/UserProfile.ts +5 -0
- package/src/UserProfile/index.ts +1 -0
- package/src/WSAPI/WSAPI.ts +37 -1
- package/src/WSAPI/WSAPITypes.ts +16 -0
- package/src/index.ts +1 -0
package/dist/index.modern.mjs
CHANGED
|
@@ -104,6 +104,10 @@ var ClassId;
|
|
|
104
104
|
ClassId[ClassId["SAW_PRIZE_DROP_WIN_AKNOWLEDGE_REQUEST"] = 709] = "SAW_PRIZE_DROP_WIN_AKNOWLEDGE_REQUEST";
|
|
105
105
|
ClassId[ClassId["SAW_PRIZE_DROP_WIN_AKNOWLEDGE_RESPONSE"] = 710] = "SAW_PRIZE_DROP_WIN_AKNOWLEDGE_RESPONSE";
|
|
106
106
|
ClassId[ClassId["SAW_AKNOWLEDGE_SPIN_PUSH"] = 711] = "SAW_AKNOWLEDGE_SPIN_PUSH";
|
|
107
|
+
ClassId[ClassId["SAW_DO_SPIN_BATCH_REQUEST"] = 712] = "SAW_DO_SPIN_BATCH_REQUEST";
|
|
108
|
+
ClassId[ClassId["SAW_DO_SPIN_BATCH_RESPONSE"] = 713] = "SAW_DO_SPIN_BATCH_RESPONSE";
|
|
109
|
+
ClassId[ClassId["SAW_AKNOWLEDGE_BATCH_REQUEST"] = 714] = "SAW_AKNOWLEDGE_BATCH_REQUEST";
|
|
110
|
+
ClassId[ClassId["SAW_AKNOWLEDGE_BATCH_RESPONSE"] = 715] = "SAW_AKNOWLEDGE_BATCH_RESPONSE";
|
|
107
111
|
/*
|
|
108
112
|
!Important, if adding new messages that are 'acting' on behalf of the client,
|
|
109
113
|
you need to include them in the CLASS_ID_IGNORE_FOR_SIMULATION
|
|
@@ -1501,6 +1505,13 @@ class WSAPI {
|
|
|
1501
1505
|
/**
|
|
1502
1506
|
* Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
|
|
1503
1507
|
*
|
|
1508
|
+
* **Example**:
|
|
1509
|
+
* ```
|
|
1510
|
+
* _smartico.api.playMiniGame(55).then((result) => {
|
|
1511
|
+
* console.log(result);
|
|
1512
|
+
* });
|
|
1513
|
+
* ```
|
|
1514
|
+
*
|
|
1504
1515
|
* **Visitor mode: not supported**
|
|
1505
1516
|
*/
|
|
1506
1517
|
async playMiniGame(template_id) {
|
|
@@ -1513,6 +1524,30 @@ class WSAPI {
|
|
|
1513
1524
|
};
|
|
1514
1525
|
return o;
|
|
1515
1526
|
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
|
|
1529
|
+
*
|
|
1530
|
+
* **Example**:
|
|
1531
|
+
* ```
|
|
1532
|
+
* _smartico.api.playMiniGameBatch(55, 10).then((result) => {
|
|
1533
|
+
* console.log(result);
|
|
1534
|
+
* });
|
|
1535
|
+
* ```
|
|
1536
|
+
* **Visitor mode: not supported**
|
|
1537
|
+
*/
|
|
1538
|
+
async playMiniGameBatch(template_id, spin_count) {
|
|
1539
|
+
const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
|
|
1540
|
+
const request_ids = response.results.map(result => result.request_id);
|
|
1541
|
+
this.api.doAcknowledgeBatchRequest(null, request_ids);
|
|
1542
|
+
const o = response.results.map(result => ({
|
|
1543
|
+
errCode: result.errCode,
|
|
1544
|
+
errMessage: result.errMsg,
|
|
1545
|
+
saw_prize_id: result.saw_prize_id,
|
|
1546
|
+
jackpot_amount: result.jackpot_amount,
|
|
1547
|
+
first_spin_in_period: result.first_spin_in_period
|
|
1548
|
+
}));
|
|
1549
|
+
return o;
|
|
1550
|
+
}
|
|
1516
1551
|
/**
|
|
1517
1552
|
* Requests an opt-in for the specified mission_id. Returns the err_code.
|
|
1518
1553
|
*
|
|
@@ -2279,6 +2314,38 @@ class SmarticoAPI {
|
|
|
2279
2314
|
request_id
|
|
2280
2315
|
});
|
|
2281
2316
|
}
|
|
2317
|
+
async doAcknowledgeBatchRequest(user_ext_id, request_ids) {
|
|
2318
|
+
const message = this.buildMessage(user_ext_id, ClassId.SAW_AKNOWLEDGE_REQUEST, {
|
|
2319
|
+
request_ids
|
|
2320
|
+
});
|
|
2321
|
+
return await this.send(message, ClassId.SAW_AKNOWLEDGE_BATCH_RESPONSE);
|
|
2322
|
+
}
|
|
2323
|
+
async sawSpinBatchRequest(user_ext_id, saw_template_id, spins_count) {
|
|
2324
|
+
const spins = [];
|
|
2325
|
+
for (let i = 0; i < spins_count; i++) {
|
|
2326
|
+
const request_id = IntUtils.uuid();
|
|
2327
|
+
spins.push({
|
|
2328
|
+
request_id,
|
|
2329
|
+
saw_template_id
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
const message = this.buildMessage(user_ext_id, ClassId.SAW_DO_SPIN_BATCH_REQUEST, {
|
|
2333
|
+
spins
|
|
2334
|
+
});
|
|
2335
|
+
const spinAttemptResponse = await this.send(message, ClassId.SAW_DO_SPIN_BATCH_RESPONSE);
|
|
2336
|
+
// If one response is 'OK' we consider that whole result is 'OK'
|
|
2337
|
+
const result = spinAttemptResponse.results.find(res => res.errCode === 0);
|
|
2338
|
+
let status = 'OK';
|
|
2339
|
+
if (!result) {
|
|
2340
|
+
status = 'BATCH FAIL';
|
|
2341
|
+
}
|
|
2342
|
+
await this.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
2343
|
+
saw_template_id,
|
|
2344
|
+
status,
|
|
2345
|
+
spins_count
|
|
2346
|
+
});
|
|
2347
|
+
return _extends({}, spinAttemptResponse);
|
|
2348
|
+
}
|
|
2282
2349
|
async missionOptIn(user_ext_id, mission_id) {
|
|
2283
2350
|
if (!mission_id) {
|
|
2284
2351
|
throw new Error('Missing mission id');
|