11using SteamWebAPI2 . Models . DOTA2 ;
2+ using System ;
23using System . Collections . Generic ;
34using System . Collections . ObjectModel ;
45using System . Threading . Tasks ;
@@ -22,15 +23,8 @@ public async Task<IReadOnlyCollection<LiveLeagueGame>> GetLiveLeagueGames(int? l
2223 {
2324 List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
2425
25- if ( leagueId . HasValue )
26- {
27- parameters . Add ( new SteamWebRequestParameter ( "league_id" , leagueId . Value . ToString ( ) ) ) ;
28- }
29-
30- if ( matchId . HasValue )
31- {
32- parameters . Add ( new SteamWebRequestParameter ( "match_id" , matchId . Value . ToString ( ) ) ) ;
33- }
26+ AddToParametersIfHasValue ( "league_id" , leagueId , parameters ) ;
27+ AddToParametersIfHasValue ( "match_id" , matchId , parameters ) ;
3428
3529 var liveLeagueGames = await CallMethodAsync < LiveLeagueGameResultContainer > ( "GetLiveLeagueGames" , 1 , parameters ) ;
3630 return new ReadOnlyCollection < LiveLeagueGame > ( liveLeagueGames . Result . Games ) ;
@@ -39,15 +33,42 @@ public async Task<IReadOnlyCollection<LiveLeagueGame>> GetLiveLeagueGames(int? l
3933 public async Task < MatchDetailResult > GetMatchDetails ( int matchId )
4034 {
4135 List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
42- parameters . Add ( new SteamWebRequestParameter ( "match_id" , matchId . ToString ( ) ) ) ;
36+
37+ AddToParametersIfHasValue ( "match_id" , matchId , parameters ) ;
38+
4339 var matchDetail = await CallMethodAsync < MatchDetailResultContainer > ( "GetMatchDetails" , 1 , parameters ) ;
4440 return matchDetail . Result ;
4541 }
4642
47- public async Task < MatchHistoryResult > GetMatchHistory ( )
43+ public async Task < MatchHistoryResult > GetMatchHistory ( int ? heroId = null , int ? gameMode = null , int ? skill = null ,
44+ string minPlayers = "" , string accountId = "" , string leagueId = "" , long ? startAtMatchId = null ,
45+ string matchesRequested = "" , string tournamentGamesOnly = "" )
4846 {
47+ List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
48+
49+ AddToParametersIfHasValue ( "hero_id" , heroId , parameters ) ;
50+ AddToParametersIfHasValue ( "game_mode" , gameMode , parameters ) ;
51+ AddToParametersIfHasValue ( "skill" , skill , parameters ) ;
52+ AddToParametersIfHasValue ( "min_players" , minPlayers , parameters ) ;
53+ AddToParametersIfHasValue ( "account_id" , accountId , parameters ) ;
54+ AddToParametersIfHasValue ( "league_id" , leagueId , parameters ) ;
55+ AddToParametersIfHasValue ( "start_at_match_id" , startAtMatchId , parameters ) ;
56+ AddToParametersIfHasValue ( "matches_requested" , matchesRequested , parameters ) ;
57+ AddToParametersIfHasValue ( "tournament_games_only" , tournamentGamesOnly , parameters ) ;
58+
4959 var matchHistory = await CallMethodAsync < MatchHistoryResultContainer > ( "GetMatchHistory" , 1 ) ;
5060 return matchHistory . Result ;
5161 }
62+
63+ public async Task < MatchHistoryBySequenceNumberResult > GetMatchHistoryBySequenceNumber ( long ? startAtMatchSequenceNumber = null , int ? matchesRequested = null )
64+ {
65+ List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
66+
67+ AddToParametersIfHasValue ( "start_at_match_seq_num" , startAtMatchSequenceNumber , parameters ) ;
68+ AddToParametersIfHasValue ( "matches_requested" , matchesRequested , parameters ) ;
69+
70+ var matchHistory = await CallMethodAsync < MatchHistoryBySequenceNumberResultContainer > ( "GetMatchHistoryBySequenceNum" , 1 ) ;
71+ return matchHistory . Result ;
72+ }
5273 }
5374}
0 commit comments