Bot API 4.1, add new fields and error types for Telegram Passport

parent 3dbf450c
...@@ -25,8 +25,8 @@ use Longman\TelegramBot\Entities\Entity; ...@@ -25,8 +25,8 @@ use Longman\TelegramBot\Entities\Entity;
* @method string getEmail() Optional. User's verified email address, available only for “email” type * @method string getEmail() Optional. User's verified email address, available only for “email” type
* @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. * @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.
* @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. * @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.
* @method PassportFile getSelfie() Optional. Encrypted file with the selfie of the user holding a document, provided by the user; * @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.
* available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. * @method string getHash() Base64-encoded element hash for using in PassportElementErrorUnspecified
**/ **/
class EncryptedPassportElement extends Entity class EncryptedPassportElement extends Entity
{ {
...@@ -40,11 +40,12 @@ class EncryptedPassportElement extends Entity ...@@ -40,11 +40,12 @@ class EncryptedPassportElement extends Entity
'front_side' => PassportFile::class, 'front_side' => PassportFile::class,
'reverse_side' => PassportFile::class, 'reverse_side' => PassportFile::class,
'selfie' => PassportFile::class, 'selfie' => PassportFile::class,
'translation' => PassportFile::class,
]; ];
} }
/** /**
* Array with information about documents and other Telegram Passport elements that was shared with the bot * 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.
* *
* This method overrides the default getFiles method * This method overrides the default getFiles method
* and returns a nice array of PassportFile objects. * and returns a nice array of PassportFile objects.
...@@ -57,4 +58,19 @@ class EncryptedPassportElement extends Entity ...@@ -57,4 +58,19 @@ class EncryptedPassportElement extends Entity
return empty($pretty_array) ? null : $pretty_array; return empty($pretty_array) ? null : $pretty_array;
} }
/**
* 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.
*
* This method overrides the default getTranslation method
* and returns a nice array of PassportFile objects.
*
* @return null|PassportFile[]
*/
public function getTranslation()
{
$pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'translation');
return empty($pretty_array) ? null : $pretty_array;
}
} }
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Entities\TelegramPassport\PassportElementError;
use Longman\TelegramBot\Entities\Entity;
/**
* Class PassportElementErrorTranslationFile
*
* Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
*
* @link https://core.telegram.org/bots/api#passportelementerrortranslationfile
*
* @method string getSource() Error source, must be translation_file
* @method string getType() Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
* @method string getFileHash() Base64-encoded translation_file hash
* @method string getMessage() Error message
*/
class PassportElementErrorTranslationFile extends Entity implements PassportElementError
{
/**
* PassportElementErrorTranslationFile constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['source'] = 'translation_file';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Entities\TelegramPassport\PassportElementError;
use Longman\TelegramBot\Entities\Entity;
/**
* Class PassportElementErrorTranslationFiles
*
* Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
*
* @link https://core.telegram.org/bots/api#passportelementerrortranslationfiles
*
* @method string getSource() Error source, must be translation_files
* @method string getType() Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
* @method string[] getFileHashes() List of base64-encoded file hashes
* @method string getMessage() Error message
*/
class PassportElementErrorTranslationFiles extends Entity implements PassportElementError
{
/**
* PassportElementErrorTranslationFiles constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['source'] = 'translation_files';
parent::__construct($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Entities\TelegramPassport\PassportElementError;
use Longman\TelegramBot\Entities\Entity;
/**
* Class PassportElementErrorUnspecified
*
* Represents an issue in an unspecified place. The error is considered resolved when new data is added.
*
* @link https://core.telegram.org/bots/api#passportelementerrorunspecified
*
* @method string getSource() Error source, must be unspecified
* @method string getType() Type of element of the user's Telegram Passport which has the issue
* @method string getElementHash() Base64-encoded element hash
* @method string getMessage() Error message
*/
class PassportElementErrorUnspecified extends Entity implements PassportElementError
{
/**
* PassportElementErrorUnspecified constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['source'] = 'unspecified';
parent::__construct($data);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment