getDeviceById method
Implementation
@override
Future<Devices> getDeviceById(String id) async {
try {
return await dio
.get('${ApiEndpoints.DEVICES}/$id',
options: Options(
validateStatus: (status) => status == 200 || status == 404))
.then((value) {
try {
return Devices.fromJson(value.data);
} catch (e) {
logger.error(TAG, e.toString(), {'method': 'getDeviceById'});
}
return Devices(list: []);
});
} on Exception catch (e) {
throw HttpHelper.decodeErrorResponse(e,
tag: TAG,
logger: logger,
defaultErrorMessage: 'Failed to get a device by id',
meta: {'id': id, 'method': 'getDeviceById'});
}
}