|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of the TelegramBot package. |
| 4 | + * |
| 5 | + * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com> |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + */ |
| 10 | + |
| 11 | +namespace Longman\TelegramBot\Entities\TelegramPassport; |
| 12 | + |
| 13 | +use Longman\TelegramBot\Entities\Entity; |
| 14 | + |
| 15 | +/** |
| 16 | + * Class EncryptedPassportElement |
| 17 | + * |
| 18 | + * Contains information about documents or other Telegram Passport elements shared with the bot by the user. |
| 19 | + * |
| 20 | + * @link https://core.telegram.org/bots/api#encryptedpassportelement |
| 21 | + * |
| 22 | + * @method string getType() Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. |
| 23 | + * @method string getData() Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “identity_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. |
| 24 | + * @method string getPhoneNumber() Optional. User's verified phone number, available only for “phone_number” type |
| 25 | + * @method string getEmail() Optional. User's verified email address, available only for “email” type |
| 26 | + * @method PassportFile getFrontSide() Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
| 27 | + * @method PassportFile getReverseSide() Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
| 28 | + * @method PassportFile getSelfie() Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. |
| 29 | + * @method string getHash() Base64-encoded element hash for using in PassportElementErrorUnspecified |
| 30 | + **/ |
| 31 | +class EncryptedPassportElement extends Entity |
| 32 | +{ |
| 33 | + /** |
| 34 | + * {@inheritdoc} |
| 35 | + */ |
| 36 | + protected function subEntities() |
| 37 | + { |
| 38 | + return [ |
| 39 | + 'files' => PassportFile::class, |
| 40 | + 'front_side' => PassportFile::class, |
| 41 | + 'reverse_side' => PassportFile::class, |
| 42 | + 'selfie' => PassportFile::class, |
| 43 | + 'translation' => PassportFile::class, |
| 44 | + ]; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
| 49 | + * |
| 50 | + * This method overrides the default getFiles method |
| 51 | + * and returns a nice array of PassportFile objects. |
| 52 | + * |
| 53 | + * @return null|PassportFile[] |
| 54 | + */ |
| 55 | + public function getFiles() |
| 56 | + { |
| 57 | + $pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'files'); |
| 58 | + |
| 59 | + return empty($pretty_array) ? null : $pretty_array; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. |
| 64 | + * |
| 65 | + * This method overrides the default getTranslation method |
| 66 | + * and returns a nice array of PassportFile objects. |
| 67 | + * |
| 68 | + * @return null|PassportFile[] |
| 69 | + */ |
| 70 | + public function getTranslation() |
| 71 | + { |
| 72 | + $pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'translation'); |
| 73 | + |
| 74 | + return empty($pretty_array) ? null : $pretty_array; |
| 75 | + } |
| 76 | +} |
0 commit comments