aj-r / RiotNet

A .NET/C# client for the Riot Games API
MIT License
22 stars 10 forks source link

Tournament for Global Endpoint only? #9

Closed hmcspbr closed 7 years ago

hmcspbr commented 7 years ago

Hello everyone! I observed that only Global Endpoint is used at the Tournament methods, I mean, why not use the Region Endpoint chose on RiotClient constructor? Can I change this in some configuration? Thanks.

aj-r commented 7 years ago

Hi! My understanding is that the global endpoint should be used for tournament calls, and the region name should be passed in the body on the request.

Unfortunately, I don't have a valid Tournament API key right now, so I can't test or check the documentation anymore :(.

aj-r commented 7 years ago

I'd be concerned that having configuration for something like this would let someone accidentally break the API calls. This library should be set up so it just does the API calls correctly. I did have a tournament API key for a short time, and my unit tests were passing using the global endpoint.

Is the global endpoint causing problems for you?

hmcspbr commented 7 years ago

Yep, I've access for br.api.pvp.net and when I called the Tournament API at global endpoint an Forbidden (403) exception was throw. I'll test using an HttpClient to be sure if at the region endpoint will work fine.

aj-r commented 7 years ago

Ok, let me know if the region endpoint works for you.

Do you have a valid Tounament API key? The normal API key doesn't give you access to the tournament stuff - you have to request a special key.

hmcspbr commented 7 years ago

I have a interim tournament key.

hmcspbr commented 7 years ago

Hi aj, you are right! For the Tournament API we need use the Global Endpoint. The only difference that I found is that the tournament URL suffer a little change: "https://global.api.pvp.net/tournament/stub/v1/provider", there is a "stub" and not a "public". I had a successful test only using the Riot Developer page. Maybe because my key is interim and the responses are mocks.

aj-r commented 7 years ago

Interesting - I don't see that documented anywhere. But I can add it in.

It probably makes the most sense to add a setting on the RiotClient object that you set once when you create the client.

i.e.

var client = new RiotClient(Region.BR) { UseTournamentStub = true };

When you set UseTournamentStub to true, it will use /tounament/stub. Otherwise it will use /tournamnet/public.

I'm not sure if you're using the v2 or v3 release, but I'll add it to both.

aj-r commented 7 years ago

On second thought, I believe it makes more sense to add this property to the settings object. So you would create it like this:

var settings = new RiotClientSettings
{
    ApiKey = "your api key",
    UseTournamentStub = true,
};
var client = new RiotClient(Region.BR, settings);
hmcspbr commented 7 years ago

Great, if you can do this, I'll be grateful. I'm using the v3 release. I can test and return a feedback to you. Thanks a lot.

aj-r commented 7 years ago

Ok, I've added v3.1.0-Beta to NuGet. Try it out and see if it works. You'll have to check the "Include pre-realease" box in the NuGet package manager in order to see it.

If it works, I'll publish it as v3.1.0.

hmcspbr commented 7 years ago

Throws this message: "A REST request failed. Status code: 415".

{StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { X-Rate-Limit-Count: 1:10,1:600 Connection: keep-alive Content-Length: 79 Content-Type: application/json; charset=utf-8 }}

aj-r commented 7 years ago

Weird. application/json should be a supported content type. I'll look into it on Tuesday.

If you need something working sooner, you can try writing your own class that extends RiotClient and adds methods for the endpoints you need.

hmcspbr commented 7 years ago

OK, don't worry! Thanks!

aj-r commented 7 years ago

Ok, I fixed a couple of issues with the POST requests. Try v3.1.0-Beta2.

If that still doesn't work, you may need to fork the code, change it yourself, and submit a pull request, since I can't test it :(. I've asked Riot for an interim API key, but it might be a while before they give it to me. If you do that, use the tournament-stub branch.

aj-r commented 7 years ago

Riot gave me a tournament key so I was able to test. It works now - use the 3.1.0 release.