private string BuildUrl (GeocodingRequest request) { var path = BaseUrl + "?language=en"; if (!string.IsNullOrEmpty (apiKey)) { path += "&key=" + apiKey; } return request.AddParametersToUrl (path); }
private string BuildUrl(GeocodingRequest request) { var path = BaseUrl + "?language=en"; if (!string.IsNullOrEmpty(apiKey)) { path += "&key=" + apiKey; } return(request.AddParametersToUrl(path)); }
public async Task<GeocodingResult[]> GetAddressesAsync (GeocodingRequest request) { request.Validate (); var path = Uri.EscapeUriString (BuildUrl (request)); var json = await httpClient.GetStringAsync (path); var response = JsonConvert.DeserializeObject<GeocodingResponse> (json); if (response.IsSuccess) { return response.Results; } throw new InvalidOperationException (string.Format ("Google Geocoding error [code: {0}]: {1}", response.Status, response.ErrorMessage)); }
public async Task <GeocodingResult[]> GetAddressesAsync(GeocodingRequest request) { request.Validate(); var path = Uri.EscapeUriString(BuildUrl(request)); var json = await httpClient.GetStringAsync(path); var response = JsonConvert.DeserializeObject <GeocodingResponse> (json); if (response.IsSuccess) { return(response.Results); } throw new InvalidOperationException(string.Format("Google Geocoding error [code: {0}]: {1}", response.Status, response.ErrorMessage)); }