private static IEnumerable <WordSuggestion> ParseSuggestions(JdictSuggestions jdictSuggestions) => jdictSuggestions.List.Select(suggestion => new WordSuggestion() { Word = $"{suggestion.Word} / {suggestion.Kana}", Meaning = suggestion.SuggestMean.Replace(" ", " "), //remove weird typos. });
public async Task <IEnumerable <WordSuggestion> > Get(string word) { var response = await SendSuggestionsRequest(word); if (!response.IsSuccessStatusCode) { throw new HttpRequestException($"Failed to get content. Status code: {response.StatusCode}"); } var rawSuggestions = await response.Content.ReadAsStringAsync(); JdictSuggestions jdictSuggestions = GetJdictSuggestions(rawSuggestions); return(ParseSuggestions(jdictSuggestions)); }