Project for Riot Games API (League Of Legends game)
- generic class and method were used
- Ninject InSingletonScope was used
- Repository Pattern included (half)
- there is RiotCaller.Tests also there is ExampleProject in solution
ApiService.ApiKey="RiotGames API Key" //for service
or
ApiService svc = new ApiService("[Riot API Key here]"); //classic defining
Ranked data = svc.Api.GetStatsRanked("[summonerId]", "[region]");
..
kernel.Bind<ApiService>().ToSelf().InSingletonScope().WithConstructorArgument("[Riot API Key here]");
..
var summoner1 = LolApi.Api.GetSummoner("[summonerName]", [region]);
//you can use this method in your solution wherever you want
var summoner2 = new RiotApiCaller<Summoner>(suffix.summonerByname);
summoner2.AddParam(param.summonerNames, new List<string>() { "[summonerName]" });
summoner2.AddParam(param.region, "[region]");
summoner2.CreateRequest();
var ranked1 = LolApi.Api.GetStatsRanked("[summonerId]", "[region]");
//you can use this method in your solution wherever you want
var ranked2 = new RiotApiCaller<Ranked>(suffix.statsRanked);
ranked2.AddParam(param.summonerId, "[summonerId]");
ranked2.AddParam(param.region, "[region]");
ranked2.AddParam(param.season, "[season]");
ranked2.CreateRequest();
var ranked3 = summoner1.GetStatsRanked();
Summoner summoner1 = LolApi.Api.GetSummoner("[summonerName]", "[region]");
var ranked4 = SummonerExtensions.GetStatsRanked(summoner1);
OR
var ranked4 = SummonerExtensions.GetStatsRanked(new Summoner() { Id = "[summonerId]" });
this struct helps for creating api url if you add new api method you must add new suffix
- ApiType Attribute
- (defining this apiurl is static OR is non-static, routing API SERVER URL)
- apiVer Attribute
- (sometimes we need two keys, EXAMPLE: ( 'by-summoner/{summonerIds}' AND 'by-summoner/{summonerIds}/entry' )
AND both of them use GetSummoner() ,so apiVer reference to BASE API URL like 'Summoner'
- Value Attribute
- this attribute separates and contains (suffix url) for each API
this struct helps replace to suffix url parameters if you add new suffix, you must add its parameter to param enum (if it has not already) Example: add new suffix name TEST with value, non-static, base api is league
[ApiType(apiType.nonStatic)]
[apiVer(apiVer.league)]
[Value("by-summoner/{LeagueName}/entry?api_key={api_key}")]
TEST
its parameter {LeagueName} if it has not in param which helps replace to suffix, you must add new value to param, like this 'LeagueName'
every ApiEndPoints can use memorycaching. (default value:FALSE)
ApiService svc = new ApiService();
Summoner data = svc.Api.GetSummoner("[summonerId]", "[region]", true); // TRUE: method is caching
Ranked data = svc.Api.GetStatsRanked("[summonerId]", "[region]", null, true); //caching
Champions data = svc.staticApi.GetChampions("[region]", "[language]", champData.all, true);//caching
-.NET MVC and dependency injection (not finished also half)
if you have good idea, you can create pull request
This project is licensed under the MIT license.
RiotCaller is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games , Inc. League of Legends © Riot Games, Inc.