representativeInfoByAddress method

Future<RepresentativeInfoResponse> representativeInfoByAddress({
  1. String? address,
  2. bool? includeOffices,
  3. List<String>? levels,
  4. List<String>? roles,
  5. String? $fields,
})

Looks up political geography and representative information for a single address.

Request parameters:

address - The address to look up. May only be specified if the field ocdId is not given in the URL

includeOffices - Whether to return information about offices and officials. If false, only the top-level district information will be returned.

levels - A list of office levels to filter by. Only offices that serve at least one of these levels will be returned. Divisions that don't contain a matching office will not be returned.

roles - A list of office roles to filter by. Only offices fulfilling one of these roles will be returned. Divisions that don't contain a matching office will not be returned.

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

Completes with a RepresentativeInfoResponse.

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<RepresentativeInfoResponse> representativeInfoByAddress({
  core.String? address,
  core.bool? includeOffices,
  core.List<core.String>? levels,
  core.List<core.String>? roles,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (address != null) 'address': [address],
    if (includeOffices != null) 'includeOffices': ['${includeOffices}'],
    if (levels != null) 'levels': levels,
    if (roles != null) 'roles': roles,
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'civicinfo/v2/representatives';

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