1
// Package civicinfo provides access to the Google Civic Information API.
3
// See https://developers.google.com/civic-information
7
// import "google.golang.org/api/civicinfo/v1"
9
// civicinfoService, err := civicinfo.New(oauthHttpClient)
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "civicinfo:v1"
38
const apiName = "civicinfo"
39
const apiVersion = "v1"
40
const basePath = "https://www.googleapis.com/civicinfo/v1/"
42
func New(client *http.Client) (*Service, error) {
44
return nil, errors.New("client is nil")
46
s := &Service{client: client, BasePath: basePath}
47
s.Divisions = NewDivisionsService(s)
48
s.Elections = NewElectionsService(s)
49
s.Representatives = NewRepresentativesService(s)
55
BasePath string // API endpoint base URL
57
Divisions *DivisionsService
59
Elections *ElectionsService
61
Representatives *RepresentativesService
64
func NewDivisionsService(s *Service) *DivisionsService {
65
rs := &DivisionsService{s: s}
69
type DivisionsService struct {
73
func NewElectionsService(s *Service) *ElectionsService {
74
rs := &ElectionsService{s: s}
78
type ElectionsService struct {
82
func NewRepresentativesService(s *Service) *RepresentativesService {
83
rs := &RepresentativesService{s: s}
87
type RepresentativesService struct {
91
type AdministrationRegion struct {
92
// ElectionAdministrationBody: The election administration body for this
94
ElectionAdministrationBody *AdministrativeBody `json:"electionAdministrationBody,omitempty"`
96
// Id: An ID for this object. IDs may change in future requests and
97
// should not be cached. Access to this field requires special access
98
// that can be requested from the Request more link on the Quotas page.
99
Id string `json:"id,omitempty"`
101
// Local_jurisdiction: The city or county that provides election
102
// information for this voter. This object can have the same elements as
104
Local_jurisdiction *AdministrationRegion `json:"local_jurisdiction,omitempty"`
106
// Name: The name of the jurisdiction.
107
Name string `json:"name,omitempty"`
109
// Sources: A list of sources for this area. If multiple sources are
110
// listed the data has been aggregated from those sources.
111
Sources []*Source `json:"sources,omitempty"`
114
type AdministrativeBody struct {
115
// AbsenteeVotingInfoUrl: A URL provided by this administrative body for
116
// information on absentee voting.
117
AbsenteeVotingInfoUrl string `json:"absenteeVotingInfoUrl,omitempty"`
119
// BallotInfoUrl: A URL provided by this administrative body to give
120
// contest information to the voter.
121
BallotInfoUrl string `json:"ballotInfoUrl,omitempty"`
123
// CorrespondenceAddress: The mailing address of this administrative
125
CorrespondenceAddress *SimpleAddressType `json:"correspondenceAddress,omitempty"`
127
// ElectionInfoUrl: A URL provided by this administrative body for
128
// looking up general election information.
129
ElectionInfoUrl string `json:"electionInfoUrl,omitempty"`
131
// ElectionOfficials: The election officials for this election
132
// administrative body.
133
ElectionOfficials []*ElectionOfficial `json:"electionOfficials,omitempty"`
135
// ElectionRegistrationConfirmationUrl: A URL provided by this
136
// administrative body for confirming that the voter is registered to
138
ElectionRegistrationConfirmationUrl string `json:"electionRegistrationConfirmationUrl,omitempty"`
140
// ElectionRegistrationUrl: A URL provided by this administrative body
141
// for looking up how to register to vote.
142
ElectionRegistrationUrl string `json:"electionRegistrationUrl,omitempty"`
144
// ElectionRulesUrl: A URL provided by this administrative body
145
// describing election rules to the voter.
146
ElectionRulesUrl string `json:"electionRulesUrl,omitempty"`
148
// HoursOfOperation: A description of the hours of operation for this
149
// administrative body.
150
HoursOfOperation string `json:"hoursOfOperation,omitempty"`
152
// Name: The name of this election administrative body.
153
Name string `json:"name,omitempty"`
155
// PhysicalAddress: The physical address of this administrative body.
156
PhysicalAddress *SimpleAddressType `json:"physicalAddress,omitempty"`
158
// Voter_services: A description of the services this administrative
160
Voter_services []string `json:"voter_services,omitempty"`
162
// VotingLocationFinderUrl: A URL provided by this administrative body
163
// for looking up where to vote.
164
VotingLocationFinderUrl string `json:"votingLocationFinderUrl,omitempty"`
167
type Candidate struct {
168
// CandidateUrl: The URL for the candidate's campaign web site.
169
CandidateUrl string `json:"candidateUrl,omitempty"`
171
// Channels: A list of known (social) media channels for this candidate.
172
Channels []*Channel `json:"channels,omitempty"`
174
// Email: The email address for the candidate's campaign.
175
Email string `json:"email,omitempty"`
177
// Name: The candidate's name.
178
Name string `json:"name,omitempty"`
180
// OrderOnBallot: The order the candidate appears on the ballot for this
182
OrderOnBallot int64 `json:"orderOnBallot,omitempty,string"`
184
// Party: The full name of the party the candidate is a member of.
185
Party string `json:"party,omitempty"`
187
// Phone: The voice phone number for the candidate's campaign office.
188
Phone string `json:"phone,omitempty"`
190
// PhotoUrl: A URL for a photo of the candidate.
191
PhotoUrl string `json:"photoUrl,omitempty"`
194
type Channel struct {
195
// Id: The unique public identifier for the candidate's channel.
196
Id string `json:"id,omitempty"`
198
// Type: The type of channel. The following is a list of types of
199
// channels, but is not exhaustive. More channel types may be added at a
200
// later time. One of: GooglePlus, YouTube, Facebook, Twitter
201
Type string `json:"type,omitempty"`
204
type Contest struct {
205
// BallotPlacement: A number specifying the position of this contest on
206
// the voter's ballot.
207
BallotPlacement int64 `json:"ballotPlacement,omitempty,string"`
209
// Candidates: The candidate choices for this contest.
210
Candidates []*Candidate `json:"candidates,omitempty"`
212
// District: Information about the electoral district that this contest
214
District *ElectoralDistrict `json:"district,omitempty"`
216
// ElectorateSpecifications: A description of any additional eligibility
217
// requirements for voting in this contest.
218
ElectorateSpecifications string `json:"electorateSpecifications,omitempty"`
220
// Id: An ID for this object. IDs may change in future requests and
221
// should not be cached. Access to this field requires special access
222
// that can be requested from the Request more link on the Quotas page.
223
Id string `json:"id,omitempty"`
225
// Level: The level of office for this contest. One of: federal, state,
226
// county, city, other
227
Level string `json:"level,omitempty"`
229
// NumberElected: The number of candidates that will be elected to
230
// office in this contest.
231
NumberElected int64 `json:"numberElected,omitempty,string"`
233
// NumberVotingFor: The number of candidates that a voter may vote for
235
NumberVotingFor int64 `json:"numberVotingFor,omitempty,string"`
237
// Office: The name of the office for this contest.
238
Office string `json:"office,omitempty"`
240
// PrimaryParty: If this is a partisan election, the name of the party
242
PrimaryParty string `json:"primaryParty,omitempty"`
244
// ReferendumSubtitle: A brief description of the referendum. This field
245
// is only populated for contests of type 'Referendum'.
246
ReferendumSubtitle string `json:"referendumSubtitle,omitempty"`
248
// ReferendumTitle: The title of the referendum (e.g. 'Proposition 42').
249
// This field is only populated for contests of type 'Referendum'.
250
ReferendumTitle string `json:"referendumTitle,omitempty"`
252
// ReferendumUrl: A link to the referendum. This field is only populated
253
// for contests of type 'Referendum'.
254
ReferendumUrl string `json:"referendumUrl,omitempty"`
256
// Sources: A list of sources for this contest. If multiple sources are
257
// listed, the data has been aggregated from those sources.
258
Sources []*Source `json:"sources,omitempty"`
260
// Special: "Yes" or "No" depending on whether this a contest being held
261
// outside the normal election cycle.
262
Special string `json:"special,omitempty"`
264
// Type: The type of contest. Usually this will be 'General', 'Primary',
265
// or 'Run-off' for contests with candidates. For referenda this will be
267
Type string `json:"type,omitempty"`
270
type DivisionSearchResponse struct {
271
// Kind: Identifies what kind of resource this is. Value: the fixed
272
// string "civicinfo#divisionSearchResponse".
273
Kind string `json:"kind,omitempty"`
275
Results []*DivisionSearchResult `json:"results,omitempty"`
277
// Status: The result of the request. One of: success,
278
// addressUnparseable, noAddressParameter, internalLookupFailure
279
Status string `json:"status,omitempty"`
282
type DivisionSearchResult struct {
283
// Aliases: Other Open Civic Data identifiers that refer to the same
284
// division -- for example, those that refer to other political
285
// divisions whose boundaries are defined to be coterminous with this
286
// one. For example, ocd-division/country:us/state:wy will include an
287
// alias of ocd-division/country:us/state:wy/cd:1, since Wyoming has
288
// only one Congressional district.
289
Aliases []string `json:"aliases,omitempty"`
291
// Name: The name of the division.
292
Name string `json:"name,omitempty"`
294
// OcdId: The unique Open Civic Data identifier for this division.
295
OcdId string `json:"ocdId,omitempty"`
298
type Election struct {
299
// ElectionDay: Day of the election in YYYY-MM-DD format.
300
ElectionDay string `json:"electionDay,omitempty"`
302
// Id: The unique ID of this election.
303
Id int64 `json:"id,omitempty,string"`
305
// Name: A displayable name for the election.
306
Name string `json:"name,omitempty"`
309
type ElectionOfficial struct {
310
// EmailAddress: The email address of the election official.
311
EmailAddress string `json:"emailAddress,omitempty"`
313
// FaxNumber: The fax number of the election official.
314
FaxNumber string `json:"faxNumber,omitempty"`
316
// Name: The full name of the election official.
317
Name string `json:"name,omitempty"`
319
// OfficePhoneNumber: The office phone number of the election official.
320
OfficePhoneNumber string `json:"officePhoneNumber,omitempty"`
322
// Title: The title of the election official.
323
Title string `json:"title,omitempty"`
326
type ElectionsQueryResponse struct {
327
// Elections: A list of available elections
328
Elections []*Election `json:"elections,omitempty"`
330
// Kind: Identifies what kind of resource this is. Value: the fixed
331
// string "civicinfo#electionsQueryResponse".
332
Kind string `json:"kind,omitempty"`
335
type ElectoralDistrict struct {
336
// Id: An identifier for this district, relative to its scope. For
337
// example, the 34th State Senate district would have id "34" and a
338
// scope of stateUpper.
339
Id string `json:"id,omitempty"`
341
// Name: The name of the district.
342
Name string `json:"name,omitempty"`
344
// Scope: The geographic scope of this district. If unspecified the
345
// district's geography is not known. One of: national, statewide,
346
// congressional, stateUpper, stateLower, countywide, judicial,
347
// schoolBoard, cityWide, township, countyCouncil, cityCouncil, ward,
349
Scope string `json:"scope,omitempty"`
352
type GeographicDivision struct {
353
// AlsoKnownAs: Any other valid OCD IDs that refer to the same
356
// Because OCD IDs are meant to be human-readable and at
357
// least somewhat predictable, there are occasionally several
358
// identifiers for a single division. These identifiers are defined to
359
// be equivalent to one another, and one is always indicated as the
360
// primary identifier. The primary identifier will be returned in ocd_id
361
// above, and any other equivalent valid identifiers will be returned in
364
// For example, if this division's OCD ID is
365
// ocd-division/country:us/district:dc, this will contain
366
// ocd-division/country:us/state:dc.
367
AlsoKnownAs []string `json:"alsoKnownAs,omitempty"`
369
// Name: The name of the division.
370
Name string `json:"name,omitempty"`
372
// OfficeIds: List of keys in the offices object, one for each office
373
// elected from this division. Will only be present if includeOffices
374
// was true (or absent) in the request.
375
OfficeIds []string `json:"officeIds,omitempty"`
377
// Scope: The geographic scope of the division. If unspecified, the
378
// division's geography is not known. One of: national, statewide,
379
// congressional, stateUpper, stateLower, countywide, judicial,
380
// schoolBoard, cityWide, township, countyCouncil, cityCouncil, ward,
382
Scope string `json:"scope,omitempty"`
386
// DivisionId: The OCD ID of the division with which this office is
388
DivisionId string `json:"divisionId,omitempty"`
390
// Level: The level of this elected office. One of: federal, state,
391
// county, city, other
392
Level string `json:"level,omitempty"`
394
// Name: The human-readable name of the office.
395
Name string `json:"name,omitempty"`
397
// OfficialIds: List of keys in the officials object of people who
398
// presently hold this office.
399
OfficialIds []string `json:"officialIds,omitempty"`
401
// Sources: A list of sources for this office. If multiple sources are
402
// listed, the data has been aggregated from those sources.
403
Sources []*Source `json:"sources,omitempty"`
406
type Official struct {
407
// Address: Addresses at which to contact the official.
408
Address []*SimpleAddressType `json:"address,omitempty"`
410
// Channels: A list of known (social) media channels for this official.
411
Channels []*Channel `json:"channels,omitempty"`
413
// Emails: The direct email addresses for the official.
414
Emails []string `json:"emails,omitempty"`
416
// Name: The official's name.
417
Name string `json:"name,omitempty"`
419
// Party: The full name of the party the official belongs to.
420
Party string `json:"party,omitempty"`
422
// Phones: The official's public contact phone numbers.
423
Phones []string `json:"phones,omitempty"`
425
// PhotoUrl: A URL for a photo of the official.
426
PhotoUrl string `json:"photoUrl,omitempty"`
428
// Urls: The official's public website URLs.
429
Urls []string `json:"urls,omitempty"`
432
type PollingLocation struct {
433
// Address: The address of the location.
434
Address *SimpleAddressType `json:"address,omitempty"`
436
// EndDate: The last date that this early vote site or drop off location
437
// may be used. This field is not populated for polling locations.
438
EndDate string `json:"endDate,omitempty"`
440
// Id: An ID for this object. IDs may change in future requests and
441
// should not be cached. Access to this field requires special access
442
// that can be requested from the Request more link on the Quotas page.
443
Id string `json:"id,omitempty"`
445
// Name: The name of the early vote site or drop off location. This
446
// field is not populated for polling locations.
447
Name string `json:"name,omitempty"`
449
// Notes: Notes about this location (e.g. accessibility ramp or entrance
451
Notes string `json:"notes,omitempty"`
453
// PollingHours: A description of when this location is open.
454
PollingHours string `json:"pollingHours,omitempty"`
456
// Sources: A list of sources for this location. If multiple sources are
457
// listed the data has been aggregated from those sources.
458
Sources []*Source `json:"sources,omitempty"`
460
// StartDate: The first date that this early vote site or drop off
461
// location may be used. This field is not populated for polling
463
StartDate string `json:"startDate,omitempty"`
465
// VoterServices: The services provided by this early vote site or drop
466
// off location. This field is not populated for polling locations.
467
VoterServices string `json:"voterServices,omitempty"`
470
type RepresentativeInfoRequest struct {
471
// Address: The address to look up. May only be specified if the field
472
// ocdId is not given in the URL.
473
Address string `json:"address,omitempty"`
476
type RepresentativeInfoResponse struct {
477
// Divisions: Political geographic divisions that contain the requested
479
Divisions map[string]GeographicDivision `json:"divisions,omitempty"`
481
// Kind: Identifies what kind of resource this is. Value: the fixed
482
// string "civicinfo#representativeInfoResponse".
483
Kind string `json:"kind,omitempty"`
485
// NormalizedInput: The normalized version of the requested address
486
NormalizedInput *SimpleAddressType `json:"normalizedInput,omitempty"`
488
// Offices: Elected offices referenced by the divisions listed above.
489
// Will only be present if includeOffices was true in the request.
490
Offices map[string]Office `json:"offices,omitempty"`
492
// Officials: Officials holding the offices listed above. Will only be
493
// present if includeOffices was true in the request.
494
Officials map[string]Official `json:"officials,omitempty"`
496
// Status: The result of the request. One of: success,
497
// noStreetSegmentFound, addressUnparseable, noAddressParameter,
498
// multipleStreetSegmentsFound, electionOver, electionUnknown,
499
// internalLookupFailure, RequestedBothAddressAndOcdId
500
Status string `json:"status,omitempty"`
503
type SimpleAddressType struct {
504
// City: The city or town for the address.
505
City string `json:"city,omitempty"`
507
// Line1: The street name and number of this address.
508
Line1 string `json:"line1,omitempty"`
510
// Line2: The second line the address, if needed.
511
Line2 string `json:"line2,omitempty"`
513
// Line3: The third line of the address, if needed.
514
Line3 string `json:"line3,omitempty"`
516
// LocationName: The name of the location.
517
LocationName string `json:"locationName,omitempty"`
519
// State: The US two letter state abbreviation of the address.
520
State string `json:"state,omitempty"`
522
// Zip: The US Postal Zip Code of the address.
523
Zip string `json:"zip,omitempty"`
527
// Name: The name of the data source.
528
Name string `json:"name,omitempty"`
530
// Official: Whether this data comes from an official government source.
531
Official bool `json:"official,omitempty"`
534
type VoterInfoRequest struct {
535
// Address: The registered address of the voter to look up.
536
Address string `json:"address,omitempty"`
539
type VoterInfoResponse struct {
540
// Contests: Contests that will appear on the voter's ballot.
541
Contests []*Contest `json:"contests,omitempty"`
543
// DropOffLocations: Locations where a voter is eligible to drop off a
544
// completed ballot. The voter must have received and completed a ballot
545
// prior to arriving at the location. The location may not have ballots
546
// available on the premises. These locations could be open on or before
547
// election day as indicated in the pollingHours field.
548
DropOffLocations []*PollingLocation `json:"dropOffLocations,omitempty"`
550
// EarlyVoteSites: Locations where the voter is eligible to vote early,
551
// prior to election day.
552
EarlyVoteSites []*PollingLocation `json:"earlyVoteSites,omitempty"`
554
// Election: The election that was queried.
555
Election *Election `json:"election,omitempty"`
557
// Kind: Identifies what kind of resource this is. Value: the fixed
558
// string "civicinfo#voterInfoResponse".
559
Kind string `json:"kind,omitempty"`
561
// NormalizedInput: The normalized version of the requested address
562
NormalizedInput *SimpleAddressType `json:"normalizedInput,omitempty"`
564
// PollingLocations: Locations where the voter is eligible to vote on
566
PollingLocations []*PollingLocation `json:"pollingLocations,omitempty"`
568
PrecinctId string `json:"precinctId,omitempty"`
570
// State: Local Election Information for the state that the voter votes
571
// in. For the US, there will only be one element in this array.
572
State []*AdministrationRegion `json:"state,omitempty"`
574
// Status: The result of the request. One of: success,
575
// noStreetSegmentFound, addressUnparseable, noAddressParameter,
576
// multipleStreetSegmentsFound, electionOver, electionUnknown,
577
// internalLookupFailure
578
Status string `json:"status,omitempty"`
581
// method id "civicinfo.divisions.search":
583
type DivisionsSearchCall struct {
585
opt_ map[string]interface{}
588
// Search: Searches for political divisions by their natural name or OCD
590
func (r *DivisionsService) Search() *DivisionsSearchCall {
591
c := &DivisionsSearchCall{s: r.s, opt_: make(map[string]interface{})}
595
// Query sets the optional parameter "query": The search query. Queries
596
// can cover any parts of a OCD ID or a human readable division name.
597
// All words given in the query are treated as required patterns. In
598
// addition to that, most query operators of the Apache Lucene library
599
// are supported. See
600
// http://lucene.apache.org/core/2_9_4/queryparsersyntax.html
601
func (c *DivisionsSearchCall) Query(query string) *DivisionsSearchCall {
602
c.opt_["query"] = query
606
// Fields allows partial responses to be retrieved.
607
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
608
// for more information.
609
func (c *DivisionsSearchCall) Fields(s ...googleapi.Field) *DivisionsSearchCall {
610
c.opt_["fields"] = googleapi.CombineFields(s)
614
func (c *DivisionsSearchCall) Do() (*DivisionSearchResponse, error) {
615
var body io.Reader = nil
616
params := make(url.Values)
617
params.Set("alt", "json")
618
if v, ok := c.opt_["query"]; ok {
619
params.Set("query", fmt.Sprintf("%v", v))
621
if v, ok := c.opt_["fields"]; ok {
622
params.Set("fields", fmt.Sprintf("%v", v))
624
urls := googleapi.ResolveRelative(c.s.BasePath, "representatives/division_search")
625
urls += "?" + params.Encode()
626
req, _ := http.NewRequest("GET", urls, body)
627
googleapi.SetOpaque(req.URL)
628
req.Header.Set("User-Agent", "google-api-go-client/0.5")
629
res, err := c.s.client.Do(req)
633
defer googleapi.CloseBody(res)
634
if err := googleapi.CheckResponse(res); err != nil {
637
var ret *DivisionSearchResponse
638
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
643
// "description": "Searches for political divisions by their natural name or OCD ID.",
644
// "httpMethod": "GET",
645
// "id": "civicinfo.divisions.search",
648
// "description": "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",
649
// "location": "query",
653
// "path": "representatives/division_search",
655
// "$ref": "DivisionSearchResponse"
661
// method id "civicinfo.elections.electionQuery":
663
type ElectionsElectionQueryCall struct {
665
opt_ map[string]interface{}
668
// ElectionQuery: List of available elections to query.
669
func (r *ElectionsService) ElectionQuery() *ElectionsElectionQueryCall {
670
c := &ElectionsElectionQueryCall{s: r.s, opt_: make(map[string]interface{})}
674
// Fields allows partial responses to be retrieved.
675
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
676
// for more information.
677
func (c *ElectionsElectionQueryCall) Fields(s ...googleapi.Field) *ElectionsElectionQueryCall {
678
c.opt_["fields"] = googleapi.CombineFields(s)
682
func (c *ElectionsElectionQueryCall) Do() (*ElectionsQueryResponse, error) {
683
var body io.Reader = nil
684
params := make(url.Values)
685
params.Set("alt", "json")
686
if v, ok := c.opt_["fields"]; ok {
687
params.Set("fields", fmt.Sprintf("%v", v))
689
urls := googleapi.ResolveRelative(c.s.BasePath, "elections")
690
urls += "?" + params.Encode()
691
req, _ := http.NewRequest("GET", urls, body)
692
googleapi.SetOpaque(req.URL)
693
req.Header.Set("User-Agent", "google-api-go-client/0.5")
694
res, err := c.s.client.Do(req)
698
defer googleapi.CloseBody(res)
699
if err := googleapi.CheckResponse(res); err != nil {
702
var ret *ElectionsQueryResponse
703
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
708
// "description": "List of available elections to query.",
709
// "httpMethod": "GET",
710
// "id": "civicinfo.elections.electionQuery",
711
// "path": "elections",
713
// "$ref": "ElectionsQueryResponse"
719
// method id "civicinfo.elections.voterInfoQuery":
721
type ElectionsVoterInfoQueryCall struct {
724
voterinforequest *VoterInfoRequest
725
opt_ map[string]interface{}
728
// VoterInfoQuery: Looks up information relevant to a voter based on the
729
// voter's registered address.
730
func (r *ElectionsService) VoterInfoQuery(electionId int64, voterinforequest *VoterInfoRequest) *ElectionsVoterInfoQueryCall {
731
c := &ElectionsVoterInfoQueryCall{s: r.s, opt_: make(map[string]interface{})}
732
c.electionId = electionId
733
c.voterinforequest = voterinforequest
737
// OfficialOnly sets the optional parameter "officialOnly": If set to
738
// true, only data from official state sources will be returned.
739
func (c *ElectionsVoterInfoQueryCall) OfficialOnly(officialOnly bool) *ElectionsVoterInfoQueryCall {
740
c.opt_["officialOnly"] = officialOnly
744
// Fields allows partial responses to be retrieved.
745
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
746
// for more information.
747
func (c *ElectionsVoterInfoQueryCall) Fields(s ...googleapi.Field) *ElectionsVoterInfoQueryCall {
748
c.opt_["fields"] = googleapi.CombineFields(s)
752
func (c *ElectionsVoterInfoQueryCall) Do() (*VoterInfoResponse, error) {
753
var body io.Reader = nil
754
body, err := googleapi.WithoutDataWrapper.JSONReader(c.voterinforequest)
758
ctype := "application/json"
759
params := make(url.Values)
760
params.Set("alt", "json")
761
if v, ok := c.opt_["officialOnly"]; ok {
762
params.Set("officialOnly", fmt.Sprintf("%v", v))
764
if v, ok := c.opt_["fields"]; ok {
765
params.Set("fields", fmt.Sprintf("%v", v))
767
urls := googleapi.ResolveRelative(c.s.BasePath, "voterinfo/{electionId}/lookup")
768
urls += "?" + params.Encode()
769
req, _ := http.NewRequest("POST", urls, body)
770
googleapi.Expand(req.URL, map[string]string{
771
"electionId": strconv.FormatInt(c.electionId, 10),
773
req.Header.Set("Content-Type", ctype)
774
req.Header.Set("User-Agent", "google-api-go-client/0.5")
775
res, err := c.s.client.Do(req)
779
defer googleapi.CloseBody(res)
780
if err := googleapi.CheckResponse(res); err != nil {
783
var ret *VoterInfoResponse
784
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
789
// "description": "Looks up information relevant to a voter based on the voter's registered address.",
790
// "httpMethod": "POST",
791
// "id": "civicinfo.elections.voterInfoQuery",
792
// "parameterOrder": [
797
// "description": "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",
798
// "format": "int64",
799
// "location": "path",
804
// "default": "false",
805
// "description": "If set to true, only data from official state sources will be returned.",
806
// "location": "query",
810
// "path": "voterinfo/{electionId}/lookup",
812
// "$ref": "VoterInfoRequest"
815
// "$ref": "VoterInfoResponse"
821
// method id "civicinfo.representatives.representativeInfoQuery":
823
type RepresentativesRepresentativeInfoQueryCall struct {
825
representativeinforequest *RepresentativeInfoRequest
826
opt_ map[string]interface{}
829
// RepresentativeInfoQuery: Looks up political geography and
830
// representative information based on an address or Open Civic Data
831
// division identifier.
832
func (r *RepresentativesService) RepresentativeInfoQuery(representativeinforequest *RepresentativeInfoRequest) *RepresentativesRepresentativeInfoQueryCall {
833
c := &RepresentativesRepresentativeInfoQueryCall{s: r.s, opt_: make(map[string]interface{})}
834
c.representativeinforequest = representativeinforequest
838
// IncludeOffices sets the optional parameter "includeOffices": Whether
839
// to return information about offices and officials. If false, only the
840
// top-level district information will be returned.
841
func (c *RepresentativesRepresentativeInfoQueryCall) IncludeOffices(includeOffices bool) *RepresentativesRepresentativeInfoQueryCall {
842
c.opt_["includeOffices"] = includeOffices
846
// OcdId sets the optional parameter "ocdId": The division to look up.
847
// May only be specified if the address field is not given in the
849
func (c *RepresentativesRepresentativeInfoQueryCall) OcdId(ocdId string) *RepresentativesRepresentativeInfoQueryCall {
850
c.opt_["ocdId"] = ocdId
854
// Recursive sets the optional parameter "recursive": When ocd_id is
855
// supplied, return all divisions which are hierarchically nested within
856
// the queried division. For example, if querying
857
// ocd-division/country:us/district:dc, this would also return all DC's
859
func (c *RepresentativesRepresentativeInfoQueryCall) Recursive(recursive bool) *RepresentativesRepresentativeInfoQueryCall {
860
c.opt_["recursive"] = recursive
864
// Fields allows partial responses to be retrieved.
865
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
866
// for more information.
867
func (c *RepresentativesRepresentativeInfoQueryCall) Fields(s ...googleapi.Field) *RepresentativesRepresentativeInfoQueryCall {
868
c.opt_["fields"] = googleapi.CombineFields(s)
872
func (c *RepresentativesRepresentativeInfoQueryCall) Do() (*RepresentativeInfoResponse, error) {
873
var body io.Reader = nil
874
body, err := googleapi.WithoutDataWrapper.JSONReader(c.representativeinforequest)
878
ctype := "application/json"
879
params := make(url.Values)
880
params.Set("alt", "json")
881
if v, ok := c.opt_["includeOffices"]; ok {
882
params.Set("includeOffices", fmt.Sprintf("%v", v))
884
if v, ok := c.opt_["ocdId"]; ok {
885
params.Set("ocdId", fmt.Sprintf("%v", v))
887
if v, ok := c.opt_["recursive"]; ok {
888
params.Set("recursive", fmt.Sprintf("%v", v))
890
if v, ok := c.opt_["fields"]; ok {
891
params.Set("fields", fmt.Sprintf("%v", v))
893
urls := googleapi.ResolveRelative(c.s.BasePath, "representatives/lookup")
894
urls += "?" + params.Encode()
895
req, _ := http.NewRequest("POST", urls, body)
896
googleapi.SetOpaque(req.URL)
897
req.Header.Set("Content-Type", ctype)
898
req.Header.Set("User-Agent", "google-api-go-client/0.5")
899
res, err := c.s.client.Do(req)
903
defer googleapi.CloseBody(res)
904
if err := googleapi.CheckResponse(res); err != nil {
907
var ret *RepresentativeInfoResponse
908
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
913
// "description": "Looks up political geography and representative information based on an address or Open Civic Data division identifier.",
914
// "httpMethod": "POST",
915
// "id": "civicinfo.representatives.representativeInfoQuery",
917
// "includeOffices": {
918
// "default": "true",
919
// "description": "Whether to return information about offices and officials. If false, only the top-level district information will be returned.",
920
// "location": "query",
924
// "description": "The division to look up. May only be specified if the address field is not given in the request body.",
925
// "location": "query",
929
// "default": "false",
930
// "description": "When ocd_id is supplied, return all divisions which are hierarchically nested within the queried division. For example, if querying ocd-division/country:us/district:dc, this would also return all DC's wards and ANCs.",
931
// "location": "query",
935
// "path": "representatives/lookup",
937
// "$ref": "RepresentativeInfoRequest"
940
// "$ref": "RepresentativeInfoResponse"