From d0219425c1f696025aca8c05f84e6ed8524f97d2 Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 27 Apr 2023 16:18:29 -0400 Subject: [PATCH] Added new methods to \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setTitle - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setDescription - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setPayload - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setProviderToken - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setCurrency - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::addPrice - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::clearPrices - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setMaxTipAmount - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setSuggestionsTipAmounts - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setProviderData - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setPhotoUrl - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setPhotoSize - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setPhotoWidth - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setPhotoHeight - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setNeedName - jetbrains://php-storm/navigate/reference?project=tgbot&fqn=\TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setNeedPhoneNumber - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setNeedEmail - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setNeedShippingAddress - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setSendPhoneNumberToProvider - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setSendEmailToProvider - \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::setIsFlexible Renamed \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::isIsFlexible to \TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent::isFlexible https://git.n64.cc/nosial/libs/tgbot/-/issues/3 --- .../InputInvoiceMessageContent.php | 324 +++++++++++++++++- 1 file changed, 322 insertions(+), 2 deletions(-) diff --git a/src/TgBotLib/Objects/Telegram/InputMessageContent/InputInvoiceMessageContent.php b/src/TgBotLib/Objects/Telegram/InputMessageContent/InputInvoiceMessageContent.php index 0a6fb56..7ed7f9b 100644 --- a/src/TgBotLib/Objects/Telegram/InputMessageContent/InputInvoiceMessageContent.php +++ b/src/TgBotLib/Objects/Telegram/InputMessageContent/InputInvoiceMessageContent.php @@ -5,10 +5,12 @@ namespace TgBotLib\Objects\Telegram\InputMessageContent; + use InvalidArgumentException; + use TgBotLib\Classes\Validate; use TgBotLib\Interfaces\ObjectTypeInterface; use TgBotLib\Objects\Telegram\LabeledPrice; - class InputInvoiceMessageContent implements \TgBotLib\Interfaces\ObjectTypeInterface + class InputInvoiceMessageContent implements ObjectTypeInterface { /** * @var string @@ -120,6 +122,22 @@ return $this->title; } + /** + * Sets the value of 'title' property + * Product name, 1-32 characters + * + * @param string $title + * @return $this + */ + public function setTitle(string $title): self + { + if(!Validate::length($title, 1, 32)) + throw new InvalidArgumentException('title should be between 1-32 characters'); + + $this->title = $title; + return $this; + } + /** * Product description, 1-255 characters * @@ -130,6 +148,22 @@ return $this->description; } + /** + * Sets the value of 'description' property + * Product description, 1-255 characters + * + * @param string $description + * @return $this + */ + public function setDescription(string $description): self + { + if(!Validate::length($description, 1, 255)) + throw new InvalidArgumentException('description should be between 1-255 characters'); + + $this->description = $description; + return $this; + } + /** * Bot-defined invoice payload, 1-128 bytes. * This will not be displayed to the user, use for your internal processes. @@ -141,6 +175,22 @@ return $this->payload; } + /** + * Set's the value of 'payload' property + * Bot-defined invoice payload, 1-128 bytes. + * + * @param string $payload + * @return $this + */ + public function setPayload(string $payload): self + { + if(!Validate::length($payload, 1, 128)) + throw new InvalidArgumentException('payload should be between 1-128 characters'); + + $this->payload = $payload; + return $this; + } + /** * Payment provider token, obtained via @BotFather * @@ -152,6 +202,19 @@ return $this->provider_token; } + /** + * Sets the value of 'provider_token' property + * Payment provider token, obtained via @BotFather + * + * @param string $provider_token + * @return $this + */ + public function setProviderToken(string $provider_token): self + { + $this->provider_token = $provider_token; + return $this; + } + /** * Three-letter ISO 4217 currency code * @@ -163,6 +226,22 @@ return $this->currency; } + /** + * Sets the value of 'currency' property + * Three-letter ISO 4217 currency code, see more on currencies + * + * @param string $currency + * @return $this + */ + public function setCurrency(string $currency): self + { + if(!Validate::length($currency, 3, 3)) + throw new InvalidArgumentException('currency should be 3 characters'); + + $this->currency = $currency; + return $this; + } + /** * Price breakdown, a JSON-serialized list of components * (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) @@ -174,6 +253,29 @@ return $this->prices; } + /** + * Adds a price to the list of prices + * + * @param LabeledPrice $price + * @return $this + */ + public function addPrice(LabeledPrice $price): self + { + $this->prices[] = $price; + return $this; + } + + /** + * Clears the current list of prices + * + * @return $this + */ + public function clearPrices(): self + { + $this->prices = []; + return $this; + } + /** * Optional. The maximum accepted amount for tips in the smallest units of the currency * (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the @@ -187,6 +289,22 @@ return $this->max_tip_amount; } + /** + * Sets the value of 'max_tip_amount' property + * Optional. The maximum accepted amount for tips in the smallest units of the currency + * (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the + * exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency + * (2 for the majority of currencies). Defaults to 0 + * + * @param int $max_tip_amount + * @return $this + */ + public function setMaxTipAmount(int $max_tip_amount): self + { + $this->max_tip_amount = $max_tip_amount; + return $this; + } + /** * Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency * (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts @@ -199,6 +317,21 @@ return $this->suggested_tip_amounts; } + /** + * Sets the value of 'suggested_tip_amounts' property + * Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency + * (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts + * must be positive, passed in a strictly increased order and must not exceed max_tip_amount. + * + * @param array $suggested_tip_amounts + * @return $this + */ + public function setSuggestionsTipAmounts(array $suggested_tip_amounts): self + { + $this->suggested_tip_amounts = $suggested_tip_amounts; + return $this; + } + /** * Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. * A detailed description of the required fields should be provided by the payment provider. @@ -210,6 +343,26 @@ return $this->provider_data; } + /** + * Sets the value of 'provider_data' property + * Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. + * A detailed description of the required fields should be provided by the payment provider. + * + * @param string|null $provider_data + * @return $this + */ + public function setProviderData(?string $provider_data): self + { + if($provider_data === null) + { + $this->provider_data = null; + return $this; + } + + $this->provider_data = $provider_data; + return $this; + } + /** * Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. * @@ -220,6 +373,25 @@ return $this->photo_url; } + /** + * Sets the value of 'photo_url' property + * Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. + * + * @param string|null $photo_url + * @return $this + */ + public function setPhotoUrl(?string $photo_url): self + { + if($photo_url === null) + { + $this->photo_url = null; + return $this; + } + + $this->photo_url = $photo_url; + return $this; + } + /** * Optional. Photo size in bytes * @@ -230,6 +402,25 @@ return $this->photo_size; } + /** + * Sets the value of 'photo_size' property + * Optional. Photo size in bytes + * + * @param int|null $photo_size + * @return $this + */ + public function setPhotoSize(?int $photo_size): self + { + if($photo_size === null) + { + $this->photo_size = null; + return $this; + } + + $this->photo_size = $photo_size; + return $this; + } + /** * Optional. Photo width * @@ -240,6 +431,25 @@ return $this->photo_width; } + /** + * Sets the value of 'photo_width' property + * Optional. Photo width + * + * @param int|null $photo_width + * @return $this + */ + public function setPhotoWidth(?int $photo_width): self + { + if($photo_width === null) + { + $this->photo_width = null; + return $this; + } + + $this->photo_width = $photo_width; + return $this; + } + /** * Optional. Photo height * @@ -250,6 +460,25 @@ return $this->photo_height; } + /** + * Sets the value of 'photo_height' property + * Optional. Photo height + * + * @param int|null $photo_height + * @return $this + */ + public function setPhotoHeight(?int $photo_height): self + { + if($photo_height === null) + { + $this->photo_height = null; + return $this; + } + + $this->photo_height = $photo_height; + return $this; + } + /** * Optional. Pass True if you require the user's full name to complete the order * @@ -260,6 +489,19 @@ return $this->need_name; } + /** + * Sets the value of 'need_name' property + * Optional. Pass True if you require the user's full name to complete the order + * + * @param bool $need_name + * @return $this + */ + public function setNeedName(bool $need_name): self + { + $this->need_name = $need_name; + return $this; + } + /** * Optional. Pass True if you require the user's phone number to complete the order * @@ -270,6 +512,19 @@ return $this->need_phone_number; } + /** + * Sets the value of 'need_phone_number' property + * Optional. Pass True if you require the user's phone number to complete the order + * + * @param bool $need_phone_number + * @return $this + */ + public function setNeedPhoneNumber(bool $need_phone_number): self + { + $this->need_phone_number = $need_phone_number; + return $this; + } + /** * Optional. Pass True if you require the user's email address to complete the order * @@ -280,6 +535,19 @@ return $this->need_email; } + /** + * Sets the value of 'need_email' property + * Optional. Pass True if you require the user's email address to complete the order + * + * @param bool $need_email + * @return $this + */ + public function setNeedEmail(bool $need_email): self + { + $this->need_email = $need_email; + return $this; + } + /** * Optional. Pass True if you require the user's shipping address to complete the order * @@ -290,6 +558,19 @@ return $this->need_shipping_address; } + /** + * Sets the value of 'need_shipping_address' property + * Optional. Pass True if you require the user's shipping address to complete the order + * + * @param bool $need_shipping_address + * @return $this + */ + public function setNeedShippingAddress(bool $need_shipping_address): self + { + $this->need_shipping_address = $need_shipping_address; + return $this; + } + /** * Optional. Pass True if the user's phone number should be sent to provider * @@ -300,6 +581,19 @@ return $this->send_phone_number_to_provider; } + /** + * Sets the value of 'send_phone_number_to_provider' property + * Optional. Pass True if the user's phone number should be sent to provider + * + * @param bool $send_phone_number_to_provider + * @return $this + */ + public function setSendPhoneNumberToProvider(bool $send_phone_number_to_provider): self + { + $this->send_phone_number_to_provider = $send_phone_number_to_provider; + return $this; + } + /** * Optional. Pass True if the user's email address should be sent to provider * @@ -310,16 +604,42 @@ return $this->send_email_to_provider; } + /** + * Sets the value of 'send_email_to_provider' property + * Optional. Pass True if the user's email address should be sent to provider + * + * @param bool $send_email_to_provider + * @return $this + */ + public function setSendEmailToProvider(bool $send_email_to_provider): self + { + $this->send_email_to_provider = $send_email_to_provider; + return $this; + } + /** * Optional. Pass True if the final price depends on the shipping method * * @return bool */ - public function isIsFlexible(): bool + public function isFlexible(): bool { return $this->is_flexible; } + /** + * Sets the value of 'is_flexible' property + * Optional. Pass True if the final price depends on the shipping method + * + * @param bool $is_flexible + * @return $this + */ + public function setIsFlexible(bool $is_flexible): self + { + $this->is_flexible = $is_flexible; + return $this; + } + /** * @inheritDoc */