public void Validate(IGeoSearchParameters parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } }
public string GetSearchGeoQuery(IGeoSearchParameters parameters) { if (string.IsNullOrEmpty(parameters.Query) && string.IsNullOrEmpty(parameters.IP) && parameters.Coordinates == null && parameters.Attributes.IsNullOrEmpty()) { throw new ArgumentException("You must provide valid coordinates, IP address, query, or attributes."); } var query = new StringBuilder(Resources.Geo_SearchGeo); query.AddParameterToQuery("query", parameters.Query); query.AddParameterToQuery("ip", parameters.IP); if (parameters.Coordinates != null) { query.AddParameterToQuery("lat", parameters.Coordinates.Latitude); query.AddParameterToQuery("long", parameters.Coordinates.Longitude); } foreach (var attribute in parameters.Attributes) { query.AddParameterToQuery(string.Format("attribute:{0}", attribute.Key), attribute.Value); } if (parameters.Granularity != Granularity.Undefined) { query.AddParameterToQuery("granularity", parameters.Granularity.ToString().ToLowerInvariant()); } if (parameters.Accuracy != null) { var accuracyMeasure = parameters.AccuracyMeasure == AccuracyMeasure.Feets ? "ft" : "m"; query.AddParameterToQuery("accuracy", $"{parameters.Accuracy}{accuracyMeasure}"); } query.AddParameterToQuery("max_results", parameters.MaximumNumberOfResults); query.AddParameterToQuery("contained_within", parameters.ContainedWithin); query.AddParameterToQuery("callback", parameters.Callback); query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters); return(query.ToString()); }
public string GetSearchGeoQuery(IGeoSearchParameters parameters) { if (string.IsNullOrEmpty(parameters.Query) && string.IsNullOrEmpty(parameters.IP) && parameters.Coordinates == null && parameters.Attributes.IsNullOrEmpty()) { throw new ArgumentException("You must provide valid coordinates, IP address, query, or attributes."); } var query = new StringBuilder(Resources.Geo_SearchGeo); query.AddParameterToQuery("query", parameters.Query); query.AddParameterToQuery("ip", parameters.IP); if (parameters.Coordinates != null) { query.AddParameterToQuery("lat", parameters.Coordinates.Latitude); query.AddParameterToQuery("long", parameters.Coordinates.Longitude); } foreach (var attribute in parameters.Attributes) { query.AddParameterToQuery(string.Format("attribute:{0}", attribute.Key), attribute.Value); } if (parameters.Granularity != Granularity.Undefined) { query.AddParameterToQuery("granularity", parameters.Granularity.ToString().ToLowerInvariant()); } if (parameters.Accuracy != null) { var accuracyMeasure = parameters.AccuracyMeasure == AccuracyMeasure.Feets ? "ft" : "m"; query.AddParameterToQuery("accuracy", $"{parameters.Accuracy}{accuracyMeasure}"); } query.AddParameterToQuery("max_results", parameters.MaximumNumberOfResults); query.AddParameterToQuery("contained_within", parameters.ContainedWithin); query.AddParameterToQuery("callback", parameters.Callback); query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters); return query.ToString(); }
public void Validate(IGeoSearchParameters parameters) { _helpClientParametersValidator.Validate(parameters); }
public Task <ITwitterResult <SearchGeoSearchResultDTO> > SearchGeoAsync(IGeoSearchParameters parameters, ITwitterRequest request) { return(_helpQueryExecutor.SearchGeoAsync(parameters, request)); }
public Task <ITwitterResult <SearchGeoSearchResultDTO> > SearchGeoAsync(IGeoSearchParameters parameters, ITwitterRequest request) { request.Query.Url = _helpQueryGenerator.GetSearchGeoQuery(parameters); request.Query.HttpMethod = HttpMethod.GET; return(_twitterAccessor.ExecuteRequestAsync <SearchGeoSearchResultDTO>(request)); }
public async Task <IPlace[]> SearchGeo(IGeoSearchParameters parameters) { var result = await _helpRequester.SearchGeo(parameters).ConfigureAwait(false); return(result?.DataTransferObject?.Result.Places); }
public IEnumerable <IPlace> SearchGeo(IGeoSearchParameters parameters) { var query = _geoQueryGenerator.GetSearchGeoQuery(parameters); return(_twitterAccessor.ExecuteGETQueryWithPath <IEnumerable <IPlace> >(query, "result", "places")); }
/// <summary> /// Search for places that can be attached to a statuses/update. Given a latitude and a longitude pair, an IP address, or a name. /// </summary> public IEnumerable <IPlace> SearchGeo(IGeoSearchParameters parameters) { return(_geoQueryExecutor.SearchGeo(parameters)); }
/// <summary> /// Search for places that can be attached to a statuses/update. Given a latitude and a longitude pair, an IP address, or a name. /// </summary> public static IEnumerable <IPlace> SearchGeo(IGeoSearchParameters parameters) { return(GeoController.SearchGeo(parameters)); }
public Task <ITwitterResult <SearchGeoSearchResultDTO> > SearchGeo(IGeoSearchParameters parameters) { _validator.Validate(parameters); return(ExecuteRequest(request => _helpController.SearchGeo(parameters, request))); }
public async Task <IPlace[]> SearchGeoAsync(IGeoSearchParameters parameters) { var result = await _helpRequester.SearchGeoAsync(parameters).ConfigureAwait(false); return(result?.Model?.Result.Places); }
public IEnumerable<IPlace> SearchGeo(IGeoSearchParameters parameters) { var query = _geoQueryGenerator.GetSearchGeoQuery(parameters); return _twitterAccessor.ExecuteGETQueryWithPath<IEnumerable<IPlace>>(query, "result", "places"); }
/// <summary> /// Search for places that can be attached to a statuses/update. Given a latitude and a longitude pair, an IP address, or a name. /// </summary> public static IEnumerable<IPlace> SearchGeo(IGeoSearchParameters parameters) { return GeoController.SearchGeo(parameters); }
/// <summary> /// Search for places that can be attached to a statuses/update. Given a latitude and a longitude pair, an IP address, or a name. /// </summary> public IEnumerable<IPlace> SearchGeo(IGeoSearchParameters parameters) { return _geoQueryExecutor.SearchGeo(parameters); }