/// <summary> /// Gets the news asynchronous. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <NewsSearchResponse> GetNewsAsync(NewsSearchRequest request) { request.Validate(); var requestUrl = string.Format("{0}?q={1}", this.Url, request.Query); if (request.Count > 0) { requestUrl = string.Format("{0}&count={1}", requestUrl, request.Count.ToString()); } if (request.Offset > 0) { requestUrl = string.Format("{0}&offset={1}", requestUrl, request.Offset.ToString()); } if (!string.IsNullOrEmpty(request.Market)) { requestUrl = string.Format("{0}&mkt={1}", requestUrl, request.Market); } requestUrl = string.Format("{0}&safeSearch={1}", requestUrl, request.SafeSearch.ToString()); var responseJson = await this.SendGetAsync(requestUrl); var response = JsonConvert.DeserializeObject <NewsSearchResponse>(responseJson); return(response); }
/// <summary> /// Gets the news. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public NewsSearchResponse GetNews(NewsSearchRequest request) { return(GetNewsAsync(request).Result); }