static void Main(string[] args) { var apiKey = ExampleUtils.GetApiKey(args); var client = new Client(apiKey); var query = new LocationQuery(StreetLine1, StreetLine2, City, StateCode, PostalCode); Response<ILocation> response; try { response = client.FindLocations(query); } catch (FindException) { System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} failed!", StreetLine1, StreetLine2, City, StateCode, PostalCode); throw; } if ((response != null) && (response.IsSuccess)) { var results = response.Results; System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} was successful, returning {5} root location objects.{6}{6}", StreetLine1, StreetLine2, City, StateCode, PostalCode, results.Count, System.Environment.NewLine); foreach (var location in results) { ExampleUtils.DumpLocation(location, 2); System.Console.Out.WriteLine(); } } #if DEBUG System.Console.Out.WriteLine("Press the ENTER key to quit..."); System.Console.In.ReadLine(); #endif }
public void ItShouldPrintAHumanReadableLocationQuery() { var q = new LocationQuery("1301 5th Ave", "Ste 1600", "Seattle", "WA", "98101"); var s = q.ToString(); Console.Out.WriteLine(s); Assert.IsTrue(s.StartsWith("LocationQuery")); Assert.IsTrue(s.Contains("1301 5th Ave"));Assert.IsTrue(s.Contains("Ste 1600")); Assert.IsTrue(s.Contains("Seattle")); Assert.IsTrue(s.Contains("WA")); Assert.IsTrue(s.Contains("98101")); }
public Response<ILocation> SearchProApi(string streetAddress, string city, string state, string postalCode) { Response<ILocation> response; var apiKey = ConfigurationManager.AppSettings["api_key"]; var client = new Client(apiKey); var query = new LocationQuery(streetAddress, null, city, state, postalCode); try { response = client.FindLocations(query); } catch (FindException) { throw new Exception(String.Format("ReverseAddress lookup for {0} {1} {2} {3} failed!", streetAddress, city, state, postalCode)); } return response; }
/// <summary> /// Executes the given query and returns the response. /// </summary> /// <param name="query">The query to perform</param> /// <returns>The response object</returns> public virtual Response<ILocation> FindLocations(LocationQuery query) { return _locationResultFinder.Find(query, this); }
public override Response<ILocation> FindLocations(LocationQuery query) { if (this.ForceErrorResult) { throw new FindException("Stubbed client always errors!"); } var results = new List<ILocation>(); if (!this.ForceEmptyResult) { results.Add(_location); } return new Response<ILocation>(this, results, GetDictionary(this), _emptyMessages); }