-
Notifications
You must be signed in to change notification settings - Fork 6
/
legacy.ts
93 lines (81 loc) · 2.64 KB
/
legacy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { COD_API_ENDPOINT, getDataFromAPI } from './utils';
export type GameMode =
'1v1' | // 1v1 Arena
'ball' | // Gridiron
'career' | // Career (all modes)
'conf' | // Kill Confirmed
'ctf' | // Capture the Flag
'dm' | // Free-For-All
'dom' | // Domination
'hp' | // Hardpoint
'sd' | // Search & Destroy
'raid' | // War
'war'; // Team Deathmatch
export type GameType =
'arena' | // Ranked Play
'core' | // Core
'hc'; // Hardcore
export type LeaderboardDuration =
'alltime' |
'monthly' |
'weekly';
export type Platform =
'psn' | // Playstation Network
'steam' | // Steam
'xbl'; // Xbox Live
export type Title =
'bo3' | // Black Ops 3
'iw' | // Infinite Warfare
'wwii'; // World War II
export interface BaseOptions {
platform: Platform;
title: Title;
username: string;
}
export interface RecentOptions extends BaseOptions {
days: number;
}
export interface LeaderboardOptions extends BaseOptions {
mode: GameMode;
time: LeaderboardDuration;
type: GameType
}
// Legacy API Methods
export function getLeaderboards({ title, platform, time, type, mode, username }: LeaderboardOptions) {
const leaderboardEndpoint = COD_API_ENDPOINT + '/leaderboards/v2';
const uri = leaderboardEndpoint +
`/title/${title}` +
`/platform/${platform}` +
`/time/${time}` +
`/type/${type}` +
`/mode/${mode}` +
`/gamer/${username}`;
return getDataFromAPI(uri);
};
export function getProfile({ title, platform, username }: BaseOptions) {
const profileEndpoint = COD_API_ENDPOINT + '/crm/cod/v2';
const uri = profileEndpoint +
`/title/${title}` +
`/platform/${platform}` +
`/gamer/${username}` +
`/profile`;
return getDataFromAPI(uri);
};
export function getRecentMatches({ title, platform, username, days }: RecentOptions) {
const recentMatchesEndpoint = COD_API_ENDPOINT + '/crm/cod/v2';
const uri = recentMatchesEndpoint +
`/title/${title}` +
`/platform/${platform}` +
`/gamer/${username}` +
`/matches/days/${days}`;
return getDataFromAPI(uri);
};
export function getRecentSummary({ title, platform, username, days }: RecentOptions) {
const recentSummaryEndpoint = COD_API_ENDPOINT + '/crm/cod/v2';
const uri = recentSummaryEndpoint +
`/title/${title}` +
`/platform/${platform}` +
`/gamer/${username}` +
`/matches/days/${days}`;
return getDataFromAPI(uri);
};