@smartico/public-api 0.0.79 → 0.0.80

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.
@@ -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,