-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: live match win probability (stratz) (#375)
- Loading branch information
Showing
13 changed files
with
596 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import axios from 'axios' | ||
|
||
const STRATZ_GQL = 'https://api.stratz.com/graphql' | ||
|
||
const LiveMatchDetailsQuery = ` | ||
query GetLiveMatch($matchId: Long!) { | ||
live { | ||
match(id: $matchId) { | ||
liveWinRateValues { | ||
time | ||
winRate | ||
} | ||
completed | ||
isUpdating | ||
} | ||
} | ||
} | ||
` | ||
|
||
type StratzLiveMatchResponse = { | ||
data: { | ||
live: { | ||
match?: { | ||
liveWinRateValues: Array<{ | ||
time: number | ||
winRate: number | ||
}> | ||
completed: boolean | ||
isUpdating: boolean | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const GetLiveMatch = async ( | ||
matchId: number, | ||
): Promise<StratzLiveMatchResponse | undefined> => { | ||
if (!process.env.STRATZ_TOKEN) { | ||
return | ||
} | ||
|
||
try { | ||
const response = await axios.post<StratzLiveMatchResponse>( | ||
STRATZ_GQL, | ||
{ | ||
query: LiveMatchDetailsQuery, | ||
variables: { matchId }, // Pass the matchId as a variable | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${process.env.STRATZ_TOKEN}`, | ||
}, | ||
}, | ||
) | ||
|
||
return response.data | ||
} catch (error) { | ||
// console.error(error?.response?.data?.errors ?? error?.data ?? error) | ||
return undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.