/// <summary> /// Gets the images asynchronously. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <ImageSearchResponse> GetImagesAsync(ImageSearchRequest 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 <ImageSearchResponse>(responseJson); return(response); }
/// <summary> /// Gets the images. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public ImageSearchResponse GetImages(ImageSearchRequest request) { return(GetImagesAsync(request).Result); }