/// <summary> /// API to perform flicker search /// </summary> /// <param name="queryContext"></param> public override async Task <IResponseContext> PerformSearch(IQueryContext queryContext) { if (queryContext?.ApplicationConfiguration == null || queryContext.QueryParam == null) { throw new ArgumentException("Invalid argument passed to method FlickerSearchSearchComponent.PerformSearch", nameof(queryContext)); } ApplicationConfiguration appConfig = queryContext.ApplicationConfiguration; IDataSource ds = appConfig.GetDataSource(DataSources.Flicker); //sample query : https://www.flickr.com/services/feeds/photos_public.gne?tags=Nature string finalURI = ds.DataSourceURI + "?tags=" + queryContext.QueryParam; HTTPAPIResponse response = await m_HttpAPIHelper.Get(finalURI) as HTTPAPIResponse; IResponseContext searchResponse = ParseResponse(response); return(searchResponse); }
/// <summary> /// API to perform NewsAPI search /// </summary> /// <param name="queryContext"></param> public override async Task <IResponseContext> PerformSearch(IQueryContext queryContext) { ApplicationConfiguration appConfig = queryContext.ApplicationConfiguration; IDataSource ds = appConfig.GetDataSource(DataSources.NewsAPI); if (string.IsNullOrEmpty(queryContext.QueryParam)) { queryContext.QueryParam = "Trending"; } //sample query : "http://newsapi.org/v2/everything?" + "q=Nature&apiKey=a56eae9e984a40b2a88c2eb097427e4b"; string finalURI = ds.DataSourceURI + "?q=" + queryContext.QueryParam + "&apiKey=a56eae9e984a40b2a88c2eb097427e4b"; HTTPAPIResponse response = await m_HttpAPIHelper.Get(finalURI) as HTTPAPIResponse; IResponseContext searchResponse = ParseResponse(response); return(searchResponse); }