public PlacesNearbySearchResponse NearbySearch(double lat, double lgn) { var response = new PlacesNearbySearchResponse(); try { var AppKey = new ConfigurationBuilder().AddJsonFile("application.default.json").Build().GetSection("AppSettings")["ApiKey"]; var request = new PlacesNearBySearchRequest { Key = AppKey.ToString(),//this.ApiKey, Location = new Location() { Latitude = lat, Longitude = lgn }, Radius = 1000 }; HttpEngine <PlacesNearBySearchRequest, PlacesNearbySearchResponse> httpResponse = new HttpEngine <PlacesNearBySearchRequest, PlacesNearbySearchResponse>(); response = httpResponse.Query(request); } catch (Exception ex) { Trace.WriteLine("Exception during geting places data: " + ex.ToString()); } return(response); }
public PlacesNearbySearchResponse NearbySearchTest() { //Arrange var response = new PlacesNearbySearchResponse(); var request = new PlacesNearBySearchRequest { Key = "AIzaSyB_4x15ATP7Br_fRJpb215UGhsL519cwPA", Location = new Location() { Latitude = 45.8057017, Longitude = 15.9205017 }, Radius = 1000 }; HttpEngine <PlacesNearBySearchRequest, PlacesNearbySearchResponse> httpResponse = new HttpEngine <PlacesNearBySearchRequest, PlacesNearbySearchResponse>(); // Act response = httpResponse.Query(request); // Assert Assert.IsNotNull(response); return(response); }
void WhereMatsuya(string content) { var setMatsuyaReg = new Regex(RegexStringSet.MatsuyaPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); var m = setMatsuyaReg.Match(content); var req = new PlacesTextSearchRequest(); req.Language = Language.Japanese; req.Key = "AIzaSyDOFjkWnVMBNklD5RjTQX2T9XfwsAzHI2k"; req.Query = "松屋 " + m.Groups[2]; var httpEngine = new HttpEngine <PlacesTextSearchRequest, PlacesTextSearchResponse>(); var res = httpEngine.Query(req).Results.Take(3); if (res.Count() == 0) { this.client.PostStatus("みつからなかったよ", Visibility.Public); } else { var tootText = "調べてみたら"; foreach (var r in res) { tootText += r.Name + "、"; } tootText = tootText.Substring(0, tootText.Length - 1); tootText += "がみつかったよ"; this.client.PostStatus(tootText, Visibility.Public); } }
public void QueryWhenTimeoutAndRequestIsNullTest() { var engine = new HttpEngine <PlacesQueryAutoCompleteRequest, PlacesQueryAutoCompleteResponse>(); Assert.Throws <ArgumentNullException>(() => engine.Query(null, new TimeSpan())); }
public void QueryWhenRequestIsNullTest() { var engine = new HttpEngine <TestRequest, TestResponse>(); Assert.Throws <ArgumentNullException>(() => engine.Query(null)); }