Exemple #1
0
        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));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 internal static string GetNamespaceString(BlizzardNamespace ns, BlizzardRegion region)
 {
     return(ns.ToString().ToLowerInvariant() + "-" + GetRegionCode(region));
 }