updateIntent method
Update an intent of this bot.
{intent} is the updated version of the intent that you want to update (intent's id must not be changed).
Implementation
Future<void> updateIntent({
required BotIntent intent,
}) async {
try {
if (intent.id == null) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("this intent has no id");
return;
}
intent.belongTo(_bot);
Uri url = Uri.parse("${GetIt.I<BotnoiClient>().endpoint}/developer/platform-api/intent");
http.Response response = await http.put(
url,
headers: _getHeader,
body: jsonEncode(intent.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());
}
}