removePractice static method
Implementation
static Future<Map<String, String>> removePractice(int practiceId) async {
bool isTokenValid = await AuthService.validateToken();
if (isTokenValid) {
final res = await httpClient.delete(Config.getURI('/practices/$practiceId.json'));
debugPrint('[DEBUG]: statusCode ${res.statusCode}');
debugPrint('[DEBUG]: Body ${res.body}');
String error = 'Generic Error. Please try again.';
if (res.body.isNotEmpty) {
dynamic message = json.decode(res.body);
error = message['error'] ? message['error'].toString().replaceAll('{', '').replaceAll('}', '') : '';
}
if (res.statusCode >= 400) return {'status': 'failed', 'message': error};
return {'status': 'success', 'message': 'Practice removed'};
}
return {'status': 'failed', 'message': 'An error occured. Please login again.'};
}