getDeviceLocationWithAddress method
Future<GetDeviceLocationWithAddressReponseDto>
getDeviceLocationWithAddress(
- String apiKey, {
- required String deviceId,
- required GetDeviceLocationWithAddressRequestDto getDeviceLocationWithAddressRequestDto,
Implementation
Future<GetDeviceLocationWithAddressReponseDto> getDeviceLocationWithAddress(
String apiKey, {
required String deviceId,
required GetDeviceLocationWithAddressRequestDto
getDeviceLocationWithAddressRequestDto,
}) async {
final String url =
'$channel/api/v1/mdm/devices/$deviceId/locations_with_address';
// need to remove null values from the request
final requestDto = getDeviceLocationWithAddressRequestDto.toJson();
requestDto.removeWhere((key, value) => value == null);
final response = await http.post(
Uri.parse(url).replace(
queryParameters: requestDto,
),
headers: {
'Authorization': 'Zoho-oauthtoken $apiKey',
'Content-Type': 'application/json;charset=UTF-8',
},
);
if (!response.statusCode.isSuccessful) {
throw MdmEngineException(
method: response.request?.method,
url: url,
statusCode: response.statusCode,
error: response.body,
);
}
return GetDeviceLocationWithAddressReponseDto.fromJson(
jsonDecode(response.body) as Map<String, dynamic>,
);
}