deleteBot method
Delete a bot in this botnoi chatbot server.
- {bot} is the bot that you want to delete.
Implementation
Future<void> deleteBot({
required Bot bot,
}) async {
try {
if (bot.id == null) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[deleteBot] : bot ${bot.botName} doesn't have an id, try reloading it");
return;
}
Uri url = Uri.parse("${GetIt.I<BotnoiClient>().endpoint}/developer/platform-api/bot");
http.Response response = await http.delete(
url,
headers: _getHeader,
body: jsonEncode(bot.toJson()),
);
if (response.statusCode == 200 || response.statusCode == 204) {
GetIt.I<BotnoiClient>().finishedSuccessfully();
return;
}
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[deleteBot] : ${response.reasonPhrase ?? "ERROR"}");
} catch (e) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[deleteBot] : $e");
}
}