@dubsdotapp/node 0.1.2 → 0.2.1
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/README.md +141 -9
- package/dist/index.d.mts +275 -1
- package/dist/index.d.ts +275 -1
- package/dist/index.js +164 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +31 -1
- package/src/index.ts +65 -0
- package/src/resources/auth.ts +40 -0
- package/src/resources/base.ts +14 -0
- package/src/resources/events.ts +35 -0
- package/src/resources/games.ts +71 -0
- package/src/resources/index.ts +8 -0
- package/src/resources/transactions.ts +8 -0
- package/src/resources/ufc.ts +8 -0
- package/src/resources/users.ts +16 -0
- package/src/types.ts +270 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type RequestFn = <T>(method: string, path: string, body?: string, extraHeaders?: Record<string, string>) => Promise<T>;
|
|
2
|
+
declare class BaseResource {
|
|
3
|
+
protected request: RequestFn;
|
|
4
|
+
constructor(request: RequestFn);
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
declare const DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
|
|
2
8
|
type DubsNetwork = 'devnet' | 'mainnet-beta';
|
|
3
9
|
declare const NETWORK_CONFIG: Record<DubsNetwork, {
|
|
@@ -36,12 +42,280 @@ interface WebhookEvent {
|
|
|
36
42
|
timestamp: string;
|
|
37
43
|
data: Record<string, unknown>;
|
|
38
44
|
}
|
|
45
|
+
interface User {
|
|
46
|
+
walletAddress: string;
|
|
47
|
+
username: string;
|
|
48
|
+
avatar?: string;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface Game {
|
|
54
|
+
id: string;
|
|
55
|
+
status: string;
|
|
56
|
+
gameMode: number;
|
|
57
|
+
eventId?: string;
|
|
58
|
+
wagerAmount: number;
|
|
59
|
+
players: Record<string, unknown>[];
|
|
60
|
+
winner?: string | null;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
interface Event {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
type: string;
|
|
69
|
+
league?: string;
|
|
70
|
+
startTime: string;
|
|
71
|
+
status: string;
|
|
72
|
+
teams: {
|
|
73
|
+
home: string;
|
|
74
|
+
away: string;
|
|
75
|
+
};
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
interface NonceParams {
|
|
79
|
+
walletAddress: string;
|
|
80
|
+
}
|
|
81
|
+
interface NonceResponse {
|
|
82
|
+
nonce: string;
|
|
83
|
+
}
|
|
84
|
+
interface AuthenticateParams {
|
|
85
|
+
walletAddress: string;
|
|
86
|
+
signature: string;
|
|
87
|
+
nonce: string;
|
|
88
|
+
}
|
|
89
|
+
interface AuthenticateResponse {
|
|
90
|
+
token: string;
|
|
91
|
+
user: User;
|
|
92
|
+
}
|
|
93
|
+
interface RegisterParams {
|
|
94
|
+
walletAddress: string;
|
|
95
|
+
signature: string;
|
|
96
|
+
nonce: string;
|
|
97
|
+
username: string;
|
|
98
|
+
}
|
|
99
|
+
interface RegisterResponse {
|
|
100
|
+
token: string;
|
|
101
|
+
user: User;
|
|
102
|
+
}
|
|
103
|
+
interface MeResponse {
|
|
104
|
+
user: User;
|
|
105
|
+
}
|
|
106
|
+
interface CheckUsernameResponse {
|
|
107
|
+
available: boolean;
|
|
108
|
+
username: string;
|
|
109
|
+
}
|
|
110
|
+
interface UserResponse {
|
|
111
|
+
user: User;
|
|
112
|
+
}
|
|
113
|
+
interface UsersListParams {
|
|
114
|
+
limit?: number;
|
|
115
|
+
offset?: number;
|
|
116
|
+
}
|
|
117
|
+
interface UsersListResponse {
|
|
118
|
+
users: User[];
|
|
119
|
+
total: number;
|
|
120
|
+
}
|
|
121
|
+
interface UpcomingEventsParams {
|
|
122
|
+
type?: string;
|
|
123
|
+
page?: number;
|
|
124
|
+
limit?: number;
|
|
125
|
+
}
|
|
126
|
+
interface EventsResponse {
|
|
127
|
+
events: Event[];
|
|
128
|
+
total?: number;
|
|
129
|
+
}
|
|
130
|
+
interface EsportsParams {
|
|
131
|
+
videogame?: string;
|
|
132
|
+
page?: number;
|
|
133
|
+
limit?: number;
|
|
134
|
+
}
|
|
135
|
+
interface EsportsMatchResponse {
|
|
136
|
+
match: Record<string, unknown>;
|
|
137
|
+
}
|
|
138
|
+
interface ValidateParams {
|
|
139
|
+
eventId: string;
|
|
140
|
+
}
|
|
141
|
+
interface ValidateResponse {
|
|
142
|
+
valid: boolean;
|
|
143
|
+
event: Event;
|
|
144
|
+
}
|
|
145
|
+
interface GameCreateParams {
|
|
146
|
+
id: string;
|
|
147
|
+
playerWallet: string;
|
|
148
|
+
teamChoice: string;
|
|
149
|
+
wagerAmount: number;
|
|
150
|
+
}
|
|
151
|
+
interface GameCreateResponse {
|
|
152
|
+
game: Game;
|
|
153
|
+
transaction: string;
|
|
154
|
+
}
|
|
155
|
+
interface GameJoinParams {
|
|
156
|
+
playerWallet: string;
|
|
157
|
+
gameId: string;
|
|
158
|
+
teamChoice: string;
|
|
159
|
+
amount: number;
|
|
160
|
+
}
|
|
161
|
+
interface GameJoinResponse {
|
|
162
|
+
game: Game;
|
|
163
|
+
transaction: string;
|
|
164
|
+
}
|
|
165
|
+
interface GameConfirmParams {
|
|
166
|
+
gameId: string;
|
|
167
|
+
playerWallet: string;
|
|
168
|
+
signature: string;
|
|
169
|
+
[key: string]: unknown;
|
|
170
|
+
}
|
|
171
|
+
interface GameConfirmResponse {
|
|
172
|
+
game: Game;
|
|
173
|
+
}
|
|
174
|
+
interface GameListParams {
|
|
175
|
+
status?: string;
|
|
176
|
+
limit?: number;
|
|
177
|
+
offset?: number;
|
|
178
|
+
}
|
|
179
|
+
interface GameListResponse {
|
|
180
|
+
games: Game[];
|
|
181
|
+
total: number;
|
|
182
|
+
}
|
|
183
|
+
interface NetworkGamesParams {
|
|
184
|
+
limit?: number;
|
|
185
|
+
offset?: number;
|
|
186
|
+
}
|
|
187
|
+
interface NetworkGamesResponse {
|
|
188
|
+
games: Game[];
|
|
189
|
+
total: number;
|
|
190
|
+
}
|
|
191
|
+
interface LiveScoreResponse {
|
|
192
|
+
gameId: string;
|
|
193
|
+
score: Record<string, unknown>;
|
|
194
|
+
status: string;
|
|
195
|
+
[key: string]: unknown;
|
|
196
|
+
}
|
|
197
|
+
interface CustomGameCreateParams {
|
|
198
|
+
playerWallet: string;
|
|
199
|
+
teamChoice: string;
|
|
200
|
+
wagerAmount: number;
|
|
201
|
+
[key: string]: unknown;
|
|
202
|
+
}
|
|
203
|
+
interface CustomGameCreateResponse {
|
|
204
|
+
game: Game;
|
|
205
|
+
transaction: string;
|
|
206
|
+
}
|
|
207
|
+
interface CustomGameConfirmParams {
|
|
208
|
+
gameId: string;
|
|
209
|
+
playerWallet: string;
|
|
210
|
+
signature: string;
|
|
211
|
+
[key: string]: unknown;
|
|
212
|
+
}
|
|
213
|
+
interface CustomGameConfirmResponse {
|
|
214
|
+
game: Game;
|
|
215
|
+
}
|
|
216
|
+
interface BuildClaimParams {
|
|
217
|
+
playerWallet: string;
|
|
218
|
+
gameId: string;
|
|
219
|
+
}
|
|
220
|
+
interface BuildClaimResponse {
|
|
221
|
+
transaction: string;
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
}
|
|
224
|
+
interface AppConfigResponse {
|
|
225
|
+
[key: string]: unknown;
|
|
226
|
+
}
|
|
227
|
+
interface UFCFighter {
|
|
228
|
+
name: string;
|
|
229
|
+
imageUrl: string | null;
|
|
230
|
+
abbreviation: string;
|
|
231
|
+
record: string | null;
|
|
232
|
+
winner: boolean;
|
|
233
|
+
}
|
|
234
|
+
interface UFCData {
|
|
235
|
+
currentRound: number;
|
|
236
|
+
totalRounds: number;
|
|
237
|
+
clock: string;
|
|
238
|
+
fightState: 'pre' | 'in' | 'post';
|
|
239
|
+
statusDetail: string;
|
|
240
|
+
statusShortDetail?: string;
|
|
241
|
+
}
|
|
242
|
+
interface UFCFight {
|
|
243
|
+
id: string | null;
|
|
244
|
+
home: UFCFighter;
|
|
245
|
+
away: UFCFighter;
|
|
246
|
+
weightClass: string | null;
|
|
247
|
+
status: string;
|
|
248
|
+
ufcData: UFCData | null;
|
|
249
|
+
}
|
|
250
|
+
interface UFCEvent {
|
|
251
|
+
eventName: string;
|
|
252
|
+
date: string | null;
|
|
253
|
+
fights: UFCFight[];
|
|
254
|
+
}
|
|
255
|
+
interface UFCFightCardResponse {
|
|
256
|
+
success: boolean;
|
|
257
|
+
events: UFCEvent[];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare class AuthResource extends BaseResource {
|
|
261
|
+
getNonce(walletAddress: string): Promise<NonceResponse>;
|
|
262
|
+
authenticate(params: AuthenticateParams): Promise<AuthenticateResponse>;
|
|
263
|
+
register(params: RegisterParams): Promise<RegisterResponse>;
|
|
264
|
+
me(userToken: string): Promise<MeResponse>;
|
|
265
|
+
logout(userToken: string): Promise<void>;
|
|
266
|
+
checkUsername(username: string): Promise<CheckUsernameResponse>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class UsersResource extends BaseResource {
|
|
270
|
+
get(walletAddress: string): Promise<UserResponse>;
|
|
271
|
+
list(params?: UsersListParams): Promise<UsersListResponse>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare class EventsResource extends BaseResource {
|
|
275
|
+
upcoming(params?: UpcomingEventsParams): Promise<EventsResponse>;
|
|
276
|
+
sports(league: string): Promise<EventsResponse>;
|
|
277
|
+
esports(params?: EsportsParams): Promise<EventsResponse>;
|
|
278
|
+
esportsMatch(matchId: string): Promise<EsportsMatchResponse>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare class GamesResource extends BaseResource {
|
|
282
|
+
validate(eventId: string): Promise<ValidateResponse>;
|
|
283
|
+
create(params: GameCreateParams): Promise<GameCreateResponse>;
|
|
284
|
+
join(params: GameJoinParams): Promise<GameJoinResponse>;
|
|
285
|
+
confirm(params: GameConfirmParams): Promise<GameConfirmResponse>;
|
|
286
|
+
get(gameId: string): Promise<{
|
|
287
|
+
game: Game;
|
|
288
|
+
}>;
|
|
289
|
+
list(params?: GameListParams): Promise<GameListResponse>;
|
|
290
|
+
network(params?: NetworkGamesParams): Promise<NetworkGamesResponse>;
|
|
291
|
+
liveScore(gameId: string): Promise<LiveScoreResponse>;
|
|
292
|
+
customCreate(params: CustomGameCreateParams): Promise<CustomGameCreateResponse>;
|
|
293
|
+
customConfirm(params: CustomGameConfirmParams): Promise<CustomGameConfirmResponse>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
declare class TransactionsResource extends BaseResource {
|
|
297
|
+
buildClaim(params: BuildClaimParams): Promise<BuildClaimResponse>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare class UFCResource extends BaseResource {
|
|
301
|
+
fightCard(): Promise<UFCFightCardResponse>;
|
|
302
|
+
}
|
|
39
303
|
|
|
40
304
|
declare class Dubs {
|
|
41
305
|
private readonly apiKey;
|
|
42
306
|
private readonly resolutionSecret?;
|
|
43
307
|
private readonly baseUrl;
|
|
308
|
+
readonly auth: AuthResource;
|
|
309
|
+
readonly users: UsersResource;
|
|
310
|
+
readonly events: EventsResource;
|
|
311
|
+
readonly games: GamesResource;
|
|
312
|
+
readonly transactions: TransactionsResource;
|
|
313
|
+
readonly ufc: UFCResource;
|
|
44
314
|
constructor(config: DubsConfig);
|
|
315
|
+
/**
|
|
316
|
+
* Fetch the platform configuration.
|
|
317
|
+
*/
|
|
318
|
+
config(): Promise<AppConfigResponse>;
|
|
45
319
|
/**
|
|
46
320
|
* Resolve a custom game (game_mode=6).
|
|
47
321
|
*
|
|
@@ -67,4 +341,4 @@ declare class DubsApiError extends Error {
|
|
|
67
341
|
constructor(code: string, message: string, httpStatus: number);
|
|
68
342
|
}
|
|
69
343
|
|
|
70
|
-
export { DEFAULT_BASE_URL, Dubs, DubsApiError, type DubsConfig, type DubsNetwork, NETWORK_CONFIG, type ResolveGameParams, type ResolveGameResult, type WebhookEvent };
|
|
344
|
+
export { type AppConfigResponse, AuthResource, type AuthenticateParams, type AuthenticateResponse, type BuildClaimParams, type BuildClaimResponse, type CheckUsernameResponse, type CustomGameConfirmParams, type CustomGameConfirmResponse, type CustomGameCreateParams, type CustomGameCreateResponse, DEFAULT_BASE_URL, Dubs, DubsApiError, type DubsConfig, type DubsNetwork, type EsportsMatchResponse, type EsportsParams, type Event, EventsResource, type EventsResponse, type Game, type GameConfirmParams, type GameConfirmResponse, type GameCreateParams, type GameCreateResponse, type GameJoinParams, type GameJoinResponse, type GameListParams, type GameListResponse, GamesResource, type LiveScoreResponse, type MeResponse, NETWORK_CONFIG, type NetworkGamesParams, type NetworkGamesResponse, type NonceParams, type NonceResponse, type RegisterParams, type RegisterResponse, type RequestFn, type ResolveGameParams, type ResolveGameResult, TransactionsResource, type UFCData, type UFCEvent, type UFCFight, type UFCFightCardResponse, type UFCFighter, UFCResource, type UpcomingEventsParams, type User, type UserResponse, type UsersListParams, type UsersListResponse, UsersResource, type ValidateParams, type ValidateResponse, type WebhookEvent };
|
package/dist/index.js
CHANGED
|
@@ -30,10 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
AuthResource: () => AuthResource,
|
|
33
34
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
34
35
|
Dubs: () => Dubs,
|
|
35
36
|
DubsApiError: () => DubsApiError,
|
|
36
|
-
|
|
37
|
+
EventsResource: () => EventsResource,
|
|
38
|
+
GamesResource: () => GamesResource,
|
|
39
|
+
NETWORK_CONFIG: () => NETWORK_CONFIG,
|
|
40
|
+
TransactionsResource: () => TransactionsResource,
|
|
41
|
+
UFCResource: () => UFCResource,
|
|
42
|
+
UsersResource: () => UsersResource
|
|
37
43
|
});
|
|
38
44
|
module.exports = __toCommonJS(index_exports);
|
|
39
45
|
|
|
@@ -63,11 +69,148 @@ var DubsApiError = class extends Error {
|
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
|
|
72
|
+
// src/resources/base.ts
|
|
73
|
+
var BaseResource = class {
|
|
74
|
+
request;
|
|
75
|
+
constructor(request) {
|
|
76
|
+
this.request = request;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/resources/auth.ts
|
|
81
|
+
var AuthResource = class extends BaseResource {
|
|
82
|
+
async getNonce(walletAddress) {
|
|
83
|
+
return this.request("GET", `/auth/nonce?walletAddress=${encodeURIComponent(walletAddress)}`);
|
|
84
|
+
}
|
|
85
|
+
async authenticate(params) {
|
|
86
|
+
return this.request("POST", "/auth/authenticate", JSON.stringify(params));
|
|
87
|
+
}
|
|
88
|
+
async register(params) {
|
|
89
|
+
return this.request("POST", "/auth/register", JSON.stringify(params));
|
|
90
|
+
}
|
|
91
|
+
async me(userToken) {
|
|
92
|
+
return this.request("GET", "/auth/me", void 0, {
|
|
93
|
+
Authorization: `Bearer ${userToken}`
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async logout(userToken) {
|
|
97
|
+
await this.request("POST", "/auth/logout", void 0, {
|
|
98
|
+
Authorization: `Bearer ${userToken}`
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async checkUsername(username) {
|
|
102
|
+
return this.request("GET", `/auth/check-username?username=${encodeURIComponent(username)}`);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/resources/users.ts
|
|
107
|
+
var UsersResource = class extends BaseResource {
|
|
108
|
+
async get(walletAddress) {
|
|
109
|
+
return this.request("GET", `/users/${encodeURIComponent(walletAddress)}`);
|
|
110
|
+
}
|
|
111
|
+
async list(params) {
|
|
112
|
+
const query = new URLSearchParams();
|
|
113
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
114
|
+
if (params?.offset != null) query.set("offset", String(params.offset));
|
|
115
|
+
const qs = query.toString();
|
|
116
|
+
return this.request("GET", `/users${qs ? `?${qs}` : ""}`);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/resources/events.ts
|
|
121
|
+
var EventsResource = class extends BaseResource {
|
|
122
|
+
async upcoming(params) {
|
|
123
|
+
const query = new URLSearchParams();
|
|
124
|
+
if (params?.type) query.set("type", params.type);
|
|
125
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
126
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
127
|
+
const qs = query.toString();
|
|
128
|
+
return this.request("GET", `/events/upcoming${qs ? `?${qs}` : ""}`);
|
|
129
|
+
}
|
|
130
|
+
async sports(league) {
|
|
131
|
+
return this.request("GET", `/events/sports/${encodeURIComponent(league)}`);
|
|
132
|
+
}
|
|
133
|
+
async esports(params) {
|
|
134
|
+
const query = new URLSearchParams();
|
|
135
|
+
if (params?.videogame) query.set("videogame", params.videogame);
|
|
136
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
137
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
138
|
+
const qs = query.toString();
|
|
139
|
+
return this.request("GET", `/events/esports${qs ? `?${qs}` : ""}`);
|
|
140
|
+
}
|
|
141
|
+
async esportsMatch(matchId) {
|
|
142
|
+
return this.request("GET", `/events/esports/match/${encodeURIComponent(matchId)}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// src/resources/games.ts
|
|
147
|
+
var GamesResource = class extends BaseResource {
|
|
148
|
+
async validate(eventId) {
|
|
149
|
+
return this.request("GET", `/games/validate?eventId=${encodeURIComponent(eventId)}`);
|
|
150
|
+
}
|
|
151
|
+
async create(params) {
|
|
152
|
+
return this.request("POST", "/games/create", JSON.stringify(params));
|
|
153
|
+
}
|
|
154
|
+
async join(params) {
|
|
155
|
+
return this.request("POST", "/games/join", JSON.stringify(params));
|
|
156
|
+
}
|
|
157
|
+
async confirm(params) {
|
|
158
|
+
return this.request("POST", "/games/confirm", JSON.stringify(params));
|
|
159
|
+
}
|
|
160
|
+
async get(gameId) {
|
|
161
|
+
return this.request("GET", `/games/${encodeURIComponent(gameId)}`);
|
|
162
|
+
}
|
|
163
|
+
async list(params) {
|
|
164
|
+
const query = new URLSearchParams();
|
|
165
|
+
if (params?.status) query.set("status", params.status);
|
|
166
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
167
|
+
if (params?.offset != null) query.set("offset", String(params.offset));
|
|
168
|
+
const qs = query.toString();
|
|
169
|
+
return this.request("GET", `/games${qs ? `?${qs}` : ""}`);
|
|
170
|
+
}
|
|
171
|
+
async network(params) {
|
|
172
|
+
const query = new URLSearchParams();
|
|
173
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
174
|
+
if (params?.offset != null) query.set("offset", String(params.offset));
|
|
175
|
+
const qs = query.toString();
|
|
176
|
+
return this.request("GET", `/games/network${qs ? `?${qs}` : ""}`);
|
|
177
|
+
}
|
|
178
|
+
async liveScore(gameId) {
|
|
179
|
+
return this.request("GET", `/games/${encodeURIComponent(gameId)}/live-score`);
|
|
180
|
+
}
|
|
181
|
+
async customCreate(params) {
|
|
182
|
+
return this.request("POST", "/games/custom/create", JSON.stringify(params));
|
|
183
|
+
}
|
|
184
|
+
async customConfirm(params) {
|
|
185
|
+
return this.request("POST", "/games/custom/confirm", JSON.stringify(params));
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/resources/transactions.ts
|
|
190
|
+
var TransactionsResource = class extends BaseResource {
|
|
191
|
+
async buildClaim(params) {
|
|
192
|
+
return this.request("POST", "/transactions/build-claim", JSON.stringify(params));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/resources/ufc.ts
|
|
197
|
+
var UFCResource = class extends BaseResource {
|
|
198
|
+
async fightCard() {
|
|
199
|
+
return this.request("GET", "/ufc/fightcard");
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
66
203
|
// src/client.ts
|
|
67
204
|
var Dubs = class {
|
|
68
205
|
apiKey;
|
|
69
206
|
resolutionSecret;
|
|
70
207
|
baseUrl;
|
|
208
|
+
auth;
|
|
209
|
+
users;
|
|
210
|
+
events;
|
|
211
|
+
games;
|
|
212
|
+
transactions;
|
|
213
|
+
ufc;
|
|
71
214
|
constructor(config) {
|
|
72
215
|
this.apiKey = config.apiKey;
|
|
73
216
|
this.resolutionSecret = config.resolutionSecret;
|
|
@@ -78,6 +221,19 @@ var Dubs = class {
|
|
|
78
221
|
} else {
|
|
79
222
|
this.baseUrl = DEFAULT_BASE_URL;
|
|
80
223
|
}
|
|
224
|
+
const boundRequest = this.request.bind(this);
|
|
225
|
+
this.auth = new AuthResource(boundRequest);
|
|
226
|
+
this.users = new UsersResource(boundRequest);
|
|
227
|
+
this.events = new EventsResource(boundRequest);
|
|
228
|
+
this.games = new GamesResource(boundRequest);
|
|
229
|
+
this.transactions = new TransactionsResource(boundRequest);
|
|
230
|
+
this.ufc = new UFCResource(boundRequest);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Fetch the platform configuration.
|
|
234
|
+
*/
|
|
235
|
+
async config() {
|
|
236
|
+
return this.request("GET", "/config");
|
|
81
237
|
}
|
|
82
238
|
/**
|
|
83
239
|
* Resolve a custom game (game_mode=6).
|
|
@@ -145,9 +301,15 @@ var Dubs = class {
|
|
|
145
301
|
};
|
|
146
302
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
303
|
0 && (module.exports = {
|
|
304
|
+
AuthResource,
|
|
148
305
|
DEFAULT_BASE_URL,
|
|
149
306
|
Dubs,
|
|
150
307
|
DubsApiError,
|
|
151
|
-
|
|
308
|
+
EventsResource,
|
|
309
|
+
GamesResource,
|
|
310
|
+
NETWORK_CONFIG,
|
|
311
|
+
TransactionsResource,
|
|
312
|
+
UFCResource,
|
|
313
|
+
UsersResource
|
|
152
314
|
});
|
|
153
315
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/constants.ts","../src/errors.ts"],"sourcesContent":["export { Dubs } from './client';\nexport { DubsApiError } from './errors';\nexport type { DubsConfig, ResolveGameParams, ResolveGameResult, WebhookEvent } from './types';\nexport { DEFAULT_BASE_URL, NETWORK_CONFIG } from './constants';\nexport type { DubsNetwork } from './constants';\n","import crypto from 'crypto';\nimport { DEFAULT_BASE_URL, NETWORK_CONFIG } from './constants';\nimport { DubsApiError } from './errors';\nimport type { DubsConfig, ResolveGameParams, ResolveGameResult, WebhookEvent } from './types';\n\nexport class Dubs {\n private readonly apiKey: string;\n private readonly resolutionSecret?: string;\n private readonly baseUrl: string;\n\n constructor(config: DubsConfig) {\n this.apiKey = config.apiKey;\n this.resolutionSecret = config.resolutionSecret;\n\n if (config.baseUrl) {\n this.baseUrl = config.baseUrl;\n } else if (config.network) {\n this.baseUrl = NETWORK_CONFIG[config.network].baseUrl;\n } else {\n this.baseUrl = DEFAULT_BASE_URL;\n }\n }\n\n /**\n * Resolve a custom game (game_mode=6).\n *\n * Automatically computes the HMAC-SHA256 signature using your resolution secret.\n */\n async resolveGame(gameId: string, params: ResolveGameParams): Promise<ResolveGameResult> {\n if (!this.resolutionSecret) {\n throw new DubsApiError(\n 'missing_resolution_secret',\n 'resolutionSecret is required for resolveGame(). Pass it in the Dubs constructor.',\n 0,\n );\n }\n\n const body = JSON.stringify({\n winner: params.winner,\n ...(params.metadata && { metadata: params.metadata }),\n });\n\n const hmac = crypto.createHmac('sha256', this.resolutionSecret).update(body).digest('hex');\n\n return this.request<ResolveGameResult>('POST', `/games/${gameId}/resolve`, body, {\n 'x-dubs-signature': `sha256=${hmac}`,\n });\n }\n\n /**\n * Verify an incoming Dubs webhook request.\n *\n * @param rawBody - The raw request body (string or Buffer)\n * @param signature - The X-Dubs-Signature header value\n * @param secret - Your webhook secret (from the developer portal)\n * @returns The parsed webhook event\n * @throws DubsApiError if the signature is invalid\n */\n static verifyWebhook(rawBody: string | Buffer, signature: string, secret: string): WebhookEvent {\n const body = typeof rawBody === 'string' ? rawBody : rawBody.toString('utf-8');\n const expected = crypto.createHmac('sha256', secret).update(body).digest('hex');\n\n if (\n signature.length !== expected.length ||\n !crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))\n ) {\n throw new DubsApiError('invalid_signature', 'Webhook signature verification failed', 401);\n }\n\n return JSON.parse(body) as WebhookEvent;\n }\n\n // ── Private ──\n\n private async request<T>(\n method: string,\n path: string,\n body?: string,\n extraHeaders?: Record<string, string>,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'x-api-key': this.apiKey,\n 'Content-Type': 'application/json',\n ...extraHeaders,\n };\n\n const res = await fetch(url, {\n method,\n headers,\n ...(body && { body }),\n });\n\n const json = (await res.json()) as Record<string, unknown>;\n\n if (!res.ok) {\n const msg = typeof json.message === 'string' ? json.message\n : typeof json.error === 'string' ? json.error\n : `Request failed with status ${res.status}: ${JSON.stringify(json)}`;\n throw new DubsApiError(\n (json.code as string) || 'api_error',\n msg,\n res.status,\n );\n }\n\n return json as T;\n }\n}\n","export const DEFAULT_BASE_URL = 'https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1';\n\nexport type DubsNetwork = 'devnet' | 'mainnet-beta';\n\nexport const NETWORK_CONFIG: Record<DubsNetwork, { baseUrl: string }> = {\n 'mainnet-beta': {\n baseUrl: 'https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1',\n },\n devnet: {\n baseUrl: 'https://dubs-server-dev-55d1fba09a97.herokuapp.com/api/developer/v1',\n },\n};\n","export class DubsApiError extends Error {\n public readonly code: string;\n public readonly httpStatus: number;\n\n constructor(code: string, message: string, httpStatus: number) {\n super(message);\n this.name = 'DubsApiError';\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAmB;;;ACAZ,IAAM,mBAAmB;AAIzB,IAAM,iBAA2D;AAAA,EACtE,gBAAgB;AAAA,IACd,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,EACX;AACF;;;ACXO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtB;AAAA,EACA;AAAA,EAEhB,YAAY,MAAc,SAAiB,YAAoB;AAC7D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;;;AFLO,IAAM,OAAN,MAAW;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,QAAoB;AAC9B,SAAK,SAAS,OAAO;AACrB,SAAK,mBAAmB,OAAO;AAE/B,QAAI,OAAO,SAAS;AAClB,WAAK,UAAU,OAAO;AAAA,IACxB,WAAW,OAAO,SAAS;AACzB,WAAK,UAAU,eAAe,OAAO,OAAO,EAAE;AAAA,IAChD,OAAO;AACL,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,YAAY,QAAgB,QAAuD;AACvF,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,KAAK,UAAU;AAAA,MAC1B,QAAQ,OAAO;AAAA,MACf,GAAI,OAAO,YAAY,EAAE,UAAU,OAAO,SAAS;AAAA,IACrD,CAAC;AAED,UAAM,OAAO,cAAAA,QAAO,WAAW,UAAU,KAAK,gBAAgB,EAAE,OAAO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AAAA,EACT;AACF;","names":["crypto"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/constants.ts","../src/errors.ts","../src/resources/base.ts","../src/resources/auth.ts","../src/resources/users.ts","../src/resources/events.ts","../src/resources/games.ts","../src/resources/transactions.ts","../src/resources/ufc.ts"],"sourcesContent":["export { Dubs } from './client';\nexport { DubsApiError } from './errors';\nexport type { DubsConfig, ResolveGameParams, ResolveGameResult, WebhookEvent } from './types';\nexport { DEFAULT_BASE_URL, NETWORK_CONFIG } from './constants';\nexport type { DubsNetwork } from './constants';\n\n// Resource classes\nexport { AuthResource, UsersResource, EventsResource, GamesResource, TransactionsResource, UFCResource } from './resources';\nexport type { RequestFn } from './resources';\n\n// Auth types\nexport type {\n NonceParams,\n NonceResponse,\n AuthenticateParams,\n AuthenticateResponse,\n RegisterParams,\n RegisterResponse,\n MeResponse,\n CheckUsernameResponse,\n} from './types';\n\n// Users types\nexport type { User, UserResponse, UsersListParams, UsersListResponse } from './types';\n\n// Events types\nexport type {\n Event,\n UpcomingEventsParams,\n EventsResponse,\n EsportsParams,\n EsportsMatchResponse,\n} from './types';\n\n// Games types\nexport type {\n Game,\n ValidateParams,\n ValidateResponse,\n GameCreateParams,\n GameCreateResponse,\n GameJoinParams,\n GameJoinResponse,\n GameConfirmParams,\n GameConfirmResponse,\n GameListParams,\n GameListResponse,\n NetworkGamesParams,\n NetworkGamesResponse,\n LiveScoreResponse,\n CustomGameCreateParams,\n CustomGameCreateResponse,\n CustomGameConfirmParams,\n CustomGameConfirmResponse,\n} from './types';\n\n// Transactions types\nexport type { BuildClaimParams, BuildClaimResponse } from './types';\n\n// Config types\nexport type { AppConfigResponse } from './types';\n\n// UFC types\nexport type {\n UFCFighter,\n UFCData,\n UFCFight,\n UFCEvent,\n UFCFightCardResponse,\n} from './types';\n","import crypto from 'crypto';\nimport { DEFAULT_BASE_URL, NETWORK_CONFIG } from './constants';\nimport { DubsApiError } from './errors';\nimport {\n AuthResource,\n EventsResource,\n GamesResource,\n TransactionsResource,\n UFCResource,\n UsersResource,\n} from './resources';\nimport type { AppConfigResponse, DubsConfig, ResolveGameParams, ResolveGameResult, WebhookEvent } from './types';\n\nexport class Dubs {\n private readonly apiKey: string;\n private readonly resolutionSecret?: string;\n private readonly baseUrl: string;\n\n readonly auth: AuthResource;\n readonly users: UsersResource;\n readonly events: EventsResource;\n readonly games: GamesResource;\n readonly transactions: TransactionsResource;\n readonly ufc: UFCResource;\n\n constructor(config: DubsConfig) {\n this.apiKey = config.apiKey;\n this.resolutionSecret = config.resolutionSecret;\n\n if (config.baseUrl) {\n this.baseUrl = config.baseUrl;\n } else if (config.network) {\n this.baseUrl = NETWORK_CONFIG[config.network].baseUrl;\n } else {\n this.baseUrl = DEFAULT_BASE_URL;\n }\n\n const boundRequest = this.request.bind(this);\n this.auth = new AuthResource(boundRequest);\n this.users = new UsersResource(boundRequest);\n this.events = new EventsResource(boundRequest);\n this.games = new GamesResource(boundRequest);\n this.transactions = new TransactionsResource(boundRequest);\n this.ufc = new UFCResource(boundRequest);\n }\n\n /**\n * Fetch the platform configuration.\n */\n async config(): Promise<AppConfigResponse> {\n return this.request<AppConfigResponse>('GET', '/config');\n }\n\n /**\n * Resolve a custom game (game_mode=6).\n *\n * Automatically computes the HMAC-SHA256 signature using your resolution secret.\n */\n async resolveGame(gameId: string, params: ResolveGameParams): Promise<ResolveGameResult> {\n if (!this.resolutionSecret) {\n throw new DubsApiError(\n 'missing_resolution_secret',\n 'resolutionSecret is required for resolveGame(). Pass it in the Dubs constructor.',\n 0,\n );\n }\n\n const body = JSON.stringify({\n winner: params.winner,\n ...(params.metadata && { metadata: params.metadata }),\n });\n\n const hmac = crypto.createHmac('sha256', this.resolutionSecret).update(body).digest('hex');\n\n return this.request<ResolveGameResult>('POST', `/games/${gameId}/resolve`, body, {\n 'x-dubs-signature': `sha256=${hmac}`,\n });\n }\n\n /**\n * Verify an incoming Dubs webhook request.\n *\n * @param rawBody - The raw request body (string or Buffer)\n * @param signature - The X-Dubs-Signature header value\n * @param secret - Your webhook secret (from the developer portal)\n * @returns The parsed webhook event\n * @throws DubsApiError if the signature is invalid\n */\n static verifyWebhook(rawBody: string | Buffer, signature: string, secret: string): WebhookEvent {\n const body = typeof rawBody === 'string' ? rawBody : rawBody.toString('utf-8');\n const expected = crypto.createHmac('sha256', secret).update(body).digest('hex');\n\n if (\n signature.length !== expected.length ||\n !crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))\n ) {\n throw new DubsApiError('invalid_signature', 'Webhook signature verification failed', 401);\n }\n\n return JSON.parse(body) as WebhookEvent;\n }\n\n // ── Private ──\n\n private async request<T>(\n method: string,\n path: string,\n body?: string,\n extraHeaders?: Record<string, string>,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'x-api-key': this.apiKey,\n 'Content-Type': 'application/json',\n ...extraHeaders,\n };\n\n const res = await fetch(url, {\n method,\n headers,\n ...(body && { body }),\n });\n\n const json = (await res.json()) as Record<string, unknown>;\n\n if (!res.ok) {\n const msg = typeof json.message === 'string' ? json.message\n : typeof json.error === 'string' ? json.error\n : `Request failed with status ${res.status}: ${JSON.stringify(json)}`;\n throw new DubsApiError(\n (json.code as string) || 'api_error',\n msg,\n res.status,\n );\n }\n\n return json as T;\n }\n}\n","export const DEFAULT_BASE_URL = 'https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1';\n\nexport type DubsNetwork = 'devnet' | 'mainnet-beta';\n\nexport const NETWORK_CONFIG: Record<DubsNetwork, { baseUrl: string }> = {\n 'mainnet-beta': {\n baseUrl: 'https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1',\n },\n devnet: {\n baseUrl: 'https://dubs-server-dev-55d1fba09a97.herokuapp.com/api/developer/v1',\n },\n};\n","export class DubsApiError extends Error {\n public readonly code: string;\n public readonly httpStatus: number;\n\n constructor(code: string, message: string, httpStatus: number) {\n super(message);\n this.name = 'DubsApiError';\n this.code = code;\n this.httpStatus = httpStatus;\n }\n}\n","export type RequestFn = <T>(\n method: string,\n path: string,\n body?: string,\n extraHeaders?: Record<string, string>,\n) => Promise<T>;\n\nexport class BaseResource {\n protected request: RequestFn;\n\n constructor(request: RequestFn) {\n this.request = request;\n }\n}\n","import { BaseResource } from './base';\nimport type {\n AuthenticateParams,\n AuthenticateResponse,\n CheckUsernameResponse,\n MeResponse,\n NonceResponse,\n RegisterParams,\n RegisterResponse,\n} from '../types';\n\nexport class AuthResource extends BaseResource {\n async getNonce(walletAddress: string): Promise<NonceResponse> {\n return this.request<NonceResponse>('GET', `/auth/nonce?walletAddress=${encodeURIComponent(walletAddress)}`);\n }\n\n async authenticate(params: AuthenticateParams): Promise<AuthenticateResponse> {\n return this.request<AuthenticateResponse>('POST', '/auth/authenticate', JSON.stringify(params));\n }\n\n async register(params: RegisterParams): Promise<RegisterResponse> {\n return this.request<RegisterResponse>('POST', '/auth/register', JSON.stringify(params));\n }\n\n async me(userToken: string): Promise<MeResponse> {\n return this.request<MeResponse>('GET', '/auth/me', undefined, {\n Authorization: `Bearer ${userToken}`,\n });\n }\n\n async logout(userToken: string): Promise<void> {\n await this.request<Record<string, unknown>>('POST', '/auth/logout', undefined, {\n Authorization: `Bearer ${userToken}`,\n });\n }\n\n async checkUsername(username: string): Promise<CheckUsernameResponse> {\n return this.request<CheckUsernameResponse>('GET', `/auth/check-username?username=${encodeURIComponent(username)}`);\n }\n}\n","import { BaseResource } from './base';\nimport type { UserResponse, UsersListParams, UsersListResponse } from '../types';\n\nexport class UsersResource extends BaseResource {\n async get(walletAddress: string): Promise<UserResponse> {\n return this.request<UserResponse>('GET', `/users/${encodeURIComponent(walletAddress)}`);\n }\n\n async list(params?: UsersListParams): Promise<UsersListResponse> {\n const query = new URLSearchParams();\n if (params?.limit != null) query.set('limit', String(params.limit));\n if (params?.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n return this.request<UsersListResponse>('GET', `/users${qs ? `?${qs}` : ''}`);\n }\n}\n","import { BaseResource } from './base';\nimport type {\n EsportsMatchResponse,\n EsportsParams,\n EventsResponse,\n UpcomingEventsParams,\n} from '../types';\n\nexport class EventsResource extends BaseResource {\n async upcoming(params?: UpcomingEventsParams): Promise<EventsResponse> {\n const query = new URLSearchParams();\n if (params?.type) query.set('type', params.type);\n if (params?.page != null) query.set('page', String(params.page));\n if (params?.limit != null) query.set('limit', String(params.limit));\n const qs = query.toString();\n return this.request<EventsResponse>('GET', `/events/upcoming${qs ? `?${qs}` : ''}`);\n }\n\n async sports(league: string): Promise<EventsResponse> {\n return this.request<EventsResponse>('GET', `/events/sports/${encodeURIComponent(league)}`);\n }\n\n async esports(params?: EsportsParams): Promise<EventsResponse> {\n const query = new URLSearchParams();\n if (params?.videogame) query.set('videogame', params.videogame);\n if (params?.page != null) query.set('page', String(params.page));\n if (params?.limit != null) query.set('limit', String(params.limit));\n const qs = query.toString();\n return this.request<EventsResponse>('GET', `/events/esports${qs ? `?${qs}` : ''}`);\n }\n\n async esportsMatch(matchId: string): Promise<EsportsMatchResponse> {\n return this.request<EsportsMatchResponse>('GET', `/events/esports/match/${encodeURIComponent(matchId)}`);\n }\n}\n","import { BaseResource } from './base';\nimport type {\n CustomGameConfirmParams,\n CustomGameConfirmResponse,\n CustomGameCreateParams,\n CustomGameCreateResponse,\n Game,\n GameConfirmParams,\n GameConfirmResponse,\n GameCreateParams,\n GameCreateResponse,\n GameJoinParams,\n GameJoinResponse,\n GameListParams,\n GameListResponse,\n LiveScoreResponse,\n NetworkGamesParams,\n NetworkGamesResponse,\n ValidateResponse,\n} from '../types';\n\nexport class GamesResource extends BaseResource {\n async validate(eventId: string): Promise<ValidateResponse> {\n return this.request<ValidateResponse>('GET', `/games/validate?eventId=${encodeURIComponent(eventId)}`);\n }\n\n async create(params: GameCreateParams): Promise<GameCreateResponse> {\n return this.request<GameCreateResponse>('POST', '/games/create', JSON.stringify(params));\n }\n\n async join(params: GameJoinParams): Promise<GameJoinResponse> {\n return this.request<GameJoinResponse>('POST', '/games/join', JSON.stringify(params));\n }\n\n async confirm(params: GameConfirmParams): Promise<GameConfirmResponse> {\n return this.request<GameConfirmResponse>('POST', '/games/confirm', JSON.stringify(params));\n }\n\n async get(gameId: string): Promise<{ game: Game }> {\n return this.request<{ game: Game }>('GET', `/games/${encodeURIComponent(gameId)}`);\n }\n\n async list(params?: GameListParams): Promise<GameListResponse> {\n const query = new URLSearchParams();\n if (params?.status) query.set('status', params.status);\n if (params?.limit != null) query.set('limit', String(params.limit));\n if (params?.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n return this.request<GameListResponse>('GET', `/games${qs ? `?${qs}` : ''}`);\n }\n\n async network(params?: NetworkGamesParams): Promise<NetworkGamesResponse> {\n const query = new URLSearchParams();\n if (params?.limit != null) query.set('limit', String(params.limit));\n if (params?.offset != null) query.set('offset', String(params.offset));\n const qs = query.toString();\n return this.request<NetworkGamesResponse>('GET', `/games/network${qs ? `?${qs}` : ''}`);\n }\n\n async liveScore(gameId: string): Promise<LiveScoreResponse> {\n return this.request<LiveScoreResponse>('GET', `/games/${encodeURIComponent(gameId)}/live-score`);\n }\n\n async customCreate(params: CustomGameCreateParams): Promise<CustomGameCreateResponse> {\n return this.request<CustomGameCreateResponse>('POST', '/games/custom/create', JSON.stringify(params));\n }\n\n async customConfirm(params: CustomGameConfirmParams): Promise<CustomGameConfirmResponse> {\n return this.request<CustomGameConfirmResponse>('POST', '/games/custom/confirm', JSON.stringify(params));\n }\n}\n","import { BaseResource } from './base';\nimport type { BuildClaimParams, BuildClaimResponse } from '../types';\n\nexport class TransactionsResource extends BaseResource {\n async buildClaim(params: BuildClaimParams): Promise<BuildClaimResponse> {\n return this.request<BuildClaimResponse>('POST', '/transactions/build-claim', JSON.stringify(params));\n }\n}\n","import { BaseResource } from './base';\nimport type { UFCFightCardResponse } from '../types';\n\nexport class UFCResource extends BaseResource {\n async fightCard(): Promise<UFCFightCardResponse> {\n return this.request<UFCFightCardResponse>('GET', '/ufc/fightcard');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