private static string GetRegionHost(RequestParameters.REGIONS region)
        {
            switch (region)
            {
            case RequestParameters.REGIONS.EU:
                return(RegionHosts.EUROPE);

            case RequestParameters.REGIONS.US:
                return(RegionHosts.US);

            case RequestParameters.REGIONS.KOREA:
                return(RegionHosts.KOREA);

            case RequestParameters.REGIONS.CHINA:
                return(RegionHosts.CHINA);

            case RequestParameters.REGIONS.TAIWAN:
                return(RegionHosts.TAIWAN);

            case RequestParameters.REGIONS.SEA:
                return(RegionHosts.SEA);

            default:
                throw new ArgumentOutOfRangeException(region.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns artisan information
        /// </summary>
        /// <param name="region">Player region</param>
        /// <param name="artisan">Chosen artisan</param>
        /// <param name="locale">Language code (locale)</param>
        /// <returns></returns>
        public static ArtisanInfo GetArtisanInfo(RequestParameters.REGIONS region, RequestParameters.ARTISANS artisan, string locale, string apiKeyValue)
        {
            using (HttpWebResponse response = RequestHandler.CreateArtisanRequest(region, Enum.GetName(typeof(RequestParameters.ARTISANS), artisan).ToLower(), locale, apiKeyValue))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(String.Format("Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
                }

                DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ArtisanInfo));
                object      objResponse  = jsonSerializer.ReadObject(response.GetResponseStream());
                ArtisanInfo jsonResponse = objResponse as ArtisanInfo;
                return(jsonResponse);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns stats for the chosen hero (hero id can be seen in Profile Information)
        /// </summary>
        /// <param name="region">Player region</param>
        /// <param name="battleTag">Player's battle tag</param>
        /// <param name="heroId">Player's hero ID (hero IDs can be fetched from profile information</param>
        /// <param name="locale">Language code (locale)</param>
        /// <returns></returns>
        public static CharacterInfo GetCharacterInfo(RequestParameters.REGIONS region, string battleTag, string heroId, string locale, string apiKeyValue)
        {
            using (HttpWebResponse response = RequestHandler.CreateCharacterRequest(region, battleTag, heroId, locale, apiKeyValue))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(String.Format("Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
                }

                DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(CharacterInfo));
                object        objResponse  = jsonSerializer.ReadObject(response.GetResponseStream());
                CharacterInfo jsonResponse = objResponse as CharacterInfo;
                return(jsonResponse);
            }
        }
Ejemplo n.º 4
0
 public void GetItemInfo(RequestParameters.REGIONS region, string battleTag, string itemString, string apiKeyValue)
 {
 }
        /// <summary>
        /// Creates string that represents full URL path for Follower request
        /// </summary>
        /// <param name="battleTag"></param>
        /// <param name="characterId"></param>
        /// <returns></returns>
        internal static HttpWebResponse CreateFollowerRequest(RequestParameters.REGIONS region, string follower, string locale, string apiKeyValue)
        {
            string requestUtl = GetRegionHost(region) + Resources.FOLLOWER_DATA + follower + RequestParameters.LOCALE + locale + RequestParameters.APIKEY + apiKeyValue;

            return(MakeRequest(requestUtl));
        }
        /// <summary>
        /// Creates string that represents full URL path for Artisan request
        /// </summary>
        /// <param name="battleTag"></param>
        /// <param name="characterId"></param>
        /// <returns></returns>
        internal static HttpWebResponse CreateArtisanRequest(RequestParameters.REGIONS region, string artisan, string locale, string apiKeyValue)
        {
            string requestUtl = GetRegionHost(region) + Resources.ARTISAN_DATA + artisan + RequestParameters.LOCALE + locale + RequestParameters.APIKEY + apiKeyValue;

            return(MakeRequest(requestUtl));
        }
        /// <summary>
        /// Creates string that represents full URL path for Profile request
        /// </summary>
        /// <param name="region">Player's region</param>
        /// <param name="battleTag">Player's battle tag</param>
        /// <param name="locale">Language code (locale).</param>
        /// <returns></returns>
        internal static HttpWebResponse CreateProfileRequest(RequestParameters.REGIONS region, string battleTag, string locale, string apiKeyValue)
        {
            string requestUtl = GetRegionHost(region) + Resources.CAREER_PROFILE + battleTag + "/" + RequestParameters.LOCALE + locale + RequestParameters.APIKEY + apiKeyValue;

            return(MakeRequest(requestUtl));
        }