@smartico/public-api 0.0.79 → 0.0.82
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 +4 -2
- package/dist/Tournaments/TournamentPublicMeta.d.ts +1 -0
- package/dist/WSAPI/WSAPI.d.ts +5 -1
- package/dist/WSAPI/WSAPITypes.d.ts +14 -1
- package/dist/index.js +139 -83
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +39 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +4 -0
- package/docs/classes/WSAPI.md +36 -0
- package/docs/enums/BuyStoreItemErrorCode.md +49 -0
- package/docs/enums/TournamentRegistrationError.md +55 -0
- package/docs/interfaces/TBuyStoreItemResult.md +17 -0
- package/docs/interfaces/TTournamentRegistrationResult.md +17 -0
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +29 -3
- package/src/Tournaments/TournamentPublicMeta.ts +2 -0
- package/src/WSAPI/WSAPI.ts +25 -1
- package/src/WSAPI/WSAPITypes.ts +17 -2
- package/tsconfig.json +2 -0
package/dist/index.modern.mjs
CHANGED
|
@@ -864,6 +864,15 @@ class WSAPI {
|
|
|
864
864
|
async getStoreItems() {
|
|
865
865
|
return this.api.storeGetItemsT(null);
|
|
866
866
|
}
|
|
867
|
+
/** Buy the specific shop item by item_id. Returns the err_code.*/
|
|
868
|
+
async buyStoreItem(item_id) {
|
|
869
|
+
const r = await this.api.buyStoreItem(null, item_id);
|
|
870
|
+
const o = {
|
|
871
|
+
err_code: r.errCode,
|
|
872
|
+
err_message: r.errMsg
|
|
873
|
+
};
|
|
874
|
+
return o;
|
|
875
|
+
}
|
|
867
876
|
/** Returns store categories */
|
|
868
877
|
async getStoreCategories() {
|
|
869
878
|
return this.api.storeGetItemsT(null);
|
|
@@ -921,6 +930,15 @@ class WSAPI {
|
|
|
921
930
|
async getTournamentInstanceInfo(tournamentInstanceId) {
|
|
922
931
|
return this.api.tournamentsGetInfoT(null, tournamentInstanceId);
|
|
923
932
|
}
|
|
933
|
+
/** Requests registration for the specified tournament instance. Returns the err_code. */
|
|
934
|
+
async registerInTournament(tournamentInstanceId) {
|
|
935
|
+
const r = await this.api.registerInTournament(null, tournamentInstanceId);
|
|
936
|
+
const o = {
|
|
937
|
+
err_code: r.errCode,
|
|
938
|
+
err_message: r.errMsg
|
|
939
|
+
};
|
|
940
|
+
return o;
|
|
941
|
+
}
|
|
924
942
|
async updateOnSpin(data) {
|
|
925
943
|
const templates = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
|
|
926
944
|
const index = templates.findIndex(t => t.id === data.saw_template_id);
|
|
@@ -1147,7 +1165,7 @@ class SmarticoAPI {
|
|
|
1147
1165
|
const message = this.buildMessage(user_ext_id, ClassId.CLIENT_SET_CUSTOM_USERNAME_REQUEST, {
|
|
1148
1166
|
public_username_custom
|
|
1149
1167
|
});
|
|
1150
|
-
return this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
|
|
1168
|
+
return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
|
|
1151
1169
|
}
|
|
1152
1170
|
async sawGetTemplates(user_ext_id, lang, is_visitor_mode = false) {
|
|
1153
1171
|
const message = this.buildMessage(user_ext_id, ClassId.SAW_GET_SPINS_REQUEST, lang ? {
|
|
@@ -1221,6 +1239,26 @@ class SmarticoAPI {
|
|
|
1221
1239
|
const res = await this.send(message, ClassId.MISSION_OPTIN_RESPONSE);
|
|
1222
1240
|
return res;
|
|
1223
1241
|
}
|
|
1242
|
+
async registerInTournament(user_ext_id, tournamentInstanceId) {
|
|
1243
|
+
if (!tournamentInstanceId) {
|
|
1244
|
+
throw new Error('Missing tournament instance id');
|
|
1245
|
+
}
|
|
1246
|
+
const message = this.buildMessage(user_ext_id, ClassId.TOURNAMENT_REGISTER_REQUEST, {
|
|
1247
|
+
tournamentInstanceId
|
|
1248
|
+
});
|
|
1249
|
+
const res = await this.send(message, ClassId.TOURNAMENT_REGISTER_RESPONSE);
|
|
1250
|
+
return res;
|
|
1251
|
+
}
|
|
1252
|
+
async buyStoreItem(user_ext_id, itemId) {
|
|
1253
|
+
if (!itemId) {
|
|
1254
|
+
throw new Error('Missing store item id');
|
|
1255
|
+
}
|
|
1256
|
+
const message = this.buildMessage(user_ext_id, ClassId.BUY_SHOP_ITEM_REQUEST, {
|
|
1257
|
+
itemId
|
|
1258
|
+
});
|
|
1259
|
+
const res = await this.send(message, ClassId.BUY_SHOP_ITEM_RESPONSE);
|
|
1260
|
+
return res;
|
|
1261
|
+
}
|
|
1224
1262
|
async inboxGetMessages(user_ext_id, limit = 10, offset = 0) {
|
|
1225
1263
|
const message = this.buildMessage(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
|
1226
1264
|
limit,
|