99
1010namespace Snittlistan . Web . Infrastructure . Bits ;
1111
12- public class BitsClient : IBitsClient
12+ public class BitsClient ( HttpClient client , MemoryCache memoryCache ) : IBitsClient
1313{
14- private readonly string apiKey ;
15- private readonly HttpClient client ;
16- private readonly MemoryCache memoryCache ;
17-
18- public BitsClient ( string apiKey , HttpClient client , MemoryCache memoryCache )
19- {
20- this . apiKey = apiKey ;
21- this . client = client ;
22- this . memoryCache = memoryCache ;
23- }
24-
2514 public ILogger Logger { get ; set ; } = NullLogger . Instance ;
2615
2716 public async Task < HeadInfo > GetHeadInfo ( int matchId )
2817 {
29- HeadInfo result = await Get < HeadInfo > ( $ "https:// api.swebowl.se/api/ v1/matchResult/GetHeadInfo?APIKey= { apiKey } & id={ matchId } ") ;
18+ HeadInfo result = await Get < HeadInfo > ( $ "/ api/ v1/matchResult/GetHeadInfo?id={ matchId } ") ;
3019 return result ;
3120 }
3221
3322 public async Task < HeadResultInfo > GetHeadResultInfo ( int matchId )
3423 {
35- HeadResultInfo result = await Get < HeadResultInfo > ( $ "https:// api.swebowl.se/api/ v1/matchResult/GetHeadResultInfo?APIKey= { apiKey } & id={ matchId } ") ;
24+ HeadResultInfo result = await Get < HeadResultInfo > ( $ "/ api/ v1/matchResult/GetHeadResultInfo?id={ matchId } ") ;
3625 return result ;
3726 }
3827
3928 public async Task < MatchResults > GetMatchResults ( int matchId )
4029 {
41- MatchResults result = await Get < MatchResults > ( $ "https:// api.swebowl.se/api/ v1/matchResult/GetMatchResults?APIKey= { apiKey } & matchId={ matchId } &matchSchemeId=8M8BA") ;
30+ MatchResults result = await Get < MatchResults > ( $ "/ api/ v1/matchResult/GetMatchResults?matchId={ matchId } &matchSchemeId=8M8BA") ;
4231 return result ;
4332 }
4433
4534 public async Task < MatchScores > GetMatchScores ( int matchId )
4635 {
47- MatchScores result = await Get < MatchScores > ( $ "https:// api.swebowl.se/api/ v1/matchResult/GetMatchScores?APIKey= { apiKey } & matchId={ matchId } &matchSchemeId=8M8BA") ;
36+ MatchScores result = await Get < MatchScores > ( $ "/ api/ v1/matchResult/GetMatchScores?matchId={ matchId } &matchSchemeId=8M8BA") ;
4837 return result ;
4938 }
5039
5140 public async Task < TeamResult [ ] > GetTeam ( int clubId , int seasonId )
5241 {
53- TeamResult [ ] result = await Get < TeamResult [ ] > ( $ "https:// api.swebowl.se/api/ v1/Team?APIKey= { apiKey } & clubId={ clubId } &seasonId={ seasonId } ") ;
42+ TeamResult [ ] result = await Get < TeamResult [ ] > ( $ "/ api/ v1/Team?clubId={ clubId } &seasonId={ seasonId } ") ;
5443 return result ;
5544 }
5645
5746 public async Task < DivisionResult [ ] > GetDivisions ( int teamId , int seasonId )
5847 {
59- DivisionResult [ ] result = await Get < DivisionResult [ ] > ( $ "https:// api.swebowl.se/api/ v1/Division?APIKey= { apiKey } & teamId={ teamId } &seasonId={ seasonId } ") ;
48+ DivisionResult [ ] result = await Get < DivisionResult [ ] > ( $ "/ api/ v1/Division?teamId={ teamId } &seasonId={ seasonId } ") ;
6049 return result ;
6150 }
6251
6352 public async Task < MatchRound [ ] > GetMatchRounds ( int teamId , int divisionId , int seasonId )
6453 {
65- MatchRound [ ] result = await Get < MatchRound [ ] > ( $ "https:// api.swebowl.se/api/ v1/Match/?APIKey= { apiKey } & teamId={ teamId } &divisionId={ divisionId } &seasonId={ seasonId } ") ;
54+ MatchRound [ ] result = await Get < MatchRound [ ] > ( $ "/ api/ v1/Match/?teamId={ teamId } &divisionId={ divisionId } &seasonId={ seasonId } ") ;
6655 return result ;
6756 }
6857
@@ -79,7 +68,7 @@ public async Task<PlayerResult> GetPlayers(int clubId)
7968 pageSize = "250" ,
8069 sort = new object [ 0 ]
8170 } ,
82- $ "https:// api.swebowl.se/api/ v1/player/GetAll?APIKey= { apiKey } ") ;
71+ $ "/ api/ v1/player/GetAll") ;
8372 return result ;
8473 }
8574
@@ -163,7 +152,6 @@ private async Task<string> Request(HttpMethod method, string url, Action<HttpReq
163152 "Requesting {url}" ,
164153 url ) ;
165154 HttpRequestMessage request = new ( method , url ) ;
166- request . Headers . Referrer = new Uri ( "https://bits.swebowl.se" ) ;
167155 action . Invoke ( request ) ;
168156 HttpResponseMessage result = await client . SendAsync ( request ) ;
169157 string content = await result . EnsureSuccessStatusCode ( ) . Content . ReadAsStringAsync ( ) ;
0 commit comments