editMessageLiveLocation method

Future<Message> editMessageLiveLocation(
  1. double latitude,
  2. double longitude, {
  3. dynamic chatId,
  4. int? messageId,
  5. String? inlineMessageId,
  6. double? horizontalAccuracy,
  7. int? heading,
  8. int? proximityAlertRadius,
  9. ReplyMarkup? replyMarkup,
})

Use this method to edit live location messages sent by the bot or via the bot (for inline bots).

A location can be edited until its livePeriod expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.

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

Implementation

Future<Message> editMessageLiveLocation(double latitude, double longitude,
    {dynamic chatId,
    int? messageId,
    String? inlineMessageId,
    double? horizontalAccuracy,
    int? heading,
    int? proximityAlertRadius,
    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('editMessageLiveLocation');
  var body = <String, dynamic>{
    'latitude': latitude,
    'longitude': longitude,
    'chat_id': chatId,
    'message_id': messageId,
    'inline_message_id': inlineMessageId,
    'horizontal_accuracy': horizontalAccuracy,
    'heading': heading,
    'proximity_alert_radius': proximityAlertRadius,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}