1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Type\PassportElementError\PassportElementErrorType; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class SetPassportDataErrorsMethod. |
11
|
|
|
* |
12
|
|
|
* Informs a user that some of the Telegram Passport elements they provided contains errors. |
13
|
|
|
* The user will not be able to re-submit their Passport to you until the errors are fixed |
14
|
|
|
* (the contents of the field for which you returned the error must change). Returns True on success. |
15
|
|
|
* |
16
|
|
|
* Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. |
17
|
|
|
* For example, if a birthday date seems invalid, a submitted document is blurry, |
18
|
|
|
* a scan shows evidence of tampering, etc. |
19
|
|
|
* Supply some details in the error message to make sure the user knows how to correct the issues. |
20
|
|
|
* |
21
|
|
|
* @see https://core.telegram.org/bots/api#setpassportdataerrors |
22
|
|
|
* @see https://core.telegram.org/passport |
23
|
|
|
*/ |
24
|
|
|
class SetPassportDataErrorsMethod |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* User identifier. |
28
|
|
|
* |
29
|
|
|
* @var int |
30
|
|
|
*/ |
31
|
|
|
public $userId; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* A JSON-serialized array describing the errors. |
35
|
|
|
* |
36
|
|
|
* @var PassportElementErrorType[] |
37
|
|
|
*/ |
38
|
|
|
public $errors; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* SetPassportDataErrorsMethod constructor. |
42
|
|
|
* |
43
|
|
|
* @param int $userId |
44
|
|
|
* @param PassportElementErrorType[] |
45
|
|
|
* @param array $errors |
46
|
|
|
* |
47
|
|
|
* @return SetPassportDataErrorsMethod |
48
|
|
|
*/ |
49
|
|
|
public static function create(int $userId, array $errors): SetPassportDataErrorsMethod |
50
|
|
|
{ |
51
|
|
|
$instance = new static(); |
52
|
|
|
$instance->userId = $userId; |
53
|
|
|
$instance->errors = $errors; |
54
|
|
|
|
55
|
|
|
return $instance; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param PassportElementErrorType $error |
60
|
|
|
*/ |
61
|
|
|
public function addError(PassportElementErrorType $error) |
62
|
|
|
{ |
63
|
|
|
$this->errors[] = $error; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|