editChatInviteLink method

Future<ChatInviteLink> editChatInviteLink(
  1. dynamic chatId,
  2. String inviteLink, {
  3. String? name,
  4. int? expireDate,
  5. int? memberLimit,
  6. bool? createsJoinRequest,
})

Use this method to edit a non-primary invite link created by the bot

The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

Returns the edited invite link as a ChatInviteLink object.

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

Implementation

Future<ChatInviteLink> editChatInviteLink(dynamic chatId, String inviteLink,
    {String? name,
    int? expireDate,
    int? memberLimit,
    bool? createsJoinRequest}) async {
  if (chatId is! String && chatId is! int) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('editChatInviteLink');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'invite_link': inviteLink,
    'name': name,
    'expire_date': expireDate,
    'member_limit': memberLimit,
    'creates_join_request': createsJoinRequest,
  };
  return ChatInviteLink.fromJson(
      await HttpClient.httpPost(requestUrl, body: body));
}