@smartico/public-api 0.0.74 → 0.0.76
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/Core/ActivityTypeLimited.d.ts +12 -1
- package/dist/MiniGames/SAWTemplateUI.d.ts +1 -0
- package/dist/WSAPI/WSAPITypes.d.ts +15 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +35 -0
- package/dist/index.modern.mjs.map +1 -1
- package/docs/interfaces/TTournamentDetailed.md +6 -0
- package/package.json +1 -1
- package/src/Core/ActivityTypeLimited.ts +12 -1
- package/src/MiniGames/SAWTemplateUI.ts +1 -0
- package/src/SmarticoAPI.ts +10 -0
- package/src/Tournaments/GetTournamentInfoResponse.ts +15 -0
- package/src/WSAPI/WSAPITypes.ts +16 -0
|
@@ -373,3 +373,9 @@ The information about current user in the tournament if he is registered in the
|
|
|
373
373
|
| `avatar_url` | `string` | The URL to the avatar of the current user |
|
|
374
374
|
| `position` | `number` | The position of the current user in the tournament |
|
|
375
375
|
| `scores` | `number` | The scores of the current user in the tournament |
|
|
376
|
+
|
|
377
|
+
___
|
|
378
|
+
|
|
379
|
+
### prizes
|
|
380
|
+
|
|
381
|
+
• `Optional` **prizes**: { `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
|
package/package.json
CHANGED
|
@@ -2,7 +2,18 @@ export enum ActivityTypeLimited {
|
|
|
2
2
|
|
|
3
3
|
DoNothing = 8,
|
|
4
4
|
Points = 12,
|
|
5
|
+
GiveMission = 14,
|
|
6
|
+
StartAnotherCampaign = 15,
|
|
7
|
+
MiniGameAttempt = 16,
|
|
8
|
+
DeductPoints = 21,
|
|
9
|
+
ResetPoints = 22,
|
|
5
10
|
Popup = 30,
|
|
6
11
|
Inbox = 31,
|
|
12
|
+
Slack = 70,
|
|
13
|
+
Email_To_Customer_Support = 80,
|
|
14
|
+
Email_To_Risk_Operator = 90,
|
|
7
15
|
Bonus = 100,
|
|
8
|
-
|
|
16
|
+
WebHook = 200,
|
|
17
|
+
TagCustomer = 504,
|
|
18
|
+
UnTagCustomer = 505,
|
|
19
|
+
}
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -305,6 +305,10 @@ class SmarticoAPI {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
public async sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse> {
|
|
308
|
+
if (!saw_template_id) {
|
|
309
|
+
throw new Error('Missing template id');
|
|
310
|
+
}
|
|
311
|
+
|
|
308
312
|
const request_id = IntUtils.uuid();
|
|
309
313
|
|
|
310
314
|
const message = this.buildMessage<SAWDoSpinRequest, SAWDoSpinResponse>(user_ext_id, ClassId.SAW_DO_SPIN_REQUEST, {
|
|
@@ -335,6 +339,9 @@ class SmarticoAPI {
|
|
|
335
339
|
}
|
|
336
340
|
|
|
337
341
|
public async missionOptIn(user_ext_id: string, mission_id: number) {
|
|
342
|
+
if (!mission_id) {
|
|
343
|
+
throw new Error('Missing mission id');
|
|
344
|
+
}
|
|
338
345
|
const message = this.buildMessage<AchievementOptinRequest, AchievementOptinResponse>(user_ext_id, ClassId.MISSION_OPTIN_REQUEST, {
|
|
339
346
|
achievementId: mission_id
|
|
340
347
|
});
|
|
@@ -439,6 +446,9 @@ class SmarticoAPI {
|
|
|
439
446
|
}
|
|
440
447
|
|
|
441
448
|
public async tournamentsGetInfoT(user_ext_id: string, tournamentInstanceId: number): Promise<TTournamentDetailed> {
|
|
449
|
+
if (!tournamentInstanceId) {
|
|
450
|
+
throw new Error('Missing tournament instance id');
|
|
451
|
+
}
|
|
442
452
|
return tournamentInfoItemTransform((await this.tournamentsGetInfo(user_ext_id, tournamentInstanceId)));
|
|
443
453
|
}
|
|
444
454
|
|
|
@@ -3,6 +3,7 @@ import {TournamentPlayer} from "./TournamentPlayer";
|
|
|
3
3
|
import { ProtocolResponse } from "../Base/ProtocolResponse";
|
|
4
4
|
import { TournamentPrize } from "./TournamentPrize";
|
|
5
5
|
import { TTournamentDetailed } from "../WSAPI/WSAPITypes";
|
|
6
|
+
import { ActivityTypeLimited } from "src/Core";
|
|
6
7
|
|
|
7
8
|
export interface GetTournamentInfoResponse extends ProtocolResponse {
|
|
8
9
|
|
|
@@ -22,6 +23,16 @@ export interface GetTournamentInfoResponse extends ProtocolResponse {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
const tournamentPrizeTypeToPrizeName = (type: ActivityTypeLimited) => {
|
|
27
|
+
return {
|
|
28
|
+
[ActivityTypeLimited.DoNothing]: 'TANGIBLE',
|
|
29
|
+
[ActivityTypeLimited.Points]: 'POINTS_ADD',
|
|
30
|
+
[ActivityTypeLimited.DeductPoints]: 'POINTS_DEDUCT',
|
|
31
|
+
[ActivityTypeLimited.ResetPoints]: 'POINTS_RESET',
|
|
32
|
+
[ActivityTypeLimited.MiniGameAttempt]: "MINI_GAME_ATTEMPT",
|
|
33
|
+
[ActivityTypeLimited.Bonus]: 'BONUS',
|
|
34
|
+
}[type]
|
|
35
|
+
}
|
|
25
36
|
|
|
26
37
|
export const tournamentInfoItemTransform = (t: GetTournamentInfoResponse): TTournamentDetailed => {
|
|
27
38
|
const response: TTournamentDetailed = {
|
|
@@ -35,6 +46,10 @@ export const tournamentInfoItemTransform = (t: GetTournamentInfoResponse): TTour
|
|
|
35
46
|
})),
|
|
36
47
|
};
|
|
37
48
|
|
|
49
|
+
if (t.prizeStructure) {
|
|
50
|
+
response.prizes = t.prizeStructure.prizes.map(p => ({...p, type: tournamentPrizeTypeToPrizeName(p.type)}))
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
if (t.userPosition) {
|
|
39
54
|
response.me = {
|
|
40
55
|
public_username: t.userPosition.userAltName,
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -257,6 +257,22 @@ export interface TTournamentDetailed extends TTournament {
|
|
|
257
257
|
scores: number;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
prizes?: {
|
|
261
|
+
/** The name of the prize */
|
|
262
|
+
name: string;
|
|
263
|
+
/** The description of the prize */
|
|
264
|
+
description: string;
|
|
265
|
+
/** The image of the prize */
|
|
266
|
+
image_url: string;
|
|
267
|
+
/** from-to range of the places to which this prize */
|
|
268
|
+
place_from: number;
|
|
269
|
+
place_to: number;
|
|
270
|
+
/** type of the prize: TANGIBLE, POINTS_ADD, POINTS_DEDUCT, POINTS_RESET, MINI_GAME_ATTEMPT, BONUS */
|
|
271
|
+
type: string;
|
|
272
|
+
/** if the prize is points related, indicates amount of points */
|
|
273
|
+
points?: number;
|
|
274
|
+
}[]
|
|
275
|
+
|
|
260
276
|
};
|
|
261
277
|
|
|
262
278
|
/**
|