public void TestAutocomplete() { SearchRequest searchCriteria = new SearchRequest(); searchCriteria.Latitude = double.Parse("33.732556599999995"); //"33.730140"); searchCriteria.Longitude = double.Parse("-118.0010307"); // " - 118.000145"); searchCriteria.Text = "pi"; //var response = _client.AutocompleteAsync("cakes", 33.730140, -118.000145).Result; var response = _client.AutocompleteAsync(searchCriteria).Result; Assert.IsTrue(response.Categories.Length > 0); Assert.AreNotSame(null, response); Assert.AreSame(null, response?.Error, $"Response error returned {response?.Error?.Code} - {response?.Error?.Description}"); }
public async Task <List <string> > Autocomplete(SearchRequest searchCriteria) { List <string> suggestions = new List <string>(); try { var response = await _client.AutocompleteAsync(searchCriteria); if (response?.Error != null) { _logger?.Log($"Response error returned {response?.Error?.Code} - {response?.Error?.Description}"); } suggestions.AddRange(response.Terms.Select(t => t.Text)); suggestions.AddRange(response.Categories.Select(c => c.Title)); suggestions.AddRange(response.Businesses.Select(b => b.Name)); } catch (System.Exception e) { _logger?.Log(e.ToString()); } return(suggestions); }