Class: Google::Apis::CivicinfoV2::CivicInfoService
- Inherits:
-
Google::Apis::Core::BaseService
- Object
- Google::Apis::Core::BaseService
- Google::Apis::CivicinfoV2::CivicInfoService
- Defined in:
- lib/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.
Constant Summary collapse
- DEFAULT_ENDPOINT_TEMPLATE =
"https://civicinfo.$UNIVERSE_DOMAIN$/"
Instance Attribute Summary collapse
-
#key ⇒ String
API key.
-
#quota_user ⇒ String
Available to use for quota purposes for server-side applications.
Instance Method Summary collapse
-
#initialize ⇒ CivicInfoService
constructor
A new instance of CivicInfoService.
-
#query_division_division_by_address(address: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionByAddressResponse
Lookup OCDIDs and names for divisions related to an address.
-
#query_election(production_data_only: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2ElectionsQueryResponse
List of available elections to query.
-
#query_voter_info(address: nil, election_id: nil, official_only: nil, production_data_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2VoterInfoResponse
Looks up information relevant to a voter based on the voter's registered address.
-
#search_divisions(query: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionSearchResponse
Searches for political divisions by their natural name or OCD ID.
Constructor Details
#initialize ⇒ CivicInfoService
Returns a new instance of CivicInfoService.
48 49 50 51 52 53 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 48 def initialize super(DEFAULT_ENDPOINT_TEMPLATE, '', client_name: 'google-apis-civicinfo_v2', client_version: Google::Apis::CivicinfoV2::GEM_VERSION) @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.
41 42 43 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 41 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.
46 47 48 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 46 def quota_user @quota_user end |
Instance Method Details
#query_division_division_by_address(address: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionByAddressResponse
Lookup OCDIDs and names for divisions related to an address.
74 75 76 77 78 79 80 81 82 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 74 def query_division_division_by_address(address: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'civicinfo/v2/divisionsByAddress', ) command.response_representation = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionByAddressResponse::Representation command.response_class = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionByAddressResponse command.query['address'] = address unless address.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#query_election(production_data_only: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2ElectionsQueryResponse
List of available elections to query.
137 138 139 140 141 142 143 144 145 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 137 def query_election(production_data_only: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'civicinfo/v2/elections', ) command.response_representation = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2ElectionsQueryResponse::Representation command.response_class = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2ElectionsQueryResponse command.query['productionDataOnly'] = production_data_only unless production_data_only.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#query_voter_info(address: nil, election_id: nil, official_only: nil, production_data_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2VoterInfoResponse
Looks up information relevant to a voter based on the voter's registered address.
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 184 def query_voter_info(address: nil, election_id: nil, official_only: nil, production_data_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'civicinfo/v2/voterinfo', ) command.response_representation = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2VoterInfoResponse::Representation command.response_class = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2VoterInfoResponse 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['productionDataOnly'] = production_data_only unless production_data_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? execute_or_queue_command(command, &block) end |
#search_divisions(query: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionSearchResponse
Searches for political divisions by their natural name or OCD ID.
107 108 109 110 111 112 113 114 115 |
# File 'lib/google/apis/civicinfo_v2/service.rb', line 107 def search_divisions(query: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'civicinfo/v2/divisions', ) command.response_representation = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionSearchResponse::Representation command.response_class = Google::Apis::CivicinfoV2::CivicinfoApiprotosV2DivisionSearchResponse command.query['query'] = query unless query.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |