search method

Future<DivisionSearchResponse> search({
  1. String? query,
  2. String? $fields,
})

Searches for political divisions by their natural name or OCD ID.

Request parameters:

query - 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

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

Completes with a DivisionSearchResponse.

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

  const url_ = 'civicinfo/v2/divisions';

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