google-apis-civicinfo_v2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +13 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.md +202 -0
- data/OVERVIEW.md +96 -0
- data/lib/google-apis-civicinfo_v2.rb +15 -0
- data/lib/google/apis/civicinfo_v2.rb +34 -0
- data/lib/google/apis/civicinfo_v2/classes.rb +1155 -0
- data/lib/google/apis/civicinfo_v2/gem_version.rb +28 -0
- data/lib/google/apis/civicinfo_v2/representations.rb +426 -0
- data/lib/google/apis/civicinfo_v2/service.rb +259 -0
- metadata +76 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'google/apis/core/base_service'
|
16
|
+
require 'google/apis/core/json_representation'
|
17
|
+
require 'google/apis/core/hashable'
|
18
|
+
require 'google/apis/errors'
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Apis
|
22
|
+
module CivicinfoV2
|
23
|
+
# Google Civic Information API
|
24
|
+
#
|
25
|
+
# Provides polling places, early vote locations, contest data, election
|
26
|
+
# officials, and government representatives for U.S. residential addresses.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# require 'google/apis/civicinfo_v2'
|
30
|
+
#
|
31
|
+
# Civicinfo = Google::Apis::CivicinfoV2 # Alias the module
|
32
|
+
# service = Civicinfo::CivicInfoService.new
|
33
|
+
#
|
34
|
+
# @see https://developers.google.com/civic-information/
|
35
|
+
class CivicInfoService < Google::Apis::Core::BaseService
|
36
|
+
# @return [String]
|
37
|
+
# API key. Your API key identifies your project and provides you with API access,
|
38
|
+
# quota, and reports. Required unless you provide an OAuth 2.0 token.
|
39
|
+
attr_accessor :key
|
40
|
+
|
41
|
+
# @return [String]
|
42
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
43
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
44
|
+
attr_accessor :quota_user
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
super('https://civicinfo.googleapis.com/', '',
|
48
|
+
client_name: 'google-apis-civicinfo_v2',
|
49
|
+
client_version: Google::Apis::CivicinfoV2::GEM_VERSION)
|
50
|
+
@batch_path = 'batch'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Searches for political divisions by their natural name or OCD ID.
|
54
|
+
# @param [String] query
|
55
|
+
# The search query. Queries can cover any parts of a OCD ID or a human readable
|
56
|
+
# division name. All words given in the query are treated as required patterns.
|
57
|
+
# In addition to that, most query operators of the Apache Lucene library are
|
58
|
+
# supported. See http://lucene.apache.org/core/2_9_4/queryparsersyntax.html
|
59
|
+
# @param [String] fields
|
60
|
+
# Selector specifying which fields to include in a partial response.
|
61
|
+
# @param [String] quota_user
|
62
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
63
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
64
|
+
# @param [Google::Apis::RequestOptions] options
|
65
|
+
# Request-specific options
|
66
|
+
#
|
67
|
+
# @yield [result, err] Result & error if block supplied
|
68
|
+
# @yieldparam result [Google::Apis::CivicinfoV2::SearchDivisionResponse] parsed result object
|
69
|
+
# @yieldparam err [StandardError] error object if request failed
|
70
|
+
#
|
71
|
+
# @return [Google::Apis::CivicinfoV2::SearchDivisionResponse]
|
72
|
+
#
|
73
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
74
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
75
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
76
|
+
def search_divisions(query: nil, fields: nil, quota_user: nil, options: nil, &block)
|
77
|
+
command = make_simple_command(:get, 'civicinfo/v2/divisions', options)
|
78
|
+
command.response_representation = Google::Apis::CivicinfoV2::SearchDivisionResponse::Representation
|
79
|
+
command.response_class = Google::Apis::CivicinfoV2::SearchDivisionResponse
|
80
|
+
command.query['query'] = query unless query.nil?
|
81
|
+
command.query['fields'] = fields unless fields.nil?
|
82
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
83
|
+
execute_or_queue_command(command, &block)
|
84
|
+
end
|
85
|
+
|
86
|
+
# List of available elections to query.
|
87
|
+
# @param [String] fields
|
88
|
+
# Selector specifying which fields to include in a partial response.
|
89
|
+
# @param [String] quota_user
|
90
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
91
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
92
|
+
# @param [Google::Apis::RequestOptions] options
|
93
|
+
# Request-specific options
|
94
|
+
#
|
95
|
+
# @yield [result, err] Result & error if block supplied
|
96
|
+
# @yieldparam result [Google::Apis::CivicinfoV2::QueryElectionsResponse] parsed result object
|
97
|
+
# @yieldparam err [StandardError] error object if request failed
|
98
|
+
#
|
99
|
+
# @return [Google::Apis::CivicinfoV2::QueryElectionsResponse]
|
100
|
+
#
|
101
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
102
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
103
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
104
|
+
def query_election(fields: nil, quota_user: nil, options: nil, &block)
|
105
|
+
command = make_simple_command(:get, 'civicinfo/v2/elections', options)
|
106
|
+
command.response_representation = Google::Apis::CivicinfoV2::QueryElectionsResponse::Representation
|
107
|
+
command.response_class = Google::Apis::CivicinfoV2::QueryElectionsResponse
|
108
|
+
command.query['fields'] = fields unless fields.nil?
|
109
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
110
|
+
execute_or_queue_command(command, &block)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Looks up information relevant to a voter based on the voter's registered
|
114
|
+
# address.
|
115
|
+
# @param [String] address
|
116
|
+
# The registered address of the voter to look up.
|
117
|
+
# @param [Fixnum] election_id
|
118
|
+
# The unique ID of the election to look up. A list of election IDs can be
|
119
|
+
# obtained at https://www.googleapis.com/civicinfo/`version`/elections. If no
|
120
|
+
# election ID is specified in the query and there is more than one election with
|
121
|
+
# data for the given voter, the additional elections are provided in the
|
122
|
+
# otherElections response field.
|
123
|
+
# @param [Boolean] official_only
|
124
|
+
# If set to true, only data from official state sources will be returned.
|
125
|
+
# @param [Boolean] return_all_available_data
|
126
|
+
# If set to true, the query will return the success code and include any partial
|
127
|
+
# information when it is unable to determine a matching address or unable to
|
128
|
+
# determine the election for electionId=0 queries.
|
129
|
+
# @param [String] fields
|
130
|
+
# Selector specifying which fields to include in a partial response.
|
131
|
+
# @param [String] quota_user
|
132
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
133
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
134
|
+
# @param [Google::Apis::RequestOptions] options
|
135
|
+
# Request-specific options
|
136
|
+
#
|
137
|
+
# @yield [result, err] Result & error if block supplied
|
138
|
+
# @yieldparam result [Google::Apis::CivicinfoV2::VoterInfoResponse] parsed result object
|
139
|
+
# @yieldparam err [StandardError] error object if request failed
|
140
|
+
#
|
141
|
+
# @return [Google::Apis::CivicinfoV2::VoterInfoResponse]
|
142
|
+
#
|
143
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
144
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
145
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
146
|
+
def query_voter_info(address, election_id: nil, official_only: nil, return_all_available_data: nil, fields: nil, quota_user: nil, options: nil, &block)
|
147
|
+
command = make_simple_command(:get, 'civicinfo/v2/voterinfo', options)
|
148
|
+
command.response_representation = Google::Apis::CivicinfoV2::VoterInfoResponse::Representation
|
149
|
+
command.response_class = Google::Apis::CivicinfoV2::VoterInfoResponse
|
150
|
+
command.query['address'] = address unless address.nil?
|
151
|
+
command.query['electionId'] = election_id unless election_id.nil?
|
152
|
+
command.query['officialOnly'] = official_only unless official_only.nil?
|
153
|
+
command.query['returnAllAvailableData'] = return_all_available_data unless return_all_available_data.nil?
|
154
|
+
command.query['fields'] = fields unless fields.nil?
|
155
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
156
|
+
execute_or_queue_command(command, &block)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Looks up political geography and representative information for a single
|
160
|
+
# address.
|
161
|
+
# @param [String] address
|
162
|
+
# The address to look up. May only be specified if the field ocdId is not given
|
163
|
+
# in the URL
|
164
|
+
# @param [Boolean] include_offices
|
165
|
+
# Whether to return information about offices and officials. If false, only the
|
166
|
+
# top-level district information will be returned.
|
167
|
+
# @param [Array<String>, String] levels
|
168
|
+
# A list of office levels to filter by. Only offices that serve at least one of
|
169
|
+
# these levels will be returned. Divisions that don't contain a matching office
|
170
|
+
# will not be returned.
|
171
|
+
# @param [Array<String>, String] roles
|
172
|
+
# A list of office roles to filter by. Only offices fulfilling one of these
|
173
|
+
# roles will be returned. Divisions that don't contain a matching office will
|
174
|
+
# not be returned.
|
175
|
+
# @param [String] fields
|
176
|
+
# Selector specifying which fields to include in a partial response.
|
177
|
+
# @param [String] quota_user
|
178
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
179
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
180
|
+
# @param [Google::Apis::RequestOptions] options
|
181
|
+
# Request-specific options
|
182
|
+
#
|
183
|
+
# @yield [result, err] Result & error if block supplied
|
184
|
+
# @yieldparam result [Google::Apis::CivicinfoV2::RepresentativeInfoResponse] parsed result object
|
185
|
+
# @yieldparam err [StandardError] error object if request failed
|
186
|
+
#
|
187
|
+
# @return [Google::Apis::CivicinfoV2::RepresentativeInfoResponse]
|
188
|
+
#
|
189
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
190
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
191
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
192
|
+
def representative_info_by_address(address: nil, include_offices: nil, levels: nil, roles: nil, fields: nil, quota_user: nil, options: nil, &block)
|
193
|
+
command = make_simple_command(:get, 'civicinfo/v2/representatives', options)
|
194
|
+
command.response_representation = Google::Apis::CivicinfoV2::RepresentativeInfoResponse::Representation
|
195
|
+
command.response_class = Google::Apis::CivicinfoV2::RepresentativeInfoResponse
|
196
|
+
command.query['address'] = address unless address.nil?
|
197
|
+
command.query['includeOffices'] = include_offices unless include_offices.nil?
|
198
|
+
command.query['levels'] = levels unless levels.nil?
|
199
|
+
command.query['roles'] = roles unless roles.nil?
|
200
|
+
command.query['fields'] = fields unless fields.nil?
|
201
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
202
|
+
execute_or_queue_command(command, &block)
|
203
|
+
end
|
204
|
+
|
205
|
+
# Looks up representative information for a single geographic division.
|
206
|
+
# @param [String] ocd_id
|
207
|
+
# The Open Civic Data division identifier of the division to look up.
|
208
|
+
# @param [Array<String>, String] levels
|
209
|
+
# A list of office levels to filter by. Only offices that serve at least one of
|
210
|
+
# these levels will be returned. Divisions that don't contain a matching office
|
211
|
+
# will not be returned.
|
212
|
+
# @param [Boolean] recursive
|
213
|
+
# If true, information about all divisions contained in the division requested
|
214
|
+
# will be included as well. For example, if querying ocd-division/country:us/
|
215
|
+
# district:dc, this would also return all DC's wards and ANCs.
|
216
|
+
# @param [Array<String>, String] roles
|
217
|
+
# A list of office roles to filter by. Only offices fulfilling one of these
|
218
|
+
# roles will be returned. Divisions that don't contain a matching office will
|
219
|
+
# not be returned.
|
220
|
+
# @param [String] fields
|
221
|
+
# Selector specifying which fields to include in a partial response.
|
222
|
+
# @param [String] quota_user
|
223
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
224
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
225
|
+
# @param [Google::Apis::RequestOptions] options
|
226
|
+
# Request-specific options
|
227
|
+
#
|
228
|
+
# @yield [result, err] Result & error if block supplied
|
229
|
+
# @yieldparam result [Google::Apis::CivicinfoV2::RepresentativeInfoData] parsed result object
|
230
|
+
# @yieldparam err [StandardError] error object if request failed
|
231
|
+
#
|
232
|
+
# @return [Google::Apis::CivicinfoV2::RepresentativeInfoData]
|
233
|
+
#
|
234
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
235
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
236
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
237
|
+
def representative_info_by_division(ocd_id, levels: nil, recursive: nil, roles: nil, fields: nil, quota_user: nil, options: nil, &block)
|
238
|
+
command = make_simple_command(:get, 'civicinfo/v2/representatives/{ocdId}', options)
|
239
|
+
command.response_representation = Google::Apis::CivicinfoV2::RepresentativeInfoData::Representation
|
240
|
+
command.response_class = Google::Apis::CivicinfoV2::RepresentativeInfoData
|
241
|
+
command.params['ocdId'] = ocd_id unless ocd_id.nil?
|
242
|
+
command.query['levels'] = levels unless levels.nil?
|
243
|
+
command.query['recursive'] = recursive unless recursive.nil?
|
244
|
+
command.query['roles'] = roles unless roles.nil?
|
245
|
+
command.query['fields'] = fields unless fields.nil?
|
246
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
247
|
+
execute_or_queue_command(command, &block)
|
248
|
+
end
|
249
|
+
|
250
|
+
protected
|
251
|
+
|
252
|
+
def apply_command_defaults(command)
|
253
|
+
command.query['key'] = key unless key.nil?
|
254
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-apis-civicinfo_v2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Google LLC
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-apis-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
description: This is the simple REST client for Google Civic Information API V2. Simple
|
28
|
+
REST clients are Ruby client libraries that provide access to Google services via
|
29
|
+
their HTTP REST API endpoints. These libraries are generated and updated automatically
|
30
|
+
based on the discovery documents published by the service, and they handle most
|
31
|
+
concerns such as authentication, pagination, retry, timeouts, and logging. You can
|
32
|
+
use this client to access the Google Civic Information API, but note that some services
|
33
|
+
may provide a separate modern client that is easier to use.
|
34
|
+
email: googleapis-packages@google.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".yardopts"
|
40
|
+
- CHANGELOG.md
|
41
|
+
- LICENSE.md
|
42
|
+
- OVERVIEW.md
|
43
|
+
- lib/google-apis-civicinfo_v2.rb
|
44
|
+
- lib/google/apis/civicinfo_v2.rb
|
45
|
+
- lib/google/apis/civicinfo_v2/classes.rb
|
46
|
+
- lib/google/apis/civicinfo_v2/gem_version.rb
|
47
|
+
- lib/google/apis/civicinfo_v2/representations.rb
|
48
|
+
- lib/google/apis/civicinfo_v2/service.rb
|
49
|
+
homepage: https://github.com/google/google-api-ruby-client
|
50
|
+
licenses:
|
51
|
+
- Apache-2.0
|
52
|
+
metadata:
|
53
|
+
bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
|
54
|
+
changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/generated/google-apis-civicinfo_v2/CHANGELOG.md
|
55
|
+
documentation_uri: https://googleapis.dev/ruby/google-apis-civicinfo_v2/v0.1.0
|
56
|
+
source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/generated/google-apis-civicinfo_v2
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '2.4'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubygems_version: 3.1.4
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Simple REST client for Google Civic Information API V2
|
76
|
+
test_files: []
|