/// <summary> /// provides additional details from the autocomplete search id /// </summary> /// <param name="id">place id</param> /// <returns>details</returns> public async Task <PlaceDetailResponse> GetPlaceDetailsByIdAsync(string id) { _placeDetail = new PlaceDetailResponse(); if (string.IsNullOrWhiteSpace(id)) { _logging.Error("GoogleApi:GetPlaceDetailsByIdAsync", "The id value is missing"); return(_placeDetail); } return(await Task.Run(async() => { try { _placeDetail = new PlaceDetailResponse(); string url = string.Format(PlaceDetailUrl, id, Key); var rawJson = await url.GetUrlResponseString(); var placeDetail = rawJson.DeserializeObject <PlaceDetail>(); if (placeDetail != null && placeDetail.status == "OK") { _placeDetail.Name = placeDetail.result.name; _placeDetail.Location = placeDetail.result.geometry.location; _placeDetail.Url = placeDetail.result.url; _placeDetail.Website = placeDetail.result.website; _placeDetail.Address = placeDetail.result.formatted_address; _placeDetail.PhoneNumber = placeDetail.result.formatted_phone_number; _placeDetail.LocationTypes = placeDetail.result.types; _placeDetail.isOpen = placeDetail.result.opening_hours.open_now; } return _placeDetail; } catch (Exception ex) { _logging.Error("GoogleApi:GetPlaceDetailsByIdAsync", ex.ToString()); _placeDetail = null; } return _placeDetail; })); }
public async Task <DistanceMatrix> GetDistanceMatrixByIdAsync(string lat, string lon, string id) { _distance = new DistanceMatrix(); if (string.IsNullOrWhiteSpace(lat)) { _logging.Error("GoogleApi:GetDistanceMatrixByIdAsync", "The lat can not be empty"); return(_distance); } if (string.IsNullOrWhiteSpace(lon)) { _logging.Error("GoogleApi:GetDistanceMatrixByIdAsync", "The lon can not be empty"); return(_distance); } if (string.IsNullOrWhiteSpace(id)) { _logging.Error("GoogleApi:GetDistanceMatrixByIdAsync", "The id value can not be empty"); return(_distance); } return(await Task.Run(async() => { try { string url = string.Format(DistanceMatrix, lat, lon, id, Key); var rawJson = await url.GetUrlResponseString(); _distance = rawJson.DeserializeObject <DistanceMatrix>(); return _distance; } catch (Exception ex) { _logging.Error("GoogleApi:GetDistanceMatrixByIdAsync", ex.ToString()); _placeDetail = null; } return _distance; })); }