Class: Google::Apis::CivicinfoV2::CivicInfoService

Inherits:
Google::Apis::Core::BaseService show all
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.

Examples:

require 'google/apis/civicinfo_v2'

Civicinfo = Google::Apis::CivicinfoV2 # Alias the module
service = Civicinfo::CivicInfoService.new

See Also:

Instance Attribute Summary collapse

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

Methods inherited from Google::Apis::Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Constructor Details

#initializeCivicInfoService

Returns a new instance of CivicInfoService.



52
53
54
# File 'generated/google/apis/civicinfo_v2/service.rb', line 52

def initialize
  super('https://www.googleapis.com/', 'civicinfo/v2/')
end

Instance Attribute Details

#keyString

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.

Returns:

  • (String)

    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_userString

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.

Returns:

  • (String)

    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_ipString

Returns IP address of the site where the request originates. Use this if you want to enforce per-user limits.

Returns:

  • (String)

    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(fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::QueryElectionsResponse

List of available elections to query.

Parameters:

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



116
117
118
119
120
121
122
123
124
# File 'generated/google/apis/civicinfo_v2/service.rb', line 116

def query_election(fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
  command =  make_simple_command(:get, 'elections', options)
  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, 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.

Parameters:

  • address (String)

    The registered address of the voter to look up.

  • election_id (String) (defaults to: nil)

    The unique ID of the election to look up. A list of election IDs can be obtained at https://www.googleapis.com/civicinfo/`version`/elections

  • official_only (Boolean) (defaults to: nil)

    If set to true, only data from official state sources will be returned.

  • return_all_available_data (Boolean) (defaults to: nil)

    If set to true, the query will return the success codeand include any partial information when it is unable to determine a matching address or unable to determine the election for electionId=0 queries.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'generated/google/apis/civicinfo_v2/service.rb', line 160

def query_voter_info(address, 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', options)
  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(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.

Parameters:

  • address (String) (defaults to: nil)

    The address to look up. May only be specified if the field ocdId is not given in the URL.

  • include_offices (Boolean) (defaults to: nil)

    Whether to return information about offices and officials. If false, only the top-level district information will be returned.

  • levels (Array<String>, String) (defaults to: nil)

    A list of office levels to filter by. Only offices that serve at least one of these levels will be returned. Divisions that don't contain a matching office will not be returned.

  • roles (Array<String>, String) (defaults to: nil)

    A list of office roles to filter by. Only offices fulfilling one of these roles will be returned. Divisions that don't contain a matching office will not be returned.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'generated/google/apis/civicinfo_v2/service.rb', line 211

def representative_info_by_address(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', options)
  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, 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.

Parameters:

  • ocd_id (String)

    The Open Civic Data division identifier of the division to look up.

  • levels (Array<String>, String) (defaults to: nil)

    A list of office levels to filter by. Only offices that serve at least one of these levels will be returned. Divisions that don't contain a matching office will not be returned.

  • recursive (Boolean) (defaults to: nil)

    If true, information about all divisions contained in the division requested will be included as well. For example, if querying ocd-division/country:us/ district:dc, this would also return all DC's wards and ANCs.

  • roles (Array<String>, String) (defaults to: nil)

    A list of office roles to filter by. Only offices fulfilling one of these roles will be returned. Divisions that don't contain a matching office will not be returned.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'generated/google/apis/civicinfo_v2/service.rb', line 261

def representative_info_by_division(ocd_id, levels: nil, recursive: nil, roles: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
  command =  make_simple_command(:get, 'representatives/{ocdId}', options)
  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(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.

Parameters:

  • query (String) (defaults to: nil)

    The search query. Queries can cover any parts of a OCD ID or a human readable division name. All words given in the query are treated as required patterns. In addition to that, most query operators of the Apache Lucene library are supported. See http://lucene.apache.org/core/2_9_4/queryparsersyntax.html

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



83
84
85
86
87
88
89
90
91
92
# File 'generated/google/apis/civicinfo_v2/service.rb', line 83

def search_divisions(query: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
  command =  make_simple_command(:get, 'divisions', options)
  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