createIntent method
Create a new intent for this bot.
{intent} is the intent that you want to create.
Implementation
Future<void> createIntent({
required BotIntent intent,
}) async {
try {
intent.belongTo(_bot);
Uri url = Uri.parse("${GetIt.I<BotnoiClient>().endpoint}/developer/platform-api/intent");
http.Response response = await http.post(
url,
headers: _getHeader,
body: jsonEncode(intent.toJson()),
);
if (response.statusCode == 201) {
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());
}
}