setChannelActiveStatus method
Set the active status of a channel.
-
{channel} is the channel that you want to set the active status. Currently, only "line", and "facebook" are supported.
-
{status} is the active status of the channel. True means the channel is active, false means the channel is inactive.
Implementation
Future<void> setChannelActiveStatus({
required String channel,
required bool status,
}) async {
try {
if (_bot.id == null) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[setChannelActiveStatus] : bot '${_bot.botName}' doesn't have an id, try reloading it");
return;
}
Uri url = Uri.parse("${GetIt.I<BotnoiClient>().endpoint}/developer/platform-api/bot/channel-active-status");
http.Response response = await http.put(
url,
headers: _getHeader,
body: jsonEncode({
"bot_id": _bot.id,
"channel": channel,
"status": status,
}),
);
if (response.statusCode == 200 || response.statusCode == 204 || response.statusCode == 201) {
GetIt.I<BotnoiClient>().finishedSuccessfully();
return;
}
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[setChannelActiveStatus] : ${response.reasonPhrase ?? "ERROR"}");
} catch (e) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add("[setChannelActiveStatus] : $e");
}
}