sendContact method

Future<Message> sendContact(
  1. dynamic chat_id,
  2. String phone_number,
  3. String first_name, {
  4. String? last_name,
  5. String? vcard,
  6. bool? disable_notification,
  7. int? reply_to_message_id,
  8. bool? allow_sending_without_reply,
  9. ReplyMarkup? reply_markup,
})
inherited

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 chat_id, String phone_number, String first_name,
    {String? last_name,
    String? vcard,
    bool? disable_notification,
    int? reply_to_message_id,
    bool? allow_sending_without_reply,
    ReplyMarkup? reply_markup}) async {
  if (chat_id is! String && chat_id is! int) {
    return Future.error(TelegramException(
        'Attribute \'chat_id\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('sendContact');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'phone_number': phone_number,
    'first_name': first_name,
    'last_name': last_name,
    'vcard': vcard,
    'disable_notification': disable_notification,
    'reply_to_message_id': reply_to_message_id,
    'allow_sending_without_reply': allow_sending_without_reply,
    'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}