sendContact method

Future<Message> sendContact(
  1. dynamic chatId,
  2. String phoneNumber,
  3. String firstName, {
  4. int? messageThreadId,
  5. String? lastName,
  6. String? vcard,
  7. bool? disableNotification,
  8. bool? protectContent,
  9. int? replyToMessageId,
  10. bool? allowSendingWithoutReply,
  11. ReplyMarkup? replyMarkup,
})

Use this method to send phone contacts

On success, the sent Message is returned.

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

Implementation

Future<Message> sendContact(
    dynamic chatId, String phoneNumber, String firstName,
    {int? messageThreadId,
    String? lastName,
    String? vcard,
    bool? disableNotification,
    bool? protectContent,
    int? replyToMessageId,
    bool? allowSendingWithoutReply,
    ReplyMarkup? replyMarkup}) 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('sendContact');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_thread_id': messageThreadId,
    'phone_number': phoneNumber,
    'first_name': firstName,
    'last_name': lastName,
    'vcard': vcard,
    'disable_notification': disableNotification,
    'protect_content': protectContent,
    'reply_to_message_id': replyToMessageId,
    'allow_sending_without_reply': allowSendingWithoutReply,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}