-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
686 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Passport; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\Passport\PassportElementError; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#setpassportdataerrors | ||
*/ | ||
final readonly class SetPassportDataErrors implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
/** | ||
* @param PassportElementError[] $errors | ||
*/ | ||
public function __construct( | ||
private int $userId, | ||
private array $errors, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'setPassportDataErrors'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'user_id' => $this->userId, | ||
'errors' => array_map( | ||
static fn(PassportElementError $error) => $error->toRequestArray(), | ||
$this->errors | ||
), | ||
]; | ||
} | ||
|
||
public function prepareResult(mixed $result): true | ||
{ | ||
ValueHelper::assertTrueResult($result); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerror | ||
*/ | ||
interface PassportElementError | ||
{ | ||
public function getSource(): string; | ||
|
||
public function toRequestArray(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrordatafield | ||
*/ | ||
final readonly class PassportElementErrorDataField implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fieldName, | ||
public string $dataHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'data'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'field_name' => $this->fieldName, | ||
'data_hash' => $this->dataHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrorfile | ||
*/ | ||
final readonly class PassportElementErrorFile implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fileHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'file'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hash' => $this->fileHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrorfiles | ||
*/ | ||
final readonly class PassportElementErrorFiles implements PassportElementError | ||
{ | ||
/** | ||
* @param string[] $fileHashes | ||
*/ | ||
public function __construct( | ||
public string $type, | ||
public array $fileHashes, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'files'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hashes' => $this->fileHashes, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrorfrontside | ||
*/ | ||
final readonly class PassportElementErrorFrontSide implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fileHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'front_side'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hash' => $this->fileHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrorreverseside | ||
*/ | ||
final readonly class PassportElementErrorReverseSide implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fileHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'reverse_side'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hash' => $this->fileHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrorselfie | ||
*/ | ||
final readonly class PassportElementErrorSelfie implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fileHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'selfie'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hash' => $this->fileHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Passport; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#passportelementerrortranslationfile | ||
*/ | ||
final readonly class PassportElementErrorTranslationFile implements PassportElementError | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $fileHash, | ||
public string $message, | ||
) { | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return 'translation_file'; | ||
} | ||
|
||
public function toRequestArray(): array | ||
{ | ||
return [ | ||
'source' => $this->getSource(), | ||
'type' => $this->type, | ||
'file_hash' => $this->fileHash, | ||
'message' => $this->message, | ||
]; | ||
} | ||
} |
Oops, something went wrong.