public async Task <string> GetJsonAsync(string relativeUrl, BlizzardLocaleFlags locale = BlizzardLocaleFlags.EnglishUS, BlizzardNamespace ns = BlizzardNamespace.Dynamic) { var uri = BlizzardUrlBuilder.GetUrl(Region, relativeUrl, locale, ns); return(await client.GetStringAsync(uri)); }
public static Uri GetUrl(BlizzardRegion region, string relativeUrl, BlizzardLocaleFlags locale = BlizzardLocaleFlags.EnglishUS, BlizzardNamespace ns = BlizzardNamespace.Dynamic) { var host = GetRegionHostname(region); var builder = new UriBuilder("https", host, -1, relativeUrl); if (builder.Query.Length > 0) { builder.Query += "&"; } builder.Query += "namespace=" + GetNamespaceString(ns, region); if (locale != BlizzardLocaleFlags.All && locale != BlizzardLocaleFlags.AllWowLocales) { builder.Query += "&locale=" + GetLocaleString(locale); } return(builder.Uri); }
public async Task <T> GetAsync <T>(string relativeUrl, BlizzardLocaleFlags locale = BlizzardLocaleFlags.EnglishUS, BlizzardNamespace ns = BlizzardNamespace.Dynamic) { var uri = BlizzardUrlBuilder.GetUrl(Region, relativeUrl, locale, ns); var response = await client.GetAsync(uri, token); #if DEBUG var stringValue = await response.Content.ReadAsStringAsync(); #endif await using var stream = await response.Content.ReadAsStreamAsync(); return(await JsonSerializer.DeserializeAsync <T>(stream, deserializeOptions, token)); }
internal static string GetNamespaceString(BlizzardNamespace ns, BlizzardRegion region) { return(ns.ToString().ToLowerInvariant() + "-" + GetRegionCode(region)); }