getDeviceDetails method
Future<GetDeviceDetailsResponseDto>
getDeviceDetails(
- String apiKey, {
- required String deviceId,
- required GetDeviceDetailsRequestDto getDeviceDetailsRequestDto,
Implementation
Future<GetDeviceDetailsResponseDto> getDeviceDetails(
String apiKey, {
required String deviceId,
required GetDeviceDetailsRequestDto getDeviceDetailsRequestDto,
}) async {
final String url = '$channel/api/v1/mdm/devices/$deviceId';
// need to remove null values from the request
final requestDto = getDeviceDetailsRequestDto.toJson();
requestDto.removeWhere((key, value) => value == null);
final response = await http.get(
Uri.parse(url).replace(
queryParameters: requestDto.isEmpty ? null : 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 GetDeviceDetailsResponseDto.fromJson(
jsonDecode(response.body) as Map<String, dynamic>,
);
}