BlossomiShymae / RiotBlossom

An asynchronous, extensible, and magical Riot Games API wrapper library for C#. ☆*:.。.o(≧▽≦)o.。.:*☆
https://blossomishymae.github.io/RiotBlossom/
MIT License
12 stars 2 forks source link

Add low-level API interface for making requests #7

Closed BlossomiShymae closed 1 year ago

BlossomiShymae commented 1 year ago

I think this feature would be awesome to have for making manual requests with the library that processes through the middleware plugins. So anyone can make requests to endpoints not yet supported (or will not support). So something like this, maybe:

// We are passing SummonerDto for strong-typing and JSON deserializing
SummonerDto summoner = 
    await client.Riot.GetAsync<SummonerDto>(Platform.NorthAmerica, "/lol/summoner/v4/summoners/by-name/uwuie time");

Or this:

SummonerDto summoner = 
    await client.Riot.GetAsync<SummonerDto>("na1", "/lol/summoner/v4/summoners/by-name/uwuie time");

Fluent builder:

SummonerDto summoner = await client.Riot.Request
    .WithRoute(Platform.NorthAmerica)
    .WithPath("/lol/summoner/v4/summoners/by-name/uwuie time")
    .GetAsync<SummonerDto>();

For JSON scalars:

int totalMasteryScore = await client.Riot.Request
    .WithRoute(Platform.NorthAmerica)
    .WithPath("/lol/champion-mastery/v4/scores/by-summoner/Ao5ffQ2dOV-99YKs_iB0g2EGzGD159jXIk2Z5MjvMafLwbQ")
    .GetAsync<int>();

ame_bee

BlossomiShymae commented 1 year ago

I'm going to go ahead with the second example. :3