removeGalleryItem static method
Implementation
static Future<Map<String, String>> removeGalleryItem(int locationId, int mediaId) async {
bool isTokenValid = await AuthService.validateToken();
if (isTokenValid) {
final res = await httpClient.delete(Config.getURI('/locations/$locationId/medias/$mediaId.json'));
debugPrint('[DEBUG]: statusCode ${res.statusCode}');
debugPrint('[DEBUG]: Body ${res.body}');
String error = '';
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': 'Media removed'};
}
return {'status': 'failed', 'message': 'An error occured. Please login again.'};
}