delete<T> static method
Implementation
static Future<T> delete<T>({
required String from,
required T Function(Map<String, dynamic> response) onSuccess,
}) async {
AILogger.log("starting request to $from");
final http.Response response = await http.delete(
Uri.parse(from),
headers: AIConfigBuilder.instance.headers(),
);
AILogger.log(
"request to $from finished with status code ${response.statusCode}");
AILogger.log("starting decoding response body");
final Map<String, dynamic> decodedBody =
jsonDecode(response.body) as Map<String, dynamic>;
AILogger.log("response body decoded successfully");
if (decodedBody['error'] != null) {
AILogger.log("an error occurred, throwing exception");
final Map<String, dynamic> error = decodedBody['error'];
throw AIRequestException(
error["message"],
response.statusCode,
);
} else {
AILogger.log("request finished successfully");
return onSuccess(decodedBody);
}
}