From 1b569e4972ffdb59226e9e88a586a126eb4928a6 Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 23 Apr 2023 15:02:03 -0400 Subject: [PATCH] Added object `\TgBotLib\Objects\Telegram > InputContactMessageContent` to represent the content of a contact message to be sent as the result of an inline query. --- CHANGELOG.md | 1 + .../Telegram/InputContactMessageContent.php | 104 ++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/InputContactMessageContent.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 64eb6d5..2d9ca4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This update accompanies the release of the [Telegram Bot API 6.7](https://core.t * Added object `\TgBotLib\Objects\Telegram > InputTextMessageContent` to represent the content of a text message to be sent as the result of an inline query. * Added object `\TgBotLib\Objects\Telegram > InputLocationMessageContent` to represent the content of a location message to be sent as the result of an inline query. * Added object `\TgBotLib\Objects\Telegram > InputVenueMessageContent` to represent the content of a venue message to be sent as the result of an inline query. + * Added object `\TgBotLib\Objects\Telegram > InputContactMessageContent` to represent the content of a contact message to be sent as the result of an inline query. ## [6.6.0] - 2023-04-10 diff --git a/src/TgBotLib/Objects/Telegram/InputContactMessageContent.php b/src/TgBotLib/Objects/Telegram/InputContactMessageContent.php new file mode 100644 index 0000000..4ea4daa --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/InputContactMessageContent.php @@ -0,0 +1,104 @@ +phone_number; + } + + /** + * Contact's first name + * + * @return string + */ + public function getFirstName(): string + { + return $this->first_name; + } + + /** + * Optional. Contact's last name + * + * @return string|null + */ + public function getLastName(): ?string + { + return $this->last_name; + } + + /** + * Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + * + * @see https://en.wikipedia.org/wiki/VCard + * @return string|null + */ + public function getVcard(): ?string + { + return $this->vcard; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'phone_number' => $this->phone_number, + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'vcard' => $this->vcard, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->phone_number = $data['phone_number'] ?? null; + $object->first_name = $data['first_name'] ?? null; + $object->last_name = $data['last_name'] ?? null; + $object->vcard = $data['vcard'] ?? null; + + return $object; + } + } \ No newline at end of file