Add AnswerPreCheckoutQuery method

This commit is contained in:
netkas 2024-11-27 14:45:18 -05:00
parent 932178d203
commit 672ab564c2
2 changed files with 43 additions and 0 deletions

View file

@ -8,6 +8,7 @@
use TgBotLib\Methods\AddStickerToSet; use TgBotLib\Methods\AddStickerToSet;
use TgBotLib\Methods\AnswerCallbackQuery; use TgBotLib\Methods\AnswerCallbackQuery;
use TgBotLib\Methods\AnswerInlineQuery; use TgBotLib\Methods\AnswerInlineQuery;
use TgBotLib\Methods\AnswerPreCheckoutQuery;
use TgBotLib\Methods\AnswerShippingQuery; use TgBotLib\Methods\AnswerShippingQuery;
use TgBotLib\Methods\AnswerWebAppQuery; use TgBotLib\Methods\AnswerWebAppQuery;
use TgBotLib\Methods\ApproveChatJoinRequest; use TgBotLib\Methods\ApproveChatJoinRequest;
@ -245,6 +246,7 @@
case SEND_INVOICE = 'sendInvoice'; case SEND_INVOICE = 'sendInvoice';
case CREATE_INVOICE_LINK = 'createInvoiceLink'; case CREATE_INVOICE_LINK = 'createInvoiceLink';
case ANSWER_SHIPPING_QUERY = 'answerShippingQuery'; case ANSWER_SHIPPING_QUERY = 'answerShippingQuery';
case ANSWER_PRE_CHECKOUT_QUERY = 'answerPreCheckoutQuery';
/** /**
* Executes a command on the provided bot with the given parameters. * Executes a command on the provided bot with the given parameters.
@ -377,6 +379,7 @@
self::SEND_INVOICE => SendInvoice::execute($bot, $parameters), self::SEND_INVOICE => SendInvoice::execute($bot, $parameters),
self::CREATE_INVOICE_LINK => CreateInvoiceLink::execute($bot, $parameters), self::CREATE_INVOICE_LINK => CreateInvoiceLink::execute($bot, $parameters),
self::ANSWER_SHIPPING_QUERY => AnswerShippingQuery::execute($bot, $parameters), self::ANSWER_SHIPPING_QUERY => AnswerShippingQuery::execute($bot, $parameters),
self::ANSWER_PRE_CHECKOUT_QUERY => AnswerPreCheckoutQuery::execute($bot, $parameters),
}; };
} }
} }

View file

@ -0,0 +1,40 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class AnswerPreCheckoutQuery extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
return (bool)self::executeCurl(self::buildPost($bot, Methods::ANSWER_PRE_CHECKOUT_QUERY->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'pre_checkout_query_id',
'ok'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'error_message'
];
}
}