geolocate method

Future<Response<GeolocationResponse>> geolocate({
  1. GeolocationRequest? geolocationRequest,
  2. CancelToken? cancelToken,
  3. Map<String, dynamic>? headers,
  4. Map<String, dynamic>? extra,
  5. ValidateStatus? validateStatus,
  6. ProgressCallback? onSendProgress,
  7. ProgressCallback? onReceiveProgress,
})

Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect. This document describes the protocol used to send this data to the server and to return a response to the client. Communication is done over HTTPS using POST. Both request and response are formatted as JSON, and the content type of both is application/json. You must specify a key in your request, included as the value of akey parameter. A key is your application's API key. This key identifies your application for purposes of quota management. Learn how to get a key.

Implementation

Future<Response<GeolocationResponse>> geolocate({
  GeolocationRequest? geolocationRequest,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _request = RequestOptions(
    path: r'/geolocation/v1/geolocate',
    method: 'POST',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'apiKey',
          'name': 'ApiKeyAuth',
          'keyName': 'key',
          'where': 'query',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
    contentType: 'application/json',
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  dynamic _bodyData;

  const _type = FullType(GeolocationRequest);
  _bodyData =
      _serializers.serialize(geolocationRequest, specifiedType: _type);

  final _response = await _dio.request<dynamic>(
    _request.path,
    data: _bodyData,
    options: Options(
      method: _request.method,
      sendTimeout: _request.sendTimeout,
      receiveTimeout: _request.receiveTimeout,
      extra: _request.extra,
      headers: _request.headers,
      responseType: _request.responseType,
      contentType: _request.contentType,
      validateStatus: _request.validateStatus,
      receiveDataWhenStatusError: _request.receiveDataWhenStatusError,
      followRedirects: _request.followRedirects,
      maxRedirects: _request.maxRedirects,
      requestEncoder: _request.requestEncoder,
      listFormat: _request.listFormat,
    ),
  );

  const _responseType = FullType(GeolocationResponse);
  final _responseData = _serializers.deserialize(
    _response.data,
    specifiedType: _responseType,
  ) as GeolocationResponse?;

  return Response<GeolocationResponse>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}