voterInfoQuery method

Future<VoterInfoResponse> voterInfoQuery({
  1. String? address,
  2. String? electionId,
  3. bool? officialOnly,
  4. bool? productionDataOnly,
  5. bool? returnAllAvailableData,
  6. String? $fields,
})

Looks up information relevant to a voter based on the voter's registered address.

Request parameters:

address - The registered address of the voter to look up.

electionId - 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. If no election ID is specified in the query and there is more than one election with data for the given voter, the additional elections are provided in the otherElections response field.

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

productionDataOnly - Whether to include data that has not been vetted yet. Should only be made available to internal IPs or trusted partners. This is a non-discoverable parameter in the One Platform API config.

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

$fields - Selector specifying which fields to include in a partial response.

Completes with a VoterInfoResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<VoterInfoResponse> voterInfoQuery({
  core.String? address,
  core.String? electionId,
  core.bool? officialOnly,
  core.bool? productionDataOnly,
  core.bool? returnAllAvailableData,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (address != null) 'address': [address],
    if (electionId != null) 'electionId': [electionId],
    if (officialOnly != null) 'officialOnly': ['${officialOnly}'],
    if (productionDataOnly != null)
      'productionDataOnly': ['${productionDataOnly}'],
    if (returnAllAvailableData != null)
      'returnAllAvailableData': ['${returnAllAvailableData}'],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'civicinfo/v2/voterinfo';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return VoterInfoResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}