deleteBot method

Future<void> deleteBot({
  1. required Bot bot,
})

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("This intent has no id");
      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(response.reasonPhrase ?? "ERROR");
  } catch (e) {
    GetIt.I<BotnoiClient>().finishedFailed();
    GetIt.I<BotnoiClient>().error.add(e.toString());
  }
}