Add AnswerShippingQuery method

This commit is contained in:
netkas 2024-11-22 22:11:29 -05:00
parent 791362e9c1
commit 932178d203
2 changed files with 53 additions and 0 deletions

View file

@ -8,6 +8,7 @@
use TgBotLib\Methods\AddStickerToSet;
use TgBotLib\Methods\AnswerCallbackQuery;
use TgBotLib\Methods\AnswerInlineQuery;
use TgBotLib\Methods\AnswerShippingQuery;
use TgBotLib\Methods\AnswerWebAppQuery;
use TgBotLib\Methods\ApproveChatJoinRequest;
use TgBotLib\Methods\BanChatMember;
@ -243,6 +244,7 @@
case SAVE_PREPARED_INLINE_MESSAGE = 'savePreparedInlineMessage';
case SEND_INVOICE = 'sendInvoice';
case CREATE_INVOICE_LINK = 'createInvoiceLink';
case ANSWER_SHIPPING_QUERY = 'answerShippingQuery';
/**
* Executes a command on the provided bot with the given parameters.
@ -374,6 +376,7 @@
self::SAVE_PREPARED_INLINE_MESSAGE => SavePreparedInlineMessage::execute($bot, $parameters),
self::SEND_INVOICE => SendInvoice::execute($bot, $parameters),
self::CREATE_INVOICE_LINK => CreateInvoiceLink::execute($bot, $parameters),
self::ANSWER_SHIPPING_QUERY => AnswerShippingQuery::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
use TgBotLib\Interfaces\ObjectTypeInterface;
class AnswerShippingQuery extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
if(isset($parameters['shipping_options']))
{
if($parameters['shipping_options'] instanceof ObjectTypeInterface)
{
$parameters['shipping_options'] = json_encode($parameters['shipping_options']->toArray());
}
}
return (bool)self::executeCurl(self::buildPost($bot, Methods::ANSWER_SHIPPING_QUERY->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'shipping_query_id',
'ok'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'shipping_options',
'error_message'
];
}
}