public void request_is_correctly_transformed_to_url() { var medialTypes = new List<MedicalTypeGoogleService> { MedicalTypeGoogleService.Dentist }; var location = Substitutes.GetLocationSubstitute(); var googlePlacesApiRequest = new GooglePlacesApiRequest { IsGpsUsed = true, Location = location, MedicalTypes = medialTypes, Radius = 500 }; string actual = googlePlacesApiRequest.ToRequestUrl(); Assert.IsTrue(actual.Contains("https://maps.googleapis.com/maps/api/place/search/json?")); Assert.IsTrue(actual.Contains("key=")); Assert.IsTrue(actual.Contains("&location=50.0,25.0&radius=500&types=dentist&sensor=true")); }
public GooglePlacesWcfResponse GetDataFromGooglePlacesApi(Location centerPosition, IEnumerable<MedicalType> searchedMedicalTypes, int searchingRange) { var medicalTypesForGoogleService = MedicalTypesConverter.ToGoogleService(searchedMedicalTypes).ToArray(); var googlePlacesApiRequest = new GooglePlacesApiRequest { IsGpsUsed = false, Location = centerPosition, Radius = searchingRange, MedicalTypes = medicalTypesForGoogleService }; GooglePlacesWcfResponse response = _googleMapsInterfaceServiceClient.SendGooglePlacesApiRequest(googlePlacesApiRequest); if (response.Status == Status.Zero_Results) { throw new NoSearchResultsException(); } return response; }
public static GooglePlacesWcfResponse SendGooglePlacesApiRequest( this GoogleMapsInterfaceServiceClient client, GooglePlacesApiRequest request) { var syncProvider = new ManualResetEvent(false); GooglePlacesWcfResponse response = null; Exception responseException = null; client.SendGooglePlacesApiRequestCompleted += (sender, args) => { syncProvider.Set(); try { response = args.Result; } catch (Exception exception) { responseException = exception; } }; client.SendGooglePlacesApiRequestAsync(request); syncProvider.WaitOne(); CheckException(responseException); return response; }