electionQuery method

Future<ElectionsQueryResponse> electionQuery({
  1. bool? productionDataOnly,
  2. String? $fields,
})

List of available elections to query.

Request parameters:

productionDataOnly - Whether to include data that has not been allowlisted yet

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

Completes with a ElectionsQueryResponse.

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<ElectionsQueryResponse> electionQuery({
  core.bool? productionDataOnly,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (productionDataOnly != null)
      'productionDataOnly': ['${productionDataOnly}'],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'civicinfo/v2/elections';

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