representativeInfoByDivision method

Future<RepresentativeInfoData> representativeInfoByDivision(
  1. String ocdId, {
  2. List<String>? levels,
  3. bool? recursive,
  4. List<String>? roles,
  5. String? $fields,
})

Looks up representative information for a single geographic division.

Request parameters:

ocdId - The Open Civic Data division identifier of the division to look up.

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.

recursive - If true, information about all divisions contained in the division requested will be included as well. For example, if querying ocd-division/country:us/district:dc, this would also return all DC's wards and ANCs.

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 RepresentativeInfoData.

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

  final url_ =
      'civicinfo/v2/representatives/' + commons.escapeVariable('$ocdId');

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