@smartico/public-api 0.0.350 → 0.0.352
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/GamePick/GPTypes.d.ts +265 -0
- package/dist/GamePick/index.d.ts +1 -0
- package/dist/Raffle/Raffle.d.ts +13 -0
- package/dist/SmarticoAPI.d.ts +15 -0
- package/dist/Tournaments/Tournament.d.ts +2 -0
- package/dist/WSAPI/WSAPI.d.ts +211 -0
- package/dist/WSAPI/WSAPITypes.d.ts +10 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +713 -96
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +470 -4
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/enums/RaffleTicketCapVisualization.md +21 -0
- package/docs/api/interfaces/RafflePublicMeta.md +8 -0
- package/docs/api/interfaces/TTournament.md +8 -0
- package/docs/api/interfaces/TTournamentDetailed.md +12 -0
- package/docs/api/interfaces/Tournament.md +8 -0
- package/package.json +1 -1
- package/src/ActivityLog/GetActivityLogResponse.ts +2 -0
- package/src/GamePick/GPTypes.ts +273 -0
- package/src/GamePick/index.ts +1 -0
- package/src/Raffle/GetRafflesResponse.ts +1 -0
- package/src/Raffle/Raffle.ts +14 -0
- package/src/SmarticoAPI.ts +110 -1
- package/src/Tournaments/Tournament.ts +5 -2
- package/src/WSAPI/WSAPI.ts +276 -0
- package/src/WSAPI/WSAPITypes.ts +10 -2
- package/src/index.ts +2 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Enumeration: RaffleTicketCapVisualization
|
|
2
|
+
|
|
3
|
+
### Empty
|
|
4
|
+
|
|
5
|
+
• **Empty** = ``0``
|
|
6
|
+
|
|
7
|
+
Don’t show anything
|
|
8
|
+
|
|
9
|
+
### Counter
|
|
10
|
+
|
|
11
|
+
• **Counter** = ``1``
|
|
12
|
+
|
|
13
|
+
Show ticket counter
|
|
14
|
+
|
|
15
|
+
___
|
|
16
|
+
|
|
17
|
+
### Message
|
|
18
|
+
|
|
19
|
+
• **Message** = ``2``
|
|
20
|
+
|
|
21
|
+
Show message when ticket cap is reached
|
|
@@ -57,3 +57,11 @@ ___
|
|
|
57
57
|
Custom data as string or JSON string that can be used in API to build custom UI
|
|
58
58
|
You can request from Smartico to define fields for your specific case that will be managed from Smartico BackOffice
|
|
59
59
|
Read more here - <https://help.smartico.ai/welcome/products/general-concepts/custom-fields-attributes>
|
|
60
|
+
|
|
61
|
+
___
|
|
62
|
+
|
|
63
|
+
### ticket\_cap\_visualization
|
|
64
|
+
|
|
65
|
+
• **ticket\_cap\_visualization**: [`RaffleTicketCapVisualization`](../enums/RaffleTicketCapVisualization.md)
|
|
66
|
+
|
|
67
|
+
Ticket cap visualization
|
|
@@ -316,3 +316,11 @@ ___
|
|
|
316
316
|
• `Optional` **hide\_leaderboard\_min\_scores**: `boolean`
|
|
317
317
|
|
|
318
318
|
When enabled, users who don’t meet the minimum qualifying score will be hidden from the Leaderboard
|
|
319
|
+
|
|
320
|
+
___
|
|
321
|
+
|
|
322
|
+
### total\_scores
|
|
323
|
+
|
|
324
|
+
• `Optional` **total\_scores**: `number`
|
|
325
|
+
|
|
326
|
+
Total scores across all participants in the tournament
|
|
@@ -431,6 +431,18 @@ When enabled, users who don’t meet the minimum qualifying score will be hidden
|
|
|
431
431
|
|
|
432
432
|
___
|
|
433
433
|
|
|
434
|
+
### total\_scores
|
|
435
|
+
|
|
436
|
+
• `Optional` **total\_scores**: `number`
|
|
437
|
+
|
|
438
|
+
Total scores across all participants in the tournament
|
|
439
|
+
|
|
440
|
+
#### Inherited from
|
|
441
|
+
|
|
442
|
+
[TTournament](TTournament.md).[total_scores](TTournament.md#total_scores)
|
|
443
|
+
|
|
444
|
+
___
|
|
445
|
+
|
|
434
446
|
### related\_games
|
|
435
447
|
|
|
436
448
|
• `Optional` **related\_games**: [`AchRelatedGame`](AchRelatedGame-1.md)[]
|
|
@@ -205,3 +205,11 @@ ___
|
|
|
205
205
|
• `Optional` **hideLeaderboardsMinScores**: `boolean`
|
|
206
206
|
|
|
207
207
|
When enabled, users who don't meet the minimum qualifying score will be hidden from the Leaderboard.
|
|
208
|
+
|
|
209
|
+
___
|
|
210
|
+
|
|
211
|
+
### totalScores
|
|
212
|
+
|
|
213
|
+
• `Optional` **totalScores**: `number`
|
|
214
|
+
|
|
215
|
+
Total scores across all participants in the tournament
|
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ export const ActivityLogTransform = (items: ActivityLogEntry[]): TActivityLog[]
|
|
|
20
20
|
source_type_id: item.source_type_id,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
item.type = item.type ?? UserBalanceType.Points;
|
|
24
|
+
|
|
23
25
|
if (item.type === UserBalanceType.Diamonds || item.type === UserBalanceType.Gems) {
|
|
24
26
|
itemTransformed.type = item.type;
|
|
25
27
|
itemTransformed.amount = item.amount;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { SAWGPMarketType } from '../Quiz/MarketsType';
|
|
2
|
+
import { QuizAnswersValueType } from '../Quiz/MarketsAnswers';
|
|
3
|
+
|
|
4
|
+
export enum GamePickMarketType {
|
|
5
|
+
Goals = 1,
|
|
6
|
+
Winner = 2,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum GamePickResolutionType {
|
|
10
|
+
None = 0,
|
|
11
|
+
Lost = 2,
|
|
12
|
+
PartialWin = 3,
|
|
13
|
+
FullWin = 4,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum GPRoundStatus {
|
|
17
|
+
Other = -1,
|
|
18
|
+
NoEventsDefined = 1,
|
|
19
|
+
NoMoreBetsAllowed = 2,
|
|
20
|
+
AllEventsResolved_ButNotRound = 3,
|
|
21
|
+
RoundResolved = 4,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum GamePickScoreType {
|
|
25
|
+
ExactScore = 1,
|
|
26
|
+
PointsDifference = 2,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum GamePickSportType {
|
|
30
|
+
Golf = 9,
|
|
31
|
+
Cycling = 17,
|
|
32
|
+
Specials = 18,
|
|
33
|
+
TouringCarRacing = 188,
|
|
34
|
+
StockCarRacing = 191,
|
|
35
|
+
IndyRacing = 129,
|
|
36
|
+
Biathlon = 44,
|
|
37
|
+
Speedway = 131,
|
|
38
|
+
Motorsport = 11,
|
|
39
|
+
AlpineSkiing = 43,
|
|
40
|
+
SkiJumping = 48,
|
|
41
|
+
Lacrosse = 39,
|
|
42
|
+
CrossCountry = 46,
|
|
43
|
+
NordicCombined = 47,
|
|
44
|
+
Chess = 33,
|
|
45
|
+
Athletics = 36,
|
|
46
|
+
ESportOverwatch = 121,
|
|
47
|
+
MMA = 117,
|
|
48
|
+
Futsal = 29,
|
|
49
|
+
IceHockey = 4,
|
|
50
|
+
Kabaddi = 138,
|
|
51
|
+
BeachVolley = 34,
|
|
52
|
+
Formula1 = 40,
|
|
53
|
+
ESporteBasketball = 153,
|
|
54
|
+
MotorcycleRacing = 190,
|
|
55
|
+
Bowls = 32,
|
|
56
|
+
Boxing = 10,
|
|
57
|
+
Floorball = 7,
|
|
58
|
+
GaelicHurling = 136,
|
|
59
|
+
Bandy = 15,
|
|
60
|
+
Handball = 6,
|
|
61
|
+
Waterpolo = 26,
|
|
62
|
+
Rugby = 12,
|
|
63
|
+
ESporteSoccer = 137,
|
|
64
|
+
FieldHockey = 24,
|
|
65
|
+
Pesapallo = 61,
|
|
66
|
+
Snooker = 19,
|
|
67
|
+
Badminton = 31,
|
|
68
|
+
Cricket = 21,
|
|
69
|
+
BeachSoccer = 60,
|
|
70
|
+
Baseball = 3,
|
|
71
|
+
StarCraft = 112,
|
|
72
|
+
ESportCounterStrike = 109,
|
|
73
|
+
ESportArenaofValor = 158,
|
|
74
|
+
Curling = 28,
|
|
75
|
+
Squash = 37,
|
|
76
|
+
Darts = 22,
|
|
77
|
+
TableTennis = 20,
|
|
78
|
+
Basketball3x3 = 155,
|
|
79
|
+
AussieRules = 13,
|
|
80
|
+
GaelicFootball = 135,
|
|
81
|
+
CallOfDuty = 118,
|
|
82
|
+
Soccer = 1,
|
|
83
|
+
Tennis = 5,
|
|
84
|
+
ESportDota = 111,
|
|
85
|
+
Basketball = 2,
|
|
86
|
+
ESportLeagueofLegends = 110,
|
|
87
|
+
AmericanFootball = 16,
|
|
88
|
+
Volleyball = 23,
|
|
89
|
+
Netball = 35,
|
|
90
|
+
ESportRocketLeague = 128,
|
|
91
|
+
Schwingen = 56,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export enum GameRoundOrderType {
|
|
95
|
+
HowAdded = 1,
|
|
96
|
+
HowAddedReversed = 2,
|
|
97
|
+
EventDateAscending = 3,
|
|
98
|
+
EventDateDescending = 4,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const AllRoundsGameBoardID = -1;
|
|
102
|
+
|
|
103
|
+
export interface QuizEventMeta {
|
|
104
|
+
answers?: {
|
|
105
|
+
value: string;
|
|
106
|
+
text: string;
|
|
107
|
+
_translations: {
|
|
108
|
+
[key: string]: {
|
|
109
|
+
text: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}[];
|
|
113
|
+
question_image?: string;
|
|
114
|
+
result?: QuizAnswersValueType;
|
|
115
|
+
custom_question: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface GamePickEventMeta extends QuizEventMeta {
|
|
119
|
+
event_name?: string;
|
|
120
|
+
team1_name: string;
|
|
121
|
+
team1_image: string;
|
|
122
|
+
team2_name: string;
|
|
123
|
+
team2_image: string;
|
|
124
|
+
team1_result?: number;
|
|
125
|
+
team2_result?: number;
|
|
126
|
+
sport_type_id?: number;
|
|
127
|
+
is_canceled?: boolean;
|
|
128
|
+
auto_resolve_enabled?: boolean;
|
|
129
|
+
auto_resolve_date?: string;
|
|
130
|
+
team1_auto_result?: number;
|
|
131
|
+
team2_auto_result?: number;
|
|
132
|
+
auto_result?: string;
|
|
133
|
+
_translations: {
|
|
134
|
+
[key: string]: {
|
|
135
|
+
team1_name: string;
|
|
136
|
+
team2_name: string;
|
|
137
|
+
event_name: string;
|
|
138
|
+
custom_question: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface GamePickEvent {
|
|
144
|
+
gp_event_id: number;
|
|
145
|
+
event_resolution_date: number;
|
|
146
|
+
match_date: number;
|
|
147
|
+
market_type_id: SAWGPMarketType;
|
|
148
|
+
event_meta: GamePickEventMeta;
|
|
149
|
+
user_placed_bet: boolean;
|
|
150
|
+
team1_user_selection?: number | { from: number; to: number };
|
|
151
|
+
team2_user_selection?: number | { from: number; to: number };
|
|
152
|
+
user_selection?: QuizAnswersValueType;
|
|
153
|
+
resolution_type_id: GamePickResolutionType;
|
|
154
|
+
resolution_score?: number;
|
|
155
|
+
is_open_for_bets?: boolean;
|
|
156
|
+
odds_details?: { odd_value: { [key: string]: number } };
|
|
157
|
+
question_image?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface GamePickRoundBase {
|
|
161
|
+
round_id: number;
|
|
162
|
+
round_row_id: number;
|
|
163
|
+
round_name: string;
|
|
164
|
+
round_description: string;
|
|
165
|
+
final_screen_cta_button_title: string;
|
|
166
|
+
final_screen_message: string;
|
|
167
|
+
final_screen_image_desktop: string;
|
|
168
|
+
final_screen_image_mobile: string;
|
|
169
|
+
promo_image: string;
|
|
170
|
+
promo_text: string;
|
|
171
|
+
open_date: number;
|
|
172
|
+
last_bet_date: number;
|
|
173
|
+
resolution_date: number;
|
|
174
|
+
score_full_win: number;
|
|
175
|
+
score_part_win: number;
|
|
176
|
+
score_lost: number;
|
|
177
|
+
is_active_now: boolean;
|
|
178
|
+
is_resolved: boolean;
|
|
179
|
+
round_status_id: GPRoundStatus;
|
|
180
|
+
events_total: number;
|
|
181
|
+
events_resolved: number;
|
|
182
|
+
score_type_id: GamePickScoreType;
|
|
183
|
+
order_events: GameRoundOrderType;
|
|
184
|
+
board_users_count: number;
|
|
185
|
+
hide_users_predictions: boolean;
|
|
186
|
+
public_meta: {
|
|
187
|
+
round_name: string;
|
|
188
|
+
round_description: string;
|
|
189
|
+
promo_image: string;
|
|
190
|
+
promo_text: string;
|
|
191
|
+
hide_resolved_round: boolean;
|
|
192
|
+
final_screen_image_desktop: string;
|
|
193
|
+
final_screen_image_mobile: string;
|
|
194
|
+
final_screen_message: string;
|
|
195
|
+
final_screen_cta_button_title: string;
|
|
196
|
+
final_screen_cta_dp: string;
|
|
197
|
+
allow_edit_answers?: boolean;
|
|
198
|
+
_translations: {
|
|
199
|
+
[key: string]: {
|
|
200
|
+
round_name: string;
|
|
201
|
+
round_description: string;
|
|
202
|
+
promo_image: string;
|
|
203
|
+
promo_text: string;
|
|
204
|
+
final_screen_image_desktop: string;
|
|
205
|
+
final_screen_image_mobile: string;
|
|
206
|
+
final_screen_message: string;
|
|
207
|
+
final_screen_cta_button_title: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
next_round_open_date: number;
|
|
212
|
+
show_users_preference: boolean;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface GamePickRound extends GamePickRoundBase {
|
|
216
|
+
events: GamePickEvent[];
|
|
217
|
+
user_score: number;
|
|
218
|
+
user_placed_bet: boolean;
|
|
219
|
+
has_open_for_bet_events?: boolean;
|
|
220
|
+
has_not_submitted_changes?: boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface GamePickRoundBoard extends GamePickRoundBase {
|
|
224
|
+
my_user: GamePickBoardUser;
|
|
225
|
+
users: GamePickBoardUser[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface GamePickBoardUser {
|
|
229
|
+
ext_user_id: string;
|
|
230
|
+
int_user_id: number;
|
|
231
|
+
public_username: string;
|
|
232
|
+
avatar_url: string;
|
|
233
|
+
gp_position: number;
|
|
234
|
+
resolution_score: number;
|
|
235
|
+
full_wins_count: number;
|
|
236
|
+
part_wins_count: number;
|
|
237
|
+
lost_count: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface GamePickUserInfo {
|
|
241
|
+
ext_user_id: string;
|
|
242
|
+
int_user_id: number;
|
|
243
|
+
public_username: string;
|
|
244
|
+
avatar_url: string;
|
|
245
|
+
gp_position?: number;
|
|
246
|
+
full_wins_count?: number;
|
|
247
|
+
part_wins_count?: number;
|
|
248
|
+
resolution_score?: number;
|
|
249
|
+
last_wallet_sync_time?: Date;
|
|
250
|
+
ach_points_balance?: number;
|
|
251
|
+
ach_gems_balance?: number;
|
|
252
|
+
ach_diamonds_balance?: number;
|
|
253
|
+
pubic_username_set?: boolean;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface GamePickGameInfo {
|
|
257
|
+
sawTemplate: any;
|
|
258
|
+
allRounds: GamePickRoundBase[];
|
|
259
|
+
labelInfo: any;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface GamesApiResponse<T> {
|
|
263
|
+
errCode: number;
|
|
264
|
+
errMessage?: string;
|
|
265
|
+
data?: T;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface GamePickRequestParams {
|
|
269
|
+
saw_template_id: number;
|
|
270
|
+
ext_user_id: string;
|
|
271
|
+
smartico_ext_user_id: string;
|
|
272
|
+
lang?: string;
|
|
273
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GPTypes';
|
|
@@ -108,6 +108,7 @@ export const raffleTransform = (items: Raffle[]): TRaffle[] => {
|
|
|
108
108
|
max_tickets_count: item.max_tickets_count,
|
|
109
109
|
current_tickets_count: item.current_tickets_count,
|
|
110
110
|
draws: drawTransform(item.draws),
|
|
111
|
+
ticket_cap_visualization: item.public_meta.ticket_cap_visualization,
|
|
111
112
|
};
|
|
112
113
|
});
|
|
113
114
|
};
|
package/src/Raffle/Raffle.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { RaffleDraw } from "./RaffleDraw";
|
|
2
2
|
|
|
3
|
+
export enum RaffleTicketCapVisualization {
|
|
4
|
+
/** Show nothing */
|
|
5
|
+
Empty = 0,
|
|
6
|
+
/** Show ticket counter */
|
|
7
|
+
Counter = 1,
|
|
8
|
+
/** Show message when ticket cap is reached */
|
|
9
|
+
Message = 2,
|
|
10
|
+
}
|
|
3
11
|
|
|
4
12
|
interface RafflePublicMeta {
|
|
5
13
|
/** Name of the raffle */
|
|
@@ -20,6 +28,12 @@ interface RafflePublicMeta {
|
|
|
20
28
|
* Read more here - <https://help.smartico.ai/welcome/products/general-concepts/custom-fields-attributes>
|
|
21
29
|
*/
|
|
22
30
|
custom_data: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* - Value 1 (Counter): Shows a real-time "Tickets Remaining" display available during the whole Raffle activity.
|
|
34
|
+
* - Value 2 (Message): Will show a specific message that triggers only when the cap is reached and inform users that tickets will be no longer be issued.
|
|
35
|
+
*/
|
|
36
|
+
ticket_cap_visualization?: RaffleTicketCapVisualization;
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -133,9 +133,17 @@ import { GetJackpotWinnersResponse, GetJackpotWinnersResponseTransform, JackpotW
|
|
|
133
133
|
import { GetJackpotWinnersRequest } from './Jackpots/GetJackpotWinnersRequest';
|
|
134
134
|
import { GetJackpotEligibleGamesRequest } from './Jackpots/GetJackpotEligibleGamesRequest';
|
|
135
135
|
import { GetJackpotEligibleGamesResponse, GetJackpotEligibleGamesResponseTransform, JackpotEligibleGame, TGetJackpotEligibleGamesResponse } from './Jackpots/GetJackpotEligibleGamesResponse';
|
|
136
|
+
import {
|
|
137
|
+
GamesApiResponse,
|
|
138
|
+
GamePickRound,
|
|
139
|
+
GamePickRoundBoard,
|
|
140
|
+
GamePickUserInfo,
|
|
141
|
+
GamePickGameInfo,
|
|
142
|
+
} from './GamePick';
|
|
136
143
|
|
|
137
144
|
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
138
145
|
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
|
|
146
|
+
const GAMES_API_URL = 'https://r-games-api{ENV_ID}.smr.vc';
|
|
139
147
|
const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
|
|
140
148
|
const DEFAULT_LANG_EN = 'EN';
|
|
141
149
|
|
|
@@ -160,7 +168,9 @@ class SmarticoAPI {
|
|
|
160
168
|
private wsUrl: string;
|
|
161
169
|
private inboxCdnUrl: string;
|
|
162
170
|
private partnerUrl: string;
|
|
171
|
+
public gamesApiUrl: string;
|
|
163
172
|
public avatarDomain: string;
|
|
173
|
+
private envId: number;
|
|
164
174
|
|
|
165
175
|
private logger: ILogger;
|
|
166
176
|
private logCIDs: ClassId[];
|
|
@@ -185,6 +195,7 @@ class SmarticoAPI {
|
|
|
185
195
|
|
|
186
196
|
this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
|
|
187
197
|
this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
|
|
198
|
+
this.gamesApiUrl = SmarticoAPI.getGamesApiUrl(label_api_key);
|
|
188
199
|
|
|
189
200
|
this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || options.tracker?.label_api_key);
|
|
190
201
|
|
|
@@ -254,8 +265,11 @@ class SmarticoAPI {
|
|
|
254
265
|
return C_SOCKET_PROD.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
255
266
|
}
|
|
256
267
|
|
|
268
|
+
public static getGamesApiUrl(label_api_key: string): string {
|
|
269
|
+
return GAMES_API_URL.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
270
|
+
}
|
|
271
|
+
|
|
257
272
|
public static getAvatarUrl(label_api_key: string): string {
|
|
258
|
-
const envId = SmarticoAPI.getEnvDnsSuffix(label_api_key);
|
|
259
273
|
const avatarUrl = AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
260
274
|
return SmarticoAPI.replaceSmrDomainsWithCloudfront(avatarUrl);
|
|
261
275
|
}
|
|
@@ -1266,6 +1280,101 @@ class SmarticoAPI {
|
|
|
1266
1280
|
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
1267
1281
|
}
|
|
1268
1282
|
|
|
1283
|
+
private buildGamesApiParams(ext_user_id: string, smartico_ext_user_id: string, ext_game_id: number, lang: string): Record<string, string> {
|
|
1284
|
+
const params: Record<string, string> = {
|
|
1285
|
+
ext_user_id,
|
|
1286
|
+
smartico_ext_user_id,
|
|
1287
|
+
ext_game_id: String(ext_game_id),
|
|
1288
|
+
lang,
|
|
1289
|
+
env_id: String(SmarticoAPI.getEnvId(this.label_api_key)),
|
|
1290
|
+
label_api_key: this.label_api_key,
|
|
1291
|
+
hash: '',
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
if (this.brand_api_key) {
|
|
1295
|
+
params.brand_key = this.brand_api_key;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
return params;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
private async sendGamesApi<T>(method: string, ext_user_id: string, smartico_ext_user_id: string, ext_game_id: number, lang: string, extraParams?: Record<string, any>, usePost: boolean = false): Promise<GamesApiResponse<T>> {
|
|
1302
|
+
const baseParams = this.buildGamesApiParams(ext_user_id, smartico_ext_user_id, ext_game_id, lang);
|
|
1303
|
+
const queryString = Object.entries(baseParams).map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join('&');
|
|
1304
|
+
let url = `${this.gamesApiUrl}/${method}?${queryString}`;
|
|
1305
|
+
|
|
1306
|
+
let fetchOptions: RequestInit = {
|
|
1307
|
+
method: 'GET',
|
|
1308
|
+
headers: { 'Accept': 'application/json' },
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
if (usePost && extraParams) {
|
|
1312
|
+
fetchOptions = {
|
|
1313
|
+
method: 'POST',
|
|
1314
|
+
headers: {
|
|
1315
|
+
'Accept': 'application/json',
|
|
1316
|
+
'Content-Type': 'application/json',
|
|
1317
|
+
},
|
|
1318
|
+
body: JSON.stringify(extraParams),
|
|
1319
|
+
};
|
|
1320
|
+
} else if (extraParams) {
|
|
1321
|
+
const extraQuery = Object.entries(extraParams)
|
|
1322
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(JSON.stringify(v))}`)
|
|
1323
|
+
.join('&');
|
|
1324
|
+
url += `&${extraQuery}`;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
try {
|
|
1328
|
+
const response = await fetch(url, fetchOptions);
|
|
1329
|
+
const data = await response.json();
|
|
1330
|
+
return SmarticoAPI.replaceSmrDomainsWithCloudfront<GamesApiResponse<T>>(data);
|
|
1331
|
+
} catch (e) {
|
|
1332
|
+
this.logger.error(`Failed to call games API: ${method}`, { url, error: e.message });
|
|
1333
|
+
throw new Error(`Failed to call games API: ${method}. ${e.message}`);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
public async gpGetActiveRounds(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickRound[]>> {
|
|
1338
|
+
return this.sendGamesApi<GamePickRound[]>('active-rounds', ext_user_id, smartico_ext_user_id, saw_template_id, lang);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
public async gpGetActiveRound(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN, round_id?: number): Promise<GamesApiResponse<GamePickRound>> {
|
|
1342
|
+
const extraParams: Record<string, any> = {};
|
|
1343
|
+
if (round_id !== undefined) {
|
|
1344
|
+
extraParams.round_id = round_id;
|
|
1345
|
+
}
|
|
1346
|
+
return this.sendGamesApi<GamePickRound>('active-round', ext_user_id, smartico_ext_user_id, saw_template_id, lang, Object.keys(extraParams).length > 0 ? extraParams : undefined);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
public async gpGetGamesHistory(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickRound[]>> {
|
|
1350
|
+
return this.sendGamesApi<GamePickRound[]>('games-history', ext_user_id, smartico_ext_user_id, saw_template_id, lang);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
public async gpGetGameBoard(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, round_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickRoundBoard>> {
|
|
1354
|
+
return this.sendGamesApi<GamePickRoundBoard>('game-board', ext_user_id, smartico_ext_user_id, saw_template_id, lang, { round_id });
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
public async gpSubmitSelection(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, round: any, isQuiz: boolean, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickRound>> {
|
|
1358
|
+
const method = isQuiz ? 'submit-selection-quiz' : 'submit-selection';
|
|
1359
|
+
return this.sendGamesApi<GamePickRound>(method, ext_user_id, smartico_ext_user_id, saw_template_id, lang, { round }, true);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
public async gpGetUserInfo(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickUserInfo>> {
|
|
1363
|
+
return this.sendGamesApi<GamePickUserInfo>('user-info', ext_user_id, smartico_ext_user_id, saw_template_id, lang);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
public async gpGetGameInfo(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickGameInfo>> {
|
|
1367
|
+
return this.sendGamesApi<GamePickGameInfo>('game-info', ext_user_id, smartico_ext_user_id, saw_template_id, lang);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
public async gpGetTranslations(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<any>> {
|
|
1371
|
+
return this.sendGamesApi<any>('translations', ext_user_id, smartico_ext_user_id, saw_template_id, lang);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
public async gpGetRoundInfoForUser(ext_user_id: string, smartico_ext_user_id: string, saw_template_id: number, round_id: number, int_user_id: number, lang: string = DEFAULT_LANG_EN): Promise<GamesApiResponse<GamePickRound>> {
|
|
1375
|
+
return this.sendGamesApi<GamePickRound>('game-round-info-for-user', ext_user_id, smartico_ext_user_id, saw_template_id, lang, { round_id, int_user_id });
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1269
1378
|
public getWSCalls(): WSAPI {
|
|
1270
1379
|
return new WSAPI(this);
|
|
1271
1380
|
}
|
|
@@ -68,6 +68,8 @@ export interface Tournament {
|
|
|
68
68
|
minScoreToWin?: number;
|
|
69
69
|
/** When enabled, users who don't meet the minimum qualifying score will be hidden from the Leaderboard. */
|
|
70
70
|
hideLeaderboardsMinScores?: boolean;
|
|
71
|
+
/** Total scores across all participants in the tournament */
|
|
72
|
+
totalScores?: number;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
export const TournamentItemsTransform = (items: Tournament[]): TTournament[] => {
|
|
@@ -112,8 +114,9 @@ export const TournamentItemsTransform = (items: Tournament[]): TTournament[] =>
|
|
|
112
114
|
is_in_progress: TournamentUtils.isInProgress(r),
|
|
113
115
|
is_upcoming: TournamentUtils.isUpcoming(r),
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
min_scores_win: r.minScoreToWin,
|
|
118
|
+
hide_leaderboard_min_scores: r.hideLeaderboardsMinScores,
|
|
119
|
+
total_scores: r.totalScores,
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
if (r.prizeStructure) {
|