Source code for peyk.platforms.rubika.methods.send_contact

from __future__ import annotations
from typing import Any, Dict, List, Optional, Tuple, Union
from peyk.transport import run_with_retry
from ..errors import RubikaAPIError, error_for_envelope
from ..models import ChatTypeEnum, FileTypeEnum, ForwardedFromEnum, PollStatusEnum, ButtonSelectionTypeEnum, ButtonSelectionSearchEnum, ButtonSelectionGetEnum, ButtonCalendarTypeEnum, ButtonTextboxTypeKeypadEnum, ButtonTextboxTypeLineEnum, ButtonLocationTypeEnum, MessageSenderEnum, UpdateTypeEnum, ChatKeypadTypeEnum, UpdateEndpointTypeEnum, MetadataTypeEnum, EnumChatAccess, EventTypeEnum, EventJoinTypeEnum, ButtonTypeEnum, File, Location, Chat, Bot, BotCommand, Sticker, ContactMessage, PollStatus, Poll, ForwardedFrom, AuxData, MetadataPart, Metadata, ButtonSelectionItem, ButtonSelection, ButtonCalendar, ButtonNumberPicker, ButtonStringPicker, ButtonTextbox, ButtonLocation, Button, KeypadRow, Keypad, Message, Event, Update, InlineMessage, GetUpdatesResult

[docs] async def send_contact(self, chat_id: str, first_name: str, last_name: str, phone_number: str, *, chat_keypad: Optional[Union[Keypad, Dict[str, object]]]=None, inline_keypad: Optional[Union[Keypad, Dict[str, object]]]=None, chat_keypad_type: Optional[str]=None, reply_to_message_id: Optional[str]=None, disable_notification: Optional[bool]=None) -> Message: """Sends contact through the Rubika API. Args: chat_id: Identifier of the target chat. first_name: Value used by this operation. last_name: Value used by this operation. phone_number: Value used by this operation. chat_keypad: Value used by this operation. inline_keypad: Value used by this operation. chat_keypad_type: Value used by this operation. reply_to_message_id: Value used by this operation. disable_notification: Value used by this operation. Returns: Result produced by the Rubika operation.""" '"""Rubika client operation ``send_contact``.\n\nArgs:\n chat_id: Value accepted by this operation.\n first_name: Value accepted by this operation.\n last_name: Value accepted by this operation.\n phone_number: Value accepted by this operation.\n chat_keypad: Value accepted by this operation.\n inline_keypad: Value accepted by this operation.\n chat_keypad_type: Value accepted by this operation.\n reply_to_message_id: Value accepted by this operation.\n disable_notification: Value accepted by this operation.\n\nReturns:\n Message: The value returned by the Rubika API or the local helper.\n\nRaises:\n RubikaAPIError: If the Rubika API rejects the request or returns an invalid response.\n"""' payload: Dict[str, object] = {'chat_id': chat_id, 'first_name': first_name, 'last_name': last_name, 'phone_number': phone_number} kp = self._keypad_to_dict(chat_keypad) if kp is not None: payload['chat_keypad'] = kp ikp = self._keypad_to_dict(inline_keypad) if ikp is not None: payload['inline_keypad'] = ikp if chat_keypad_type is not None: payload['chat_keypad_type'] = chat_keypad_type if reply_to_message_id is not None: payload['reply_to_message_id'] = reply_to_message_id if disable_notification is not None: payload['disable_notification'] = disable_notification data = await self._call('sendContact', json_body=payload) return self._parse_message_id_response(data, 'sendContact')