@smartico/public-api 0.0.351 → 0.0.353
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 +268 -0
- package/dist/GamePick/index.d.ts +1 -0
- package/dist/Raffle/Raffle.d.ts +13 -0
- package/dist/SmarticoAPI.d.ts +20 -0
- package/dist/Tournaments/Tournament.d.ts +2 -0
- package/dist/WSAPI/WSAPI.d.ts +334 -1
- package/dist/WSAPI/WSAPITypes.d.ts +10 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1223 -452
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +731 -83
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/README.md +3 -0
- package/docs/api/classes/WSAPI.md +199 -0
- package/docs/api/enums/QuizAnswersValueType.md +121 -0
- package/docs/api/enums/RaffleTicketCapVisualization.md +25 -0
- package/docs/api/enums/SAWGPMarketType.md +157 -0
- package/docs/api/interfaces/RafflePublicMeta.md +9 -0
- package/docs/api/interfaces/TRaffle.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 +4 -2
- package/src/GamePick/GPTypes.ts +277 -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 +158 -13
- package/src/Tournaments/Tournament.ts +5 -2
- package/src/WSAPI/WSAPI.ts +476 -62
- package/src/WSAPI/WSAPITypes.ts +10 -2
- package/src/index.ts +3 -1
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface GamePickRoundRequestParams extends GamePickRequestParams {
|
|
276
|
+
round_id: number;
|
|
277
|
+
}
|
|
@@ -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,24 +133,35 @@ 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.smr.vc';
|
|
139
147
|
const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
|
|
140
148
|
const DEFAULT_LANG_EN = 'EN';
|
|
141
149
|
|
|
142
150
|
interface Tracker {
|
|
143
151
|
label_api_key: string;
|
|
144
152
|
userPublicProps: any;
|
|
153
|
+
params: { brand_key?: string };
|
|
145
154
|
on: (callBackKey: ClassId, func: (data: any) => void) => void;
|
|
146
155
|
getLabelSetting: (key: PublicLabelSettings) => any;
|
|
147
156
|
triggerExternalCallBack: (callBackKey: string, payload: any) => void;
|
|
157
|
+
getExtUserId: () => string;
|
|
148
158
|
}
|
|
149
159
|
interface IOptions {
|
|
150
160
|
logger?: ILogger;
|
|
151
161
|
logCIDs?: ClassId[];
|
|
152
162
|
logHTTPTiming?: boolean;
|
|
153
163
|
tracker?: Tracker;
|
|
164
|
+
brand_api_key?: string;
|
|
154
165
|
}
|
|
155
166
|
|
|
156
167
|
type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any>;
|
|
@@ -160,7 +171,10 @@ class SmarticoAPI {
|
|
|
160
171
|
private wsUrl: string;
|
|
161
172
|
private inboxCdnUrl: string;
|
|
162
173
|
private partnerUrl: string;
|
|
174
|
+
private gamesApiUrl: string;
|
|
175
|
+
private baseRgApiParams: Record<string, string>;
|
|
163
176
|
public avatarDomain: string;
|
|
177
|
+
private envId: number;
|
|
164
178
|
|
|
165
179
|
private logger: ILogger;
|
|
166
180
|
private logCIDs: ClassId[];
|
|
@@ -186,6 +200,13 @@ class SmarticoAPI {
|
|
|
186
200
|
this.publicUrl = SmarticoAPI.getPublicUrl(label_api_key);
|
|
187
201
|
this.wsUrl = SmarticoAPI.getPublicWsUrl(label_api_key);
|
|
188
202
|
|
|
203
|
+
this.baseRgApiParams = {
|
|
204
|
+
env_id: String(SmarticoAPI.getEnvId(label_api_key)),
|
|
205
|
+
label_api_key: label_api_key,
|
|
206
|
+
brand_key: options.brand_api_key || this.tracker.params.brand_key,
|
|
207
|
+
hash: IntUtils.uuid(),
|
|
208
|
+
}
|
|
209
|
+
|
|
189
210
|
this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || options.tracker?.label_api_key);
|
|
190
211
|
|
|
191
212
|
this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key);
|
|
@@ -200,7 +221,7 @@ class SmarticoAPI {
|
|
|
200
221
|
return ENV_ID;
|
|
201
222
|
}
|
|
202
223
|
|
|
203
|
-
public static replaceSmrDomainsWithCloudfront<T>(value: string | {[key: string]: any}): T {
|
|
224
|
+
public static replaceSmrDomainsWithCloudfront<T>(value: string | { [key: string]: any }): T {
|
|
204
225
|
if (!value) {
|
|
205
226
|
return value as T;
|
|
206
227
|
}
|
|
@@ -255,7 +276,6 @@ class SmarticoAPI {
|
|
|
255
276
|
}
|
|
256
277
|
|
|
257
278
|
public static getAvatarUrl(label_api_key: string): string {
|
|
258
|
-
const envId = SmarticoAPI.getEnvDnsSuffix(label_api_key);
|
|
259
279
|
const avatarUrl = AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
|
|
260
280
|
return SmarticoAPI.replaceSmrDomainsWithCloudfront(avatarUrl);
|
|
261
281
|
}
|
|
@@ -477,7 +497,7 @@ class SmarticoAPI {
|
|
|
477
497
|
activityType,
|
|
478
498
|
});
|
|
479
499
|
|
|
480
|
-
this.send(message).catch(() => {});
|
|
500
|
+
this.send(message).catch(() => { });
|
|
481
501
|
}
|
|
482
502
|
|
|
483
503
|
/**
|
|
@@ -495,7 +515,7 @@ class SmarticoAPI {
|
|
|
495
515
|
...(action && { action }),
|
|
496
516
|
});
|
|
497
517
|
|
|
498
|
-
this.send(message).catch(() => {});
|
|
518
|
+
this.send(message).catch(() => { });
|
|
499
519
|
}
|
|
500
520
|
|
|
501
521
|
public async jackpotGet(
|
|
@@ -538,7 +558,7 @@ class SmarticoAPI {
|
|
|
538
558
|
return await this.send<JackpotsOptoutResponse>(message, ClassId.JP_OPTOUT_RESPONSE);
|
|
539
559
|
}
|
|
540
560
|
|
|
541
|
-
public async getJackpotWinners(user_ext_id: string, limit: number = 20, offset: number = 0, jp_template_id: number
|
|
561
|
+
public async getJackpotWinners(user_ext_id: string, limit: number = 20, offset: number = 0, jp_template_id: number): Promise<GetJackpotWinnersResponse> {
|
|
542
562
|
const message = this.buildMessage<GetJackpotWinnersRequest, GetJackpotWinnersResponse>(
|
|
543
563
|
user_ext_id,
|
|
544
564
|
ClassId.JP_GET_WINNERS_REQUEST,
|
|
@@ -551,11 +571,11 @@ class SmarticoAPI {
|
|
|
551
571
|
return await this.send<GetJackpotWinnersResponse>(message, ClassId.JP_GET_WINNERS_RESPONSE);
|
|
552
572
|
}
|
|
553
573
|
|
|
554
|
-
public async getJackpotWinnersT(user_ext_id: string, limit: number = 20, offset: number = 0, jp_template_id: number
|
|
574
|
+
public async getJackpotWinnersT(user_ext_id: string, limit: number = 20, offset: number = 0, jp_template_id: number): Promise<JackpotWinnerHistory[]> {
|
|
555
575
|
return GetJackpotWinnersResponseTransform((await this.getJackpotWinners(user_ext_id, limit, offset, jp_template_id)).winners);
|
|
556
576
|
}
|
|
557
577
|
|
|
558
|
-
public async getJackpotEligibleGames(user_ext_id: string, { jp_template_id }
|
|
578
|
+
public async getJackpotEligibleGames(user_ext_id: string, { jp_template_id }: { jp_template_id: number }): Promise<GetJackpotEligibleGamesResponse> {
|
|
559
579
|
const message = this.buildMessage<GetJackpotEligibleGamesRequest, GetJackpotEligibleGamesResponse>(
|
|
560
580
|
user_ext_id,
|
|
561
581
|
ClassId.JP_GET_ELIGIBLE_GAMES_REQUEST,
|
|
@@ -565,7 +585,7 @@ class SmarticoAPI {
|
|
|
565
585
|
return await this.send<GetJackpotEligibleGamesResponse>(message, ClassId.JP_GET_ELIGIBLE_GAMES_RESPONSE);;
|
|
566
586
|
}
|
|
567
587
|
|
|
568
|
-
public async getJackpotEligibleGamesT(user_ext_id: string, { jp_template_id }
|
|
588
|
+
public async getJackpotEligibleGamesT(user_ext_id: string, { jp_template_id }: { jp_template_id: number }): Promise<TGetJackpotEligibleGamesResponse> {
|
|
569
589
|
return GetJackpotEligibleGamesResponseTransform(await this.getJackpotEligibleGames(user_ext_id, { jp_template_id }));
|
|
570
590
|
}
|
|
571
591
|
|
|
@@ -729,7 +749,7 @@ class SmarticoAPI {
|
|
|
729
749
|
public async getSawWinningHistoryT(user_ext_id: string, limit?: number, offset?: number, saw_template_id?: number): Promise<SAWPrizesHistory[]> {
|
|
730
750
|
return SAWHistoryTransform((await this.getSawWinningHistory(user_ext_id, limit, offset, saw_template_id)).prizes);
|
|
731
751
|
}
|
|
732
|
-
|
|
752
|
+
|
|
733
753
|
public async missionOptIn(user_ext_id: string, mission_id: number) {
|
|
734
754
|
if (!mission_id) {
|
|
735
755
|
throw new Error('Missing mission id');
|
|
@@ -932,7 +952,7 @@ class SmarticoAPI {
|
|
|
932
952
|
ClassId.GET_BONUSES_RESPONSE,
|
|
933
953
|
force_language,
|
|
934
954
|
);
|
|
935
|
-
|
|
955
|
+
|
|
936
956
|
const responseClone = { ...response };
|
|
937
957
|
|
|
938
958
|
return responseClone;
|
|
@@ -949,7 +969,7 @@ class SmarticoAPI {
|
|
|
949
969
|
ClassId.CLAIM_BONUS_RESPONSE,
|
|
950
970
|
|
|
951
971
|
);
|
|
952
|
-
|
|
972
|
+
|
|
953
973
|
const responseClone = { ...response };
|
|
954
974
|
|
|
955
975
|
return responseClone;
|
|
@@ -1266,19 +1286,144 @@ class SmarticoAPI {
|
|
|
1266
1286
|
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
1267
1287
|
}
|
|
1268
1288
|
|
|
1289
|
+
private buildGamesApiParams(): Record<string, string> {
|
|
1290
|
+
const params: Record<string, string> = Object.assign({}, this.baseRgApiParams, {
|
|
1291
|
+
ext_user_id: this.tracker.userPublicProps?.user_id,
|
|
1292
|
+
smartico_ext_user_id: this.tracker.getExtUserId(),
|
|
1293
|
+
lang: this.tracker.userPublicProps?.core_user_language,
|
|
1294
|
+
});
|
|
1295
|
+
|
|
1296
|
+
return params;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
private async sendGamesApi<T>({ method, params, usePost = false }: { method: string, params: Record<string, any>, usePost?: boolean }): Promise<GamesApiResponse<T>> {
|
|
1300
|
+
const baseParams = this.buildGamesApiParams();
|
|
1301
|
+
const queryString = Object.entries(baseParams).map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join('&');
|
|
1302
|
+
let url = `${GAMES_API_URL}/${method}?${queryString}`;
|
|
1303
|
+
|
|
1304
|
+
let fetchOptions: RequestInit = {
|
|
1305
|
+
method: 'GET',
|
|
1306
|
+
headers: { 'Accept': 'application/json' },
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
if (usePost && params) {
|
|
1310
|
+
fetchOptions = {
|
|
1311
|
+
method: 'POST',
|
|
1312
|
+
headers: {
|
|
1313
|
+
'Accept': 'application/json',
|
|
1314
|
+
'Content-Type': 'application/json',
|
|
1315
|
+
},
|
|
1316
|
+
body: JSON.stringify(params),
|
|
1317
|
+
};
|
|
1318
|
+
} else if (params) {
|
|
1319
|
+
const extraQuery = Object.entries(params)
|
|
1320
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(JSON.stringify(v))}`)
|
|
1321
|
+
.join('&');
|
|
1322
|
+
url += `&${extraQuery}`;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
try {
|
|
1326
|
+
const response = await fetch(url, fetchOptions);
|
|
1327
|
+
|
|
1328
|
+
const data = await response.json();
|
|
1329
|
+
return SmarticoAPI.replaceSmrDomainsWithCloudfront<GamesApiResponse<T>>(data);
|
|
1330
|
+
} catch (e) {
|
|
1331
|
+
this.logger.error(`Failed to call games API: ${method}`, { url, error: e.message });
|
|
1332
|
+
throw new Error(`Failed to call games API: ${method}. ${e.message}`);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
public async gpGetActiveRounds(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>> {
|
|
1337
|
+
const params = {
|
|
1338
|
+
ext_game_id: saw_template_id,
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
return this.sendGamesApi<GamePickRound[]>({ method: 'active-rounds', params });
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
public async gpGetActiveRound(saw_template_id: number, round_id?: number): Promise<GamesApiResponse<GamePickRound>> {
|
|
1345
|
+
const params = {
|
|
1346
|
+
ext_game_id: saw_template_id,
|
|
1347
|
+
round_id: round_id,
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
return this.sendGamesApi<GamePickRound>({ method: 'active-round', params });
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
public async gpGetGamesHistory(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>> {
|
|
1354
|
+
const params = {
|
|
1355
|
+
ext_game_id: saw_template_id,
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
return this.sendGamesApi<GamePickRound[]>({ method: 'games-history', params });
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
public async gpGetGameBoard(saw_template_id: number, round_id: number): Promise<GamesApiResponse<GamePickRoundBoard>> {
|
|
1362
|
+
const params = {
|
|
1363
|
+
ext_game_id: saw_template_id,
|
|
1364
|
+
round_id: round_id,
|
|
1365
|
+
};
|
|
1366
|
+
|
|
1367
|
+
return this.sendGamesApi<GamePickRoundBoard>({ method: 'game-board', params });
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
public async gpSubmitSelection(saw_template_id: number, round: any, isQuiz: boolean): Promise<GamesApiResponse<GamePickRound>> {
|
|
1371
|
+
const method = isQuiz ? 'submit-selection-quiz' : 'submit-selection';
|
|
1372
|
+
const params = {
|
|
1373
|
+
ext_game_id: saw_template_id,
|
|
1374
|
+
round: round,
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
return this.sendGamesApi<GamePickRound>({ method, params, usePost: true });
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
public async gpGetUserInfo(saw_template_id: number): Promise<GamesApiResponse<GamePickUserInfo>> {
|
|
1381
|
+
const params = {
|
|
1382
|
+
ext_game_id: saw_template_id,
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
return this.sendGamesApi<GamePickUserInfo>({ method: 'user-info', params });
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
public async gpGetGameInfo(saw_template_id: number): Promise<GamesApiResponse<GamePickGameInfo>> {
|
|
1389
|
+
const params = {
|
|
1390
|
+
ext_game_id: saw_template_id,
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
return this.sendGamesApi<GamePickGameInfo>({ method: 'game-info', params });
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
public async gpGetTranslations(saw_template_id: number): Promise<GamesApiResponse<any>> {
|
|
1397
|
+
const params = {
|
|
1398
|
+
ext_game_id: saw_template_id,
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
return this.sendGamesApi<any>({ method: 'translations', params });
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
public async gpGetRoundInfoForUser(saw_template_id: number, round_id: number, int_user_id: number): Promise<GamesApiResponse<GamePickRound>> {
|
|
1405
|
+
const params = {
|
|
1406
|
+
ext_game_id: saw_template_id,
|
|
1407
|
+
round_id: round_id,
|
|
1408
|
+
int_user_id: int_user_id,
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
return this.sendGamesApi<GamePickRound>({ method: 'game-round-info-for-user', params });
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1269
1414
|
public getWSCalls(): WSAPI {
|
|
1270
1415
|
return new WSAPI(this);
|
|
1271
1416
|
}
|
|
1272
1417
|
|
|
1273
1418
|
public async getRelatedItemsForGame(user_ext_id: string, related_game_id: string,): Promise<GetRelatedAchTourResponse> {
|
|
1274
|
-
const message = this.buildMessage<
|
|
1419
|
+
const message = this.buildMessage<GetRelatedAchTourRequest, GetRelatedAchTourResponse>(
|
|
1275
1420
|
user_ext_id,
|
|
1276
1421
|
ClassId.GET_RELATED_ACH_N_TOURNAMENTS_REQUEST,
|
|
1277
1422
|
{
|
|
1278
1423
|
related_game_id: related_game_id
|
|
1279
1424
|
}
|
|
1280
1425
|
);
|
|
1281
|
-
|
|
1426
|
+
|
|
1282
1427
|
return await this.send<GetRelatedAchTourResponse>(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE);
|
|
1283
1428
|
}
|
|
1284
1429
|
|
|
@@ -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) {
|