From 581fa42715d309c834de4b62f899d9239ec53e53 Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 27 Apr 2023 14:23:14 -0400 Subject: [PATCH] Refactored \TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent and added - \TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent::setPhoneNumber - \TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent::setFirstName - \TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent::setLastName - \TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent::setVcard https://git.n64.cc/nosial/libs/tgbot/-/issues/3 --- .../InputContactMessageContent.php | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/TgBotLib/Objects/Telegram/InputMessageContent/InputContactMessageContent.php b/src/TgBotLib/Objects/Telegram/InputMessageContent/InputContactMessageContent.php index 0ad7757..762c324 100644 --- a/src/TgBotLib/Objects/Telegram/InputMessageContent/InputContactMessageContent.php +++ b/src/TgBotLib/Objects/Telegram/InputMessageContent/InputContactMessageContent.php @@ -1,9 +1,12 @@ phone_number; } + /** + * Sets the value of 'phone_number' property + * Contact's phone number + * + * @param string $phone_number + * @return $this + */ + public function setPhoneNumber(string $phone_number): self + { + if(!Validate::length($phone_number, 1, 255)) + throw new InvalidArgumentException('phone_number should be between 1-255 characters'); + + $this->phone_number = $phone_number; + return $this; + } + /** * Contact's first name * @@ -48,6 +67,22 @@ return $this->first_name; } + /** + * Sets the value of 'first_name' property + * Contact's first name + * + * @param string $first_name + * @return $this + */ + public function setFirstName(string $first_name): self + { + if(!Validate::length($first_name, 1, 255)) + throw new InvalidArgumentException('first_name should be between 1-255 characters'); + + $this->first_name = $first_name; + return $this; + } + /** * Optional. Contact's last name * @@ -58,6 +93,28 @@ return $this->last_name; } + /** + * Sets the value of 'last_name' property + * Optional. Contact's last name + * + * @param string|null $last_name + * @return InputContactMessageContent + */ + public function setLastName(?string $last_name): self + { + if($last_name == null) + { + $this->last_name = null; + return $this; + } + + if(!Validate::length($last_name, 1, 255)) + throw new InvalidArgumentException('last_name should be between 1-255 characters (or null)'); + + $this->last_name = $last_name; + return $this; + } + /** * Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes * @@ -69,6 +126,28 @@ return $this->vcard; } + /** + * Sets the value of 'vcard' property + * Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + * + * @param string|null $vcard + * @return InputContactMessageContent + */ + public function setVcard(?string $vcard): self + { + if($vcard == null) + { + $this->vcard = null; + return $this; + } + + if(!Validate::length($vcard, 1, 2048)) + throw new InvalidArgumentException('vcard should be between 1-2048 characters (or null)'); + + $this->vcard = $vcard; + return $this; + } + /** * Returns an array representation of the object *