BrentonPoke/ToornamentClient

Can't get matches with custom Fields

Closed this issue · 1 comments

So hey

When I am trying to get all matches from a tournament with this code(First the constructor is executed then the start method):

public class BotService {

    private final String TOURNAMENT_ID_MARK = "#:";
    List<Category> tournamentCategories;
    private  JDA jda;
    private  ToornamentClient toornamentClient;
    private List<TournamentDetails> serverTournaments = new ArrayList<>();
    private List<MatchDetails> matchDetails;

    public BotService(JDA jda) {
        this.jda = jda;
        List<Category> categories = jda.getCategories();
        this.tournamentCategories = categories.stream()
                .filter(c -> c.getName().contains(TOURNAMENT_ID_MARK))
                .collect(Collectors.toList());
        HashSet<Scope> scopes = new HashSet<>();
        scopes.add(Scope.ORGANIZER_RESULT);
        this.toornamentClient = new ToornamentClient(Token.API_KEY.getToken(), Token.CLIENT_ID.getToken(), Token.CLIENT_SECRET.getToken(), scopes);
        this.toornamentClient.authorize();
        Tournaments tournaments = toornamentClient.tournaments();
        for (Category cat: tournamentCategories) {
            String tournamentID = cat.getName().substring(cat.getName().indexOf("#:") + 2);
            TournamentDetails tournament = tournaments.getTournament(tournamentID);
            serverTournaments.add(tournament);
        }
    }

    public void startGetMatchesService() {

        for (TournamentDetails tournament:serverTournaments) {
            Matches matches = new Matches(toornamentClient,tournament);
            MatchQuery matchQuery = MatchQuery.builder().build();

            matchDetails =  matches.getMatches(matchQuery,"matches=0-99");
          matchDetails.forEach(x ->{
              System.out.println(x.toString());
          });
        }


    }
}

Then I am getting following Error:

Unrecognized field "beschwoerername" (class com.toornament.model.Custom.CustomFields), not marked as ignorable (37 known properties: "checkbox", "vimeo", "blood_bowl2_player_id", "facebook", "custom_fields", "summoner_player_id", "steam_player_id", "hs_pick_choice", "battle_net_player_id", "wargaming_player_id", "xbox_live_player_id", "twitch", "country", "optin", "id", "required", "origin_player_id", "snapchat", "youtube", "target_type", "public", "logo", "birth_date", "instagram", "twitter", "address", "smite_player_id", "full_name", "machine_name", "maniaplanet_player_id", "website", "uplay_player_id", "position", "default_value", "label", "type", "psn_player_id"])
 at [Source: (String)"[{"id":"3583383368534392845","stage_id":"3583383367896858624","group_id":"3583383368500838409","round_id":"3583383368534392851","number":1,"type":"duel","status":"pending","settings":{"match_format":null},"scheduled_datetime":null,"played_at":null,"public_note":null,"private_note":null,"report_closed":false,"opponents":[{"number":1,"position":1,"participant":{"id":"3536688842531454976","name":"Ch\u00eddor\u00ec","custom_user_identifier":"asd","custom_fields":{"beschwoerername":"Ch\u00eddor\u00ec"[truncated 1243 chars]; line: 1, column: 484] (through reference chain: java.util.ArrayList[0]->com.toornament.model.MatchDetails["opponents"]->java.util.ArrayList[0]->com.toornament.model.Opponent["participant"]->com.toornament.model.Participant["custom_fields"]->com.toornament.model.Custom.CustomFields["beschwoerername"])

We both know why this happens, but is there a way to fix that? Like I need to be able to have custom-named fields in my case.

note:
I changed the CustomFields Class a little bit and added, otherwise I couldn't register any participants to my tournament:

     @JsonProperty("custom_fields")
    private Map<String, String> customFields;

My registration object still look like:

{
  "name" : "ownedbypeli",
  "type" : "player",
  "tournament_id" : "3516126849330733056",
  "email" : "pelipongracz@gmail.com",
  "lineup" : [ ],
  "custom_fields" : {
    "beschwoerername" : "peli",
    "discordname" : "239677780600684544"
  }
}

I think we figured out what was going on some time ago, but the api has since been changed, so i'm updating it to their version 3.