Exemple #1
0
        /// <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);
            }
        }
        /// <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>
        /// 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);
            }
        }