stefangeyer / challonge-java

Java bindings for the Challonge API
MIT License
10 stars 7 forks source link

Using the tournament handler does not seem to work in any way #10

Closed JohnnyJayJay closed 6 years ago

JohnnyJayJay commented 6 years ago

Hello,

just leaving this here in case anybody still cares about this library. Unfortunately, even the most important requests do not function correctly for me. I had just been figuring out on my own how to work with this (since this wrapper does not provide proper documentation), when I discovered that there is no way of getting tournaments. Sounds stupid? Frankly, that's what I thought as well. So I tried the following:

String name = UUID.randomUUID().toString().replaceAll("[^A-Za-z0-9_]", ""); // generating a random, but usable String             
TournamentQuery query = TournamentQuery.builder().tournamentType(TournamentType.SINGLE_ELIMINATION).url(name).name(name).build(); // creating works fine, it also shows up in my account
Tournament tournament = api.tournaments().createTournament(query).sync(); // api is my CallongeApi object
Tournament theSameTournament = api.tournaments().getTournament(tournament.name(), true, true).sync(); // I've also tried to use different boolean parameters here
System.out.println(theSameTournament); // we should get here, right?

But as I run it, it gives me this Exception:

Exception in thread "main" com.exsoloscript.challonge.model.exception.ChallongeException: [Requested tournament not found]

Same thing for async calls. Same thing for the usage of subdomains. Because I haven't seen this issue being mentioned yet, I thought I'd share this. Maybe there is something you can do about it. Or I am doing something completely wrong, which I doubt in this case, but if so, please tell me.

Best regards

stefangeyer commented 6 years ago

I cannot reproduce your problem. When I run the code you provided, the tournament is created and printed successfully. Which version are you using? Please provide more information.

I agree that the lack of documentation is a problem. I will, however, not add any in the near future as this project is about to become deprecated. I've been working on a new version during the last few months which removes all the unnecessary dependencies and is a lot more modular in general. You can expect the release within the next month and there will also be a few wiki pages for easier understanding.

On a side note: If I were in your position and required help, I'd probably choose a different wording as the text you wrote makes you sound pretty arrogant.

JohnnyJayJay commented 6 years ago

First of all, thank you for the quick response, didn't expect that. Also, I'd like to apologize if I sounded arrogant in any way, that was not my intention. I tried it again now, and for some reason it works. Seems like this was actually my own stupidity. Is it possible, that using different Strings for name and url causes this? Because that is what I did, apparently. I didn't think of that as being relevant, but now it appears to be the opposite. So, if you actually do specify different urls and names, the tournaments may not be retrieved later on. Surprising, for it shows up in my account and doesn't give an exception while creating. But I think this might be it.

stefangeyer commented 6 years ago

Different name and url should not be a problem at all. In the code above, if you change the name in the query make sure to read the tournament using the url and not the name:

TournamentQuery query = TournamentQuery.builder().tournamentType(TournamentType.SINGLE_ELIMINATION).url(name).name("Some name").build();
// query using the url as 'name' is now "Some name" which obviously cannot be resolved
Tournament theSameTournament = api.tournaments().getTournament(tournament.url(), true, true).sync();
stefangeyer commented 6 years ago

Please let me know when your problem is resolved so I can close this issue

JohnnyJayJay commented 6 years ago

Okay, I think it works now. The thing that confused me here is probably the fact that the String-parameter in TournamentHandler#getTournament(String, boolean, boolean) is called name and not url. So I assumed that it expects the name there. Now that I know better, I hope I will not experience any further issues. You may close this.

stefangeyer commented 6 years ago

It's true that the name is a bit misleading. I would, however, suggest to check the API docs as these methods simply represent the endpoints. The documentation is also attached to the Retrofit interfaces for easier access.