@smartico/public-api 0.0.166 → 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/Missions/GetRelatedAchTourResponse.d.ts +1 -1
- package/dist/Quiz/MarketsPerSport.d.ts +1 -1
- package/dist/SmarticoAPI.d.ts +6 -0
- package/dist/WSAPI/WSAPI.d.ts +30 -1
- package/dist/WSAPI/WSAPITypes.d.ts +15 -0
- package/dist/index.js +309 -189
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +85 -0
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +64 -3
- 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/Missions/GetRelatedAchTourResponse.ts +1 -1
- package/src/SmarticoAPI.ts +60 -0
- package/src/WSAPI/WSAPI.ts +54 -2
- package/src/WSAPI/WSAPITypes.ts +16 -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
|
|
@@ -1296,6 +1300,9 @@ class WSAPI {
|
|
|
1296
1300
|
}
|
|
1297
1301
|
/**
|
|
1298
1302
|
* Returns all the bonuses for the current user
|
|
1303
|
+
* The returned bonuss are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
|
|
1304
|
+
* Note that each time you call getBonuses with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
1305
|
+
* The onUpdate callback will be called on bonus claimed and the updated bonuses will be passed to it.
|
|
1299
1306
|
*
|
|
1300
1307
|
* **Visitor mode: not supported**
|
|
1301
1308
|
*/
|
|
@@ -1510,6 +1517,24 @@ class WSAPI {
|
|
|
1510
1517
|
};
|
|
1511
1518
|
return o;
|
|
1512
1519
|
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Plays the specified by template_id mini-game on behalf of user {count} times and returns prizes or err_code
|
|
1522
|
+
*
|
|
1523
|
+
* **Visitor mode: not supported**
|
|
1524
|
+
*/
|
|
1525
|
+
async playMiniGameBatch(template_id, spin_count) {
|
|
1526
|
+
const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
|
|
1527
|
+
const request_ids = response.results.map(result => result.request_id);
|
|
1528
|
+
this.api.doAcknowledgeBatchRequest(null, request_ids);
|
|
1529
|
+
const o = response.results.map(result => ({
|
|
1530
|
+
errCode: result.errCode,
|
|
1531
|
+
errMessage: result.errMsg,
|
|
1532
|
+
saw_prize_id: result.saw_prize_id,
|
|
1533
|
+
jackpot_amount: result.jackpot_amount,
|
|
1534
|
+
first_spin_in_period: result.first_spin_in_period
|
|
1535
|
+
}));
|
|
1536
|
+
return o;
|
|
1537
|
+
}
|
|
1513
1538
|
/**
|
|
1514
1539
|
* Requests an opt-in for the specified mission_id. Returns the err_code.
|
|
1515
1540
|
*
|
|
@@ -1858,6 +1883,28 @@ class WSAPI {
|
|
|
1858
1883
|
const result = await this.api.jackpotOptOut(null, filter);
|
|
1859
1884
|
return result;
|
|
1860
1885
|
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Returns all the related tournaments and missions for the provided game id for the current user
|
|
1888
|
+
* The provided Game ID should correspond to the ID from the Games Catalog - https://help.smartico.ai/welcome/technical-guides/games-catalog-api
|
|
1889
|
+
*
|
|
1890
|
+
* **Example**:
|
|
1891
|
+
* ```
|
|
1892
|
+
* _smartico.api.getRelatedItemsForGame('gold-slot2').then((result) => {
|
|
1893
|
+
* console.log(result);
|
|
1894
|
+
* });
|
|
1895
|
+
* ```
|
|
1896
|
+
*
|
|
1897
|
+
* **Example in the Visitor mode**:
|
|
1898
|
+
* ```
|
|
1899
|
+
* _smartico.vapi('EN').getRelatedItemsForGame('gold-slot2').then((result) => {
|
|
1900
|
+
* console.log(result);
|
|
1901
|
+
* });
|
|
1902
|
+
* ```
|
|
1903
|
+
*/
|
|
1904
|
+
async getRelatedItemsForGame(related_game_id) {
|
|
1905
|
+
const result = await this.api.getRelatedItemsForGame(null, related_game_id);
|
|
1906
|
+
return result;
|
|
1907
|
+
}
|
|
1861
1908
|
}
|
|
1862
1909
|
|
|
1863
1910
|
const pointsRewardTransform = reward_points => {
|
|
@@ -2254,6 +2301,38 @@ class SmarticoAPI {
|
|
|
2254
2301
|
request_id
|
|
2255
2302
|
});
|
|
2256
2303
|
}
|
|
2304
|
+
async doAcknowledgeBatchRequest(user_ext_id, request_ids) {
|
|
2305
|
+
const message = this.buildMessage(user_ext_id, ClassId.SAW_AKNOWLEDGE_REQUEST, {
|
|
2306
|
+
request_ids
|
|
2307
|
+
});
|
|
2308
|
+
return await this.send(message, ClassId.SAW_AKNOWLEDGE_BATCH_RESPONSE);
|
|
2309
|
+
}
|
|
2310
|
+
async sawSpinBatchRequest(user_ext_id, saw_template_id, spins_count) {
|
|
2311
|
+
const spins = [];
|
|
2312
|
+
for (let i = 0; i < spins_count; i++) {
|
|
2313
|
+
const request_id = IntUtils.uuid();
|
|
2314
|
+
spins.push({
|
|
2315
|
+
request_id,
|
|
2316
|
+
saw_template_id
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
const message = this.buildMessage(user_ext_id, ClassId.SAW_DO_SPIN_BATCH_REQUEST, {
|
|
2320
|
+
spins
|
|
2321
|
+
});
|
|
2322
|
+
const spinAttemptResponse = await this.send(message, ClassId.SAW_DO_SPIN_BATCH_RESPONSE);
|
|
2323
|
+
// If one response is 'OK' we consider that whole result is 'OK'
|
|
2324
|
+
const result = spinAttemptResponse.results.find(res => res.errCode === 0);
|
|
2325
|
+
let status = 'OK';
|
|
2326
|
+
if (!result) {
|
|
2327
|
+
status = 'BATCH FAIL';
|
|
2328
|
+
}
|
|
2329
|
+
await this.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
|
|
2330
|
+
saw_template_id,
|
|
2331
|
+
status,
|
|
2332
|
+
spins_count
|
|
2333
|
+
});
|
|
2334
|
+
return _extends({}, spinAttemptResponse);
|
|
2335
|
+
}
|
|
2257
2336
|
async missionOptIn(user_ext_id, mission_id) {
|
|
2258
2337
|
if (!mission_id) {
|
|
2259
2338
|
throw new Error('Missing mission id');
|
|
@@ -2533,6 +2612,12 @@ class SmarticoAPI {
|
|
|
2533
2612
|
getWSCalls() {
|
|
2534
2613
|
return new WSAPI(this);
|
|
2535
2614
|
}
|
|
2615
|
+
async getRelatedItemsForGame(user_ext_id, related_game_id) {
|
|
2616
|
+
const message = this.buildMessage(user_ext_id, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_REQUEST, {
|
|
2617
|
+
related_game_id: related_game_id
|
|
2618
|
+
});
|
|
2619
|
+
return await this.send(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE);
|
|
2620
|
+
}
|
|
2536
2621
|
}
|
|
2537
2622
|
|
|
2538
2623
|
class CookieStore {
|