getDevices method
Implementation
@override
Future<Devices> getDevices(
{int limit = 0, int offset = 0, String keyword = ''}) async {
try {
return await dio
.get(ApiEndpoints.DEVICES,
queryParameters: {
'limit': limit,
'offset': offset,
'search': keyword
},
options: Options(
validateStatus: (status) => status == 200 || status == 404))
.then((value) {
try {
return Devices.fromJson(value.data);
} catch (e) {
logger.error(TAG, e.toString(), {'method': 'getDevices'});
}
return Devices(list: []);
});
} on Exception catch (e) {
throw HttpHelper.decodeErrorResponse(e,
tag: TAG,
logger: logger,
defaultErrorMessage: 'Failed to get devices',
meta: {'method': 'getDevices'});
}
}