Add PassportElementError handling classes
This commit is contained in:
parent
e22792cc8e
commit
7ea986a555
12 changed files with 1145 additions and 0 deletions
16
src/TgBotLib/Enums/Types/PassportElementErrorSourceType.php
Normal file
16
src/TgBotLib/Enums/Types/PassportElementErrorSourceType.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PassportElementErrorSourceType : string
|
||||
{
|
||||
case DATA = 'data';
|
||||
case FRONT_SIDE = 'front_side';
|
||||
case REVERSE_SIDE = 'reverse_side';
|
||||
case SELFIE = 'selfie';
|
||||
case FILE = 'file';
|
||||
case FILES = 'files';
|
||||
case TRANSLATION_FILE = 'translation_file';
|
||||
case TRANSLATION_FILES = 'translation_files';
|
||||
case UNSPECIFIED = 'unspecified';
|
||||
}
|
13
src/TgBotLib/Enums/Types/PassportElementErrorType.php
Normal file
13
src/TgBotLib/Enums/Types/PassportElementErrorType.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PassportElementErrorType : string
|
||||
{
|
||||
case PERSONAL_DETAILS = 'personal_details';
|
||||
case PASSPORT = 'passport';
|
||||
case DRIVER_LICENSE = 'driver_license';
|
||||
case IDENTITY_CARD = 'identity_card';
|
||||
case INTERNAL_PASSPORT = 'internal_passport';
|
||||
case ADDRESS = 'address';
|
||||
}
|
73
src/TgBotLib/Objects/PassportElementError.php
Normal file
73
src/TgBotLib/Objects/PassportElementError.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorSourceType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorDataField;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorFile;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorFiles;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorFrontSide;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorReverseSide;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorSelfie;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorTranslationFile;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorTranslationFiles;
|
||||
use TgBotLib\Objects\PassportElementError\PassportElementErrorUnspecified;
|
||||
|
||||
abstract class PassportElementError implements ObjectTypeInterface
|
||||
{
|
||||
private PassportElementErrorSourceType $source;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data=null)
|
||||
{
|
||||
if($data == null)
|
||||
{
|
||||
$this->source = PassportElementErrorSourceType::UNSPECIFIED;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->source = PassportElementErrorSourceType::tryFrom($data['source'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error source
|
||||
*
|
||||
* @return PassportElementErrorSourceType
|
||||
*/
|
||||
public function getSource(): PassportElementErrorSourceType
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?PassportElementError
|
||||
{
|
||||
return match(PassportElementErrorSourceType::tryFrom($data['source']))
|
||||
{
|
||||
PassportElementErrorSourceType::DATA => PassportElementErrorDataField::fromArray($data),
|
||||
PassportElementErrorSourceType::FILE => PassportElementErrorFile::fromArray($data),
|
||||
PassportElementErrorSourceType::FILES => PassportElementErrorFiles::fromArray($data),
|
||||
PassportElementErrorSourceType::FRONT_SIDE => PassportElementErrorFrontSide::fromArray($data),
|
||||
PassportElementErrorSourceType::REVERSE_SIDE => PassportElementErrorReverseSide::fromArray($data),
|
||||
PassportElementErrorSourceType::SELFIE => PassportElementErrorSelfie::fromArray($data),
|
||||
PassportElementErrorSourceType::TRANSLATION_FILE => PassportElementErrorTranslationFile::fromArray($data),
|
||||
PassportElementErrorSourceType::TRANSLATION_FILES => PassportElementErrorTranslationFiles::fromArray($data),
|
||||
PassportElementErrorSourceType::UNSPECIFIED => PassportElementErrorUnspecified::fromArray($data),
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorDataField extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fieldName;
|
||||
private string $dataHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue in one of the data fields that was provided by the user.
|
||||
* The error is considered resolved when the field's value changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data=null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fieldName = $data['field_name'];
|
||||
$this->dataHash = $data['data_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the error,
|
||||
* one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the error,
|
||||
* one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return PassportElementErrorDataField
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorDataField
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the data field which has the error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName(): string
|
||||
{
|
||||
return $this->fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the data field which has the error
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return PassportElementErrorDataField
|
||||
*/
|
||||
public function setFieldName(string $fieldName): PassportElementErrorDataField
|
||||
{
|
||||
$this->fieldName = $fieldName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded data hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataHash(): string
|
||||
{
|
||||
return $this->dataHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded data hash
|
||||
*
|
||||
* @param string $dataHash
|
||||
* @return PassportElementErrorDataField
|
||||
*/
|
||||
public function setDataHash(string $dataHash): PassportElementErrorDataField
|
||||
{
|
||||
$this->dataHash = $dataHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return PassportElementErrorDataField
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorDataField
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'field_name' => $this->fieldName,
|
||||
'data_hash' => $this->dataHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorFile extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fileHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with a document scan.
|
||||
* The error is considered resolved when the file with the document scan changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHash = $data['file_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorFile
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded file hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileHash(): string
|
||||
{
|
||||
return $this->fileHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded file hash
|
||||
*
|
||||
* @param string $fileHash
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHash(string $fileHash): PassportElementErrorFile
|
||||
{
|
||||
$this->fileHash = $fileHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorFile
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hash' => $this->fileHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorFiles extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $fileHashes;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with a list of scans.
|
||||
* The error is considered resolved when the list of files containing the scans changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHashes = $data['file_hashes'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorFiles
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFileHashes(): array
|
||||
{
|
||||
return $this->fileHashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @param array $fileHashes
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHashes(array $fileHashes): PassportElementErrorFiles
|
||||
{
|
||||
$this->fileHashes = $fileHashes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorFiles
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hashes' => $this->fileHashes,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorFrontSide extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fileHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with the front side of a document.
|
||||
* The error is considered resolved when the file with the front side of the document changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHash = $data['file_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “passport”, “driver_license”, “identity_card”, “internal_passport”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “passport”, “driver_license”, “identity_card”, “internal_passport”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return PassportElementErrorFrontSide
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorFrontSide
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the front side of the document
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileHash(): string
|
||||
{
|
||||
return $this->fileHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the front side of the document
|
||||
*
|
||||
* @param string $fileHash
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHash(string $fileHash): PassportElementErrorFrontSide
|
||||
{
|
||||
$this->fileHash = $fileHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return PassportElementErrorFrontSide
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorFrontSide
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hash' => $this->fileHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorReverseSide extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fileHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with the reverse side of a document.
|
||||
* The error is considered resolved when the file with reverse side of the document changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHash = $data['file_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return PassportElementErrorReverseSide
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorReverseSide
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the reverse side of the document
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileHash(): string
|
||||
{
|
||||
return $this->fileHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the reverse side of the document
|
||||
*
|
||||
* @param string $fileHash
|
||||
* @return PassportElementErrorReverseSide
|
||||
*/
|
||||
public function setFileHash(string $fileHash): PassportElementErrorReverseSide
|
||||
{
|
||||
$this->fileHash = $fileHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return PassportElementErrorReverseSide
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorReverseSide
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hash' => $this->fileHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorSelfie extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fileHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with the selfie with a document.
|
||||
* The error is considered resolved when the file with the selfie changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHash = $data['file_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “passport”, “driver_license”, “identity_card”, “internal_passport”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The section of the user's Telegram Passport which has the issue,
|
||||
* one of “passport”, “driver_license”, “identity_card”, “internal_passport”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorSelfie
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the selfie
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileHash(): string
|
||||
{
|
||||
return $this->fileHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded hash of the file with the selfie
|
||||
*
|
||||
* @param string $fileHash
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHash(string $fileHash): PassportElementErrorSelfie
|
||||
{
|
||||
$this->fileHash = $fileHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorSelfie
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hash' => $this->fileHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorTranslationFile extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $fileHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with one of the files that constitute the translation of a document.
|
||||
* The error is considered resolved when the file changes.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->fileHash = $data['file_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorTranslationFile
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded file hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileHash(): string
|
||||
{
|
||||
return $this->fileHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded file hash
|
||||
*
|
||||
* @param string $fileHash
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHash(string $fileHash): PassportElementErrorTranslationFile
|
||||
{
|
||||
$this->fileHash = $fileHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorTranslationFile
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hash' => $this->fileHash,
|
||||
'message' => $this->fileHash
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorTranslationFiles extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $fileHashes;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue with the translated version of a document.
|
||||
* The error is considered resolved when a file with the document translation change.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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”
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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”
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorTranslationFiles
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFileHashes(): array
|
||||
{
|
||||
return $this->fileHashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of base64-encoded file hashes
|
||||
*
|
||||
* @param array $fileHashes
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileHashes(array $fileHashes): PassportElementErrorTranslationFiles
|
||||
{
|
||||
$this->fileHashes = $fileHashes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorTranslationFiles
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'file_hashes' => $this->fileHashes,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\PassportElementError;
|
||||
|
||||
use TgBotLib\Enums\Types\PassportElementErrorType;
|
||||
use TgBotLib\Objects\PassportElementError;
|
||||
|
||||
class PassportElementErrorUnspecified extends PassportElementError
|
||||
{
|
||||
private PassportElementErrorType $type;
|
||||
private string $elementHash;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* Represents an issue in an unspecified place. The error is considered resolved when new data is added.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
if($data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->type = PassportElementErrorType::tryFrom($data['type'] ?? null);
|
||||
$this->elementHash = $data['element_hash'];
|
||||
$this->message = $data['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of element of the user's Telegram Passport which has the issue
|
||||
*
|
||||
* @return PassportElementErrorType
|
||||
*/
|
||||
public function getType(): PassportElementErrorType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of element of the user's Telegram Passport which has the issue
|
||||
*
|
||||
* @param PassportElementErrorType $type
|
||||
* @return $this
|
||||
*/
|
||||
public function setType(PassportElementErrorType $type): PassportElementErrorUnspecified
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded element hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getElementHash(): string
|
||||
{
|
||||
return $this->elementHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encoded element hash
|
||||
*
|
||||
* @param string $elementHash
|
||||
* @return $this
|
||||
*/
|
||||
public function setElementHash(string $elementHash): PassportElementErrorUnspecified
|
||||
{
|
||||
$this->elementHash = $elementHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
* @param string $message
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): PassportElementErrorUnspecified
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'source' => $this->getSource()->value,
|
||||
'type' => $this->type->value,
|
||||
'element_hash' => $this->elementHash,
|
||||
'message' => $this->message
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue