@smartico/public-api 0.0.72 → 0.0.74
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/SmarticoAPI.d.ts +2 -1
- package/dist/WSAPI/WSAPI.d.ts +15 -2
- package/dist/WSAPI/WSAPITypes.d.ts +9 -0
- package/dist/index.js +119 -71
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +32 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +29 -20
- package/docs/interfaces/TMissionOptInResult.md +19 -0
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +11 -1
- package/src/WSAPI/WSAPI.ts +32 -4
- package/src/WSAPI/WSAPITypes.ts +10 -0
package/dist/index.modern.mjs
CHANGED
|
@@ -797,6 +797,7 @@ class WSAPI {
|
|
|
797
797
|
this.api = api;
|
|
798
798
|
const on = this.api.tracker.on;
|
|
799
799
|
on(ClassId.SAW_SPINS_COUNT_PUSH, data => this.updateOnSpin(data));
|
|
800
|
+
on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
|
|
800
801
|
on(ClassId.SAW_DO_SPIN_RESPONSE, data => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
|
|
801
802
|
on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
|
|
802
803
|
on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration());
|
|
@@ -818,6 +819,9 @@ class WSAPI {
|
|
|
818
819
|
/** Returns all the missions available the current user.
|
|
819
820
|
* The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
820
821
|
* The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
|
|
822
|
+
/**
|
|
823
|
+
* @param params
|
|
824
|
+
*/
|
|
821
825
|
async getMissions({
|
|
822
826
|
onUpdate
|
|
823
827
|
} = {}) {
|
|
@@ -840,7 +844,11 @@ class WSAPI {
|
|
|
840
844
|
}
|
|
841
845
|
/** Returns the list of mini-games available for user
|
|
842
846
|
* 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 getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
843
|
-
* The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one. Updated templates will be passed to onUpdate callback. */
|
|
847
|
+
* The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback. */
|
|
848
|
+
/**
|
|
849
|
+
/**
|
|
850
|
+
* @param params
|
|
851
|
+
*/
|
|
844
852
|
async getMiniGames({
|
|
845
853
|
onUpdate
|
|
846
854
|
} = {}) {
|
|
@@ -860,9 +868,21 @@ class WSAPI {
|
|
|
860
868
|
};
|
|
861
869
|
return o;
|
|
862
870
|
}
|
|
871
|
+
/** Requests an opt-in for the specified mission_id. Returns the err_code. */
|
|
872
|
+
async requestMissionOptIn(mission_id) {
|
|
873
|
+
const r = await this.api.missionOptIn(null, mission_id);
|
|
874
|
+
const o = {
|
|
875
|
+
err_code: r.errCode,
|
|
876
|
+
err_message: r.errMsg
|
|
877
|
+
};
|
|
878
|
+
return o;
|
|
879
|
+
}
|
|
863
880
|
/** Returns all the active instances of tournaments
|
|
864
881
|
* The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
865
882
|
* The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
|
|
883
|
+
/**
|
|
884
|
+
* @param params
|
|
885
|
+
*/
|
|
866
886
|
async getTournamentsList({
|
|
867
887
|
onUpdate
|
|
868
888
|
} = {}) {
|
|
@@ -881,6 +901,10 @@ class WSAPI {
|
|
|
881
901
|
templates[index].spin_count = data.spin_count;
|
|
882
902
|
this.updateEntity(onUpdateContextKey.Saw, templates);
|
|
883
903
|
}
|
|
904
|
+
async updateOnAddSpin() {
|
|
905
|
+
const payload = await this.api.sawGetTemplatesT(null);
|
|
906
|
+
this.updateEntity(onUpdateContextKey.Saw, payload);
|
|
907
|
+
}
|
|
884
908
|
async updateOnPrizeWin(data) {
|
|
885
909
|
if (data.errCode === SAWSpinErrorCode.SAW_OK) {
|
|
886
910
|
var _template$prizes$find;
|
|
@@ -1158,6 +1182,13 @@ class SmarticoAPI {
|
|
|
1158
1182
|
request_id
|
|
1159
1183
|
});
|
|
1160
1184
|
}
|
|
1185
|
+
async missionOptIn(user_ext_id, mission_id) {
|
|
1186
|
+
const message = this.buildMessage(user_ext_id, ClassId.MISSION_OPTIN_REQUEST, {
|
|
1187
|
+
achievementId: mission_id
|
|
1188
|
+
});
|
|
1189
|
+
const res = await this.send(message, ClassId.MISSION_OPTIN_RESPONSE);
|
|
1190
|
+
return res;
|
|
1191
|
+
}
|
|
1161
1192
|
async inboxGetMessages(user_ext_id, limit = 10, offset = 0) {
|
|
1162
1193
|
const message = this.buildMessage(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
|
1163
1194
|
limit,
|