Example #1
0
        /// <summary>
        /// Call the encounter by name directly
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="requiredNamespace">The required namespace.</param>
        /// <param name="locale">The locale.</param>
        /// <returns>The encounter</returns>
        public static async Task <RootEncounter> SearchEncounter(string requiredNamespace, string locale, string name = null, string orderBy = "id", string sortOrder = "desc", int page = 1)
        {
            Console.WriteLine("Début de la recherche sur les boss");
            UriBuilder uriBuilder = new UriBuilder(baseURL);

            uriBuilder.Path = $"data/wow/search/journal-encounter";
            var query = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["namespace"]           = requiredNamespace;
            query["locale"]              = locale;
            query["orderby"]             = orderBy + ":" + sortOrder;
            query["_page"]               = page.ToString();
            query["instance.name.en_US"] = name;
            uriBuilder.Query             = query.ToString();

            var request = AuthentificationRepoAPI.CreateHttpRequest(HttpMethod.Get, uriBuilder.Uri);

            var response = httpClient.SendAsync(request).Result;

            var content = await response.Content.ReadAsStringAsync();

            if (content != null)
            {
                RootEncounter result = JsonConvert.DeserializeObject <RootEncounter>(content);
                if (result.results != null && result.results.Count > 0)
                {
                    Console.WriteLine("Récupération des résultats de la recherche des boss OK");
                    return(result);
                }
            }

            Console.WriteLine("Récupération des résultats de la recherche des boss KO");
            return(null);
        }
        /// <summary>
        /// Gets the instance by identifier.
        /// </summary>
        /// <param name="requiredNamespace">The required namespace.</param>
        /// <param name="locale">The locale.</param>
        /// <param name="instanceId">The creature identifier.</param>
        /// <returns></returns>
        public static async Task <RootInstance> GetInstanceById(string requiredNamespace, string locale, int instanceId)
        {
            Console.WriteLine("Début de la recherche d'une instance via son ID");
            UriBuilder uriBuilder = new UriBuilder(baseURL);

            uriBuilder.Path = $"data/wow/journal-instance/" + instanceId.ToString();
            var query = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["namespace"] = requiredNamespace;
            query["locale"]    = locale;
            uriBuilder.Query   = query.ToString();

            var request = AuthentificationRepoAPI.CreateHttpRequest(HttpMethod.Get, uriBuilder.Uri);

            var response = httpClient.SendAsync(request).Result;

            var content = await response.Content.ReadAsStringAsync();

            if (content != null)
            {
                RootInstance result = JsonConvert.DeserializeObject <RootInstance>(content);
                if (result != null)
                {
                    Console.WriteLine("Récupération de l'instance OK");
                    return(result);
                }
            }

            Console.WriteLine("Récupération de l'instance KO");
            return(null);
        }
Example #3
0
        /// <summary>
        /// Gets the item by identifier.
        /// </summary>
        /// <param name="requiredNamespace">The required namespace.</param>
        /// <param name="locale">The locale.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <returns></returns>
        public static async Task <RootItem> GetItemById(string requiredNamespace, string locale, int itemId)
        {
            Console.WriteLine("Début de la recherche d'un item via son ID");
            UriBuilder uriBuilder = new UriBuilder(baseURL);

            uriBuilder.Path = $"data/wow/item/" + itemId.ToString();
            var query = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["namespace"] = requiredNamespace;
            query["locale"]    = locale;
            uriBuilder.Query   = query.ToString();

            var request = AuthentificationRepoAPI.CreateHttpRequest(HttpMethod.Get, uriBuilder.Uri);

            var content = await httpClient.Retry(request);

            if (content != null)
            {
                RootItem result = JsonConvert.DeserializeObject <RootItem>(content);
                if (result != null)
                {
                    Console.WriteLine("Récupération de l'item OK");
                    return(result);
                }
            }

            Console.WriteLine("Récupération de l'item KO");
            return(null);
        }