Class: Google::Apis::CivicinfoV2::CivicInfoService
- Inherits:
-
Google::Apis::Core::BaseService
- Object
- Google::Apis::Core::BaseService
- Google::Apis::CivicinfoV2::CivicInfoService
- Defined in:
- generated/google/apis/civicinfo_v2/service.rb
Overview
Google Civic Information API
Provides polling places, early vote locations, contest data, election officials, and government representatives for U.S. residential addresses.
Instance Attribute Summary collapse
-
#key ⇒ String
API key.
-
#quota_user ⇒ String
Available to use for quota purposes for server-side applications.
-
#user_ip ⇒ String
IP address of the site where the request originates.
Attributes inherited from Google::Apis::Core::BaseService
#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path
Instance Method Summary collapse
-
#initialize ⇒ CivicInfoService
constructor
A new instance of CivicInfoService.
-
#query_election(elections_query_request_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::QueryElectionsResponse
List of available elections to query.
-
#query_voter_info(address, voter_info_request_object = nil, election_id: nil, official_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::VoterInfoResponse
Looks up information relevant to a voter based on the voter's registered address.
-
#representative_info_by_address(representative_info_request_object = nil, address: nil, include_offices: nil, levels: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::RepresentativeInfoResponse
Looks up political geography and representative information for a single address.
-
#representative_info_by_division(ocd_id, division_representative_info_request_object = nil, levels: nil, recursive: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::RepresentativeInfoData
Looks up representative information for a single geographic division.
-
#search_divisions(division_search_request_object = nil, query: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::DivisionSearchResponse
Searches for political divisions by their natural name or OCD ID.
Methods inherited from Google::Apis::Core::BaseService
#batch, #batch_upload, #fetch_all, #http
Methods included from Google::Apis::Core::Logging
Constructor Details
#initialize ⇒ CivicInfoService
Returns a new instance of CivicInfoService
52 53 54 55 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 52 def initialize super('https://www.googleapis.com/', 'civicinfo/v2/') @batch_path = 'batch' end |
Instance Attribute Details
#key ⇒ String
Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
39 40 41 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 39 def key @key end |
#quota_user ⇒ String
Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
45 46 47 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 45 def quota_user @quota_user end |
#user_ip ⇒ String
Returns IP address of the site where the request originates. Use this if you want to enforce per-user limits.
50 51 52 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 50 def user_ip @user_ip end |
Instance Method Details
#query_election(elections_query_request_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::QueryElectionsResponse
List of available elections to query.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 121 def query_election(elections_query_request_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block) command = make_simple_command(:get, 'elections', ) command.request_representation = Google::Apis::CivicinfoV2::ElectionsQueryRequest::Representation command.request_object = elections_query_request_object command.response_representation = Google::Apis::CivicinfoV2::QueryElectionsResponse::Representation command.response_class = Google::Apis::CivicinfoV2::QueryElectionsResponse command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? command.query['userIp'] = user_ip unless user_ip.nil? execute_or_queue_command(command, &block) end |
#query_voter_info(address, voter_info_request_object = nil, election_id: nil, official_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::VoterInfoResponse
Looks up information relevant to a voter based on the voter's registered address.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 168 def query_voter_info(address, voter_info_request_object = nil, election_id: nil, official_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block) command = make_simple_command(:get, 'voterinfo', ) command.request_representation = Google::Apis::CivicinfoV2::VoterInfoRequest::Representation command.request_object = voter_info_request_object command.response_representation = Google::Apis::CivicinfoV2::VoterInfoResponse::Representation command.response_class = Google::Apis::CivicinfoV2::VoterInfoResponse command.query['address'] = address unless address.nil? command.query['electionId'] = election_id unless election_id.nil? command.query['officialOnly'] = official_only unless official_only.nil? command.query['returnAllAvailableData'] = return_all_available_data unless return_all_available_data.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? command.query['userIp'] = user_ip unless user_ip.nil? execute_or_queue_command(command, &block) end |
#representative_info_by_address(representative_info_request_object = nil, address: nil, include_offices: nil, levels: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::RepresentativeInfoResponse
Looks up political geography and representative information for a single address.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 222 def representative_info_by_address(representative_info_request_object = nil, address: nil, include_offices: nil, levels: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block) command = make_simple_command(:get, 'representatives', ) command.request_representation = Google::Apis::CivicinfoV2::RepresentativeInfoRequest::Representation command.request_object = representative_info_request_object command.response_representation = Google::Apis::CivicinfoV2::RepresentativeInfoResponse::Representation command.response_class = Google::Apis::CivicinfoV2::RepresentativeInfoResponse command.query['address'] = address unless address.nil? command.query['includeOffices'] = include_offices unless include_offices.nil? command.query['levels'] = levels unless levels.nil? command.query['roles'] = roles unless roles.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? command.query['userIp'] = user_ip unless user_ip.nil? execute_or_queue_command(command, &block) end |
#representative_info_by_division(ocd_id, division_representative_info_request_object = nil, levels: nil, recursive: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::RepresentativeInfoData
Looks up representative information for a single geographic division.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 275 def representative_info_by_division(ocd_id, division_representative_info_request_object = nil, levels: nil, recursive: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block) command = make_simple_command(:get, 'representatives/{ocdId}', ) command.request_representation = Google::Apis::CivicinfoV2::DivisionRepresentativeInfoRequest::Representation command.request_object = division_representative_info_request_object command.response_representation = Google::Apis::CivicinfoV2::RepresentativeInfoData::Representation command.response_class = Google::Apis::CivicinfoV2::RepresentativeInfoData command.params['ocdId'] = ocd_id unless ocd_id.nil? command.query['levels'] = levels unless levels.nil? command.query['recursive'] = recursive unless recursive.nil? command.query['roles'] = roles unless roles.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? command.query['userIp'] = user_ip unless user_ip.nil? execute_or_queue_command(command, &block) end |
#search_divisions(division_search_request_object = nil, query: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::DivisionSearchResponse
Searches for political divisions by their natural name or OCD ID.
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'generated/google/apis/civicinfo_v2/service.rb', line 85 def search_divisions(division_search_request_object = nil, query: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block) command = make_simple_command(:get, 'divisions', ) command.request_representation = Google::Apis::CivicinfoV2::DivisionSearchRequest::Representation command.request_object = division_search_request_object command.response_representation = Google::Apis::CivicinfoV2::DivisionSearchResponse::Representation command.response_class = Google::Apis::CivicinfoV2::DivisionSearchResponse command.query['query'] = query unless query.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? command.query['userIp'] = user_ip unless user_ip.nil? execute_or_queue_command(command, &block) end |