/// <summary> /// Looks up information relevant to a voter based on the voter's registered address. /// Documentation https://developers.google.com/civicinfo/v2/reference/elections/voterInfoQuery /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated CivicInfo service.</param> /// <param name="address">The registered address of the voter to look up.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>VoterInfoResponseResponse</returns> public static VoterInfoResponse VoterInfoQuery(CivicInfoService service, string address, ElectionsVoterInfoQueryOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (address == null) { throw new ArgumentNullException(address); } // Building the initial request. var request = service.Elections.VoterInfoQuery(address); // Applying optional parameters to the request. request = (ElectionsResource.VoterInfoQueryRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Elections.VoterInfoQuery failed.", ex); } }
/// <summary> /// Looks up representative information for a single geographic division. /// Documentation https://developers.google.com/civicinfo/v2/reference/representatives/representativeInfoByDivision /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated CivicInfo service.</param> /// <param name="ocdId">The Open Civic Data division identifier of the division to look up.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>RepresentativeInfoDataResponse</returns> public static RepresentativeInfoData RepresentativeInfoByDivision(CivicInfoService service, string ocdId, RepresentativesRepresentativeInfoByDivisionOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (ocdId == null) { throw new ArgumentNullException(ocdId); } // Building the initial request. var request = service.Representatives.RepresentativeInfoByDivision(ocdId); // Applying optional parameters to the request. request = (RepresentativesResource.RepresentativeInfoByDivisionRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Representatives.RepresentativeInfoByDivision failed.", ex); } }
public GoogleQueryServiceBase() { _service = new CivicInfoService(new BaseClientService.Initializer { ApplicationName = System.Configuration.ConfigurationManager.AppSettings["google-civic-api-project-name"], ApiKey = System.Configuration.ConfigurationManager.AppSettings["google-civic-api-server-key"] }); }
private ElectionsResource.VoterInfoQueryRequest SetUpVoterQueryRequest(string streetAddress, long electionId) { CivicInfoService service = new CivicInfoService(new BaseClientService.Initializer { ApplicationName = "ExcelToObjects", ApiKey = _apiKey }); var voterQueryRequest = new ElectionsResource.VoterInfoQueryRequest(service, streetAddress); voterQueryRequest.ElectionId = electionId; return(voterQueryRequest); }
public async Task <RepresentativeInfoResponse> GetLocalCivicInfo(string zipCode) { var civicService = new CivicInfoService(new BaseClientService.Initializer { ApiKey = _apiSettings.ApiKey, ApplicationName = _apiSettings.AppName }); var request = civicService.Representatives.RepresentativeInfoByAddress(); request.Address = zipCode; var response = await request.ExecuteAsync(); return(response); }
/// <summary> /// List of available elections to query. /// Documentation https://developers.google.com/civicinfo/v2/reference/elections/electionQuery /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated CivicInfo service.</param> /// <returns>ElectionsQueryResponseResponse</returns> public static ElectionsQueryResponse ElectionQuery(CivicInfoService service) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Make the request. return(service.Elections.ElectionQuery().Execute()); } catch (Exception ex) { throw new Exception("Request Elections.ElectionQuery failed.", ex); } }
/// <summary> /// Searches for political divisions by their natural name or OCD ID. /// Documentation https://developers.google.com/civicinfo/v2/reference/divisions/search /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated CivicInfo service.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>DivisionSearchResponseResponse</returns> public static DivisionSearchResponse Search(CivicInfoService service, DivisionsSearchOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Building the initial request. var request = service.Divisions.Search(); // Applying optional parameters to the request. request = (DivisionsResource.SearchRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Divisions.Search failed.", ex); } }