/// <summary> /// Returns the <seealso cref="HProfile"/> from the specified hotel associated with the given unique identifier in an asynchronous operation. /// </summary> /// <param name="uniqueId">The unique identifier of the player you wish to retrieve the <see cref="HProfile"/> from.</param> /// <param name="hotel">The <seealso cref="HHotel"/> that the target user is located on.</param> /// <returns></returns> public static async Task <HProfile> GetProfileAsync(string uniqueId, HHotel hotel) { string profileJson = await _httpClient.GetStringAsync( string.Format(PROFILE_API_FORMAT, hotel.ToUrl(), uniqueId)); return(HProfile.Create(profileJson)); }
/// <summary> /// Returns the user's public profile information associated with the given unique indentifier using the specified <see cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="uniqueId">The unique identifier of the user.</param> /// <param name="hotel">The hotel where the target user is from.</param> public static async Task <HProfile> GetProfileByUniqueIdAsync(string uniqueId, HHotel hotel) { using (var client = new WebClient()) { client.Proxy = null; client.Headers[HttpRequestHeader.UserAgent] = ChromeAgent; client.Headers.Add(HttpRequestHeader.Cookie, "YPF8827340282Jdskjhfiw_928937459182JAX666=127.0.0.1"); string profileJson = null; try { profileJson = await client.DownloadStringTaskAsync(string.Format(PROFILE_API_FORMAT, hotel.ToUrl(true), uniqueId)).ConfigureAwait(false); } catch (WebException ex) { using (WebResponse response = ex.Response) using (var responseReader = new StreamReader(response.GetResponseStream())) { profileJson = await responseReader.ReadToEndAsync().ConfigureAwait(false); } } if (profileJson.StartsWith("{\"error")) { return(null); } return(HProfile.Create(profileJson)); } }
/// <summary> /// Returns the user's public profile information associated with the given unique indentifier using the specified <see cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="uniqueId">The unique identifier of the user.</param> /// <param name="hotel">The hotel where the target user is from.</param> public static async Task <HProfile> GetProfileByUniqueIdAsync(string uniqueId, HHotel hotel) { string profileJson = await _hRequest.DownloadStringAsync( string.Format(PROFILE_API_FORMAT, hotel.ToUrl(true), uniqueId)).ConfigureAwait(false); return(HProfile.Create(profileJson)); }