stefangeyer / challonge-java

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

Creating tournament under domain #7

Closed piozygmunt closed 6 years ago

piozygmunt commented 6 years ago

Hey. I've got problem with creating new tournament under specific domain. Here is my code:

    Tournament tournament = null;

        TournamentQuery.TournamentQueryBuilder querytrBuilder = TournamentQuery.builder().name(name).tournamentType(TournamentType.DOUBLE_ELIMINATION).grandFinalsModifier(GrandFinalsModifier.SINGLE_MATCH)
                .showRounds(true).url(url).subdomain(subdomain);
        TournamentQuery query = querytrBuilder.build();
        System.out.println(query.subdomain());

        try {
            tournament = api.tournaments().createTournament(query).sync();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ChallongeException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(tournament.subdomain());

first output prints subdomain correctly, second returns null. Tournament is created under challonge.com/url instead of subdomain.challonge.com/url. No exceptions are being thrown. I have rights to create tournaments under that domain. Any ideas whats wrong ?

stefangeyer commented 6 years ago

I will look into this

piozygmunt commented 6 years ago

Thanks for answer. Seems like i found the problem. You send creating tournament request in this format : {"name":"test_cup","tournament_type":"double elimination","url":"testcup-123","subdomain":"subdomainasd", ...}

while it should be like this :

{"tournament":{"name":"test_cup","tournament_type":"double elimination","url":"testcup-123","subdomain":"subdomainasd",..}}

so it needs to be wrapped in tournament property (atleast it works for me in that way). Would be nice if you could update it and make changes in maven :)

stefangeyer commented 6 years ago

Fixed in ed762e557c49a34fea9000083415c00327f1a71b. I also added methods to TournamentHandler that allow an easier use of subdomains.