private async Task <Character?> _GetCharacterFromCensusByName(string name, bool retry) { CensusQuery query = _Census.Create("character"); query.Where("name.first_lower").Equals(name.ToLower()); query.AddResolve("outfit"); try { JToken result = await query.GetAsync(); Character?player = _ParseCharacter(result); return(player); } catch (CensusConnectionException ex) { if (retry == true) { _Logger.LogWarning("Retrying {Char} from API", name); return(await _GetCharacterFromCensusByName(name, false)); } else { _Logger.LogError(ex, "Failed to get {0} from API", name); throw ex; } } }
private async Task <Character?> _GetCharacterFromCensus(string ID, bool retry) { CensusQuery query = _Census.Create("character"); query.Where("character_id").Equals(ID); query.AddResolve("outfit", "online_status"); query.ShowFields("character_id", "name", "faction_id", "outfit", "online_status"); try { JToken result = await query.GetAsync(); Character?player = _ParseCharacter(result); return(player); } catch (CensusConnectionException ex) { if (retry == true) { _Logger.LogWarning("Retrying {Char} from API", ID); return(await _GetCharacterFromCensus(ID, false)); } else { _Logger.LogError(ex, "Failed to get {0} from API", ID); throw ex; } } }