Add SetPassportDataErrors method
This commit is contained in:
parent
7ea986a555
commit
d206d20dd5
2 changed files with 61 additions and 0 deletions
|
@ -109,6 +109,7 @@
|
|||
use TgBotLib\Methods\SetMyDescription;
|
||||
use TgBotLib\Methods\SetMyName;
|
||||
use TgBotLib\Methods\SetMyShortDescription;
|
||||
use TgBotLib\Methods\SetPassportDataErrors;
|
||||
use TgBotLib\Methods\SetStickerEmojiList;
|
||||
use TgBotLib\Methods\SetStickerMaskPosition;
|
||||
use TgBotLib\Methods\SetStickerPositionInSet;
|
||||
|
@ -249,6 +250,7 @@
|
|||
case ANSWER_SHIPPING_QUERY = 'answerShippingQuery';
|
||||
case ANSWER_PRE_CHECKOUT_QUERY = 'answerPreCheckoutQuery';
|
||||
case GET_STAR_TRANSACTIONS = 'getStarTransactions';
|
||||
case SET_PASSPORT_DATA_ERRORS = 'setPassportDataErrors';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -383,6 +385,7 @@
|
|||
self::ANSWER_SHIPPING_QUERY => AnswerShippingQuery::execute($bot, $parameters),
|
||||
self::ANSWER_PRE_CHECKOUT_QUERY => AnswerPreCheckoutQuery::execute($bot, $parameters),
|
||||
self::GET_STAR_TRANSACTIONS => GetStarTransactions::execute($bot, $parameters),
|
||||
self::SET_PASSPORT_DATA_ERRORS => SetPassportDataErrors::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
58
src/TgBotLib/Methods/SetPassportDataErrors.php
Normal file
58
src/TgBotLib/Methods/SetPassportDataErrors.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class SetPassportDataErrors extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
if(isset($data['errors']))
|
||||
{
|
||||
$errors = [];
|
||||
foreach($data['errors'] as $error)
|
||||
{
|
||||
if($error instanceof ObjectTypeInterface)
|
||||
{
|
||||
$errors[] = $error->toArray();
|
||||
}
|
||||
|
||||
if(is_array($error))
|
||||
{
|
||||
$errors[] = $error;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters['errors'] = json_encode($errors);
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::SET_PASSPORT_DATA_ERRORS->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'user_id',
|
||||
'errors'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue