stopMessageLiveLocation method

Future<Message> stopMessageLiveLocation({
  1. dynamic chatId,
  2. int? messageId,
  3. String? inlineMessageId,
  4. ReplyMarkup? replyMarkup,
})

Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before livePeriod expires.

On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.

https://core.telegram.org/bots/api#stopmessagelivelocation

Implementation

Future<Message> stopMessageLiveLocation(
    {dynamic chatId,
    int? messageId,
    String? inlineMessageId,
    ReplyMarkup? replyMarkup}) async {
  if (inlineMessageId == null && (chatId == null || messageId == null)) {
    return Future.error(TelegramException(
        'Require either \'chatId\' and \'messageId\', or \'inlineMessageId\''));
  }
  if (chatId != null && (chatId is! String && chatId is! int)) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('stopMessageLiveLocation');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_id': messageId,
    'inline_message_id': inlineMessageId,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}