Skip to content

Commit

Permalink
Add last passport objects
Browse files Browse the repository at this point in the history
  • Loading branch information
punyflash committed Sep 12, 2020
1 parent 31d7ab9 commit 515a35d
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/Objects/Passport/PassportElementError.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
use WeStacks\TeleBot\Exception\TeleBotObjectException;
use WeStacks\TeleBot\Interfaces\TelegramObject;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorDataField;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFile;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFiles;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFrontSide;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorReverseSide;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorSelfie;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorTranslationFile;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorTranslationFiles;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorUnspecified;

abstract class PassportElementError extends TelegramObject
{
Expand All @@ -29,8 +37,15 @@ public static function create($object)
private static function types()
{
return [
'data' => PassportElementErrorDataField::class,
// TODO: https://core.telegram.org/bots/api#passportelementerrorfrontside and rest
'data' => PassportElementErrorDataField::class,
'front_side' => PassportElementErrorFrontSide::class,
'reverse_side' => PassportElementErrorReverseSide::class,
'selfie' => PassportElementErrorSelfie::class,
'file' => PassportElementErrorFile::class,
'files' => PassportElementErrorFiles::class,
'translation_file' => PassportElementErrorTranslationFile::class,
'translation_files' => PassportElementErrorTranslationFiles::class,
'unspecified' => PassportElementErrorUnspecified::class,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @property String $data_hash Base64-encoded data hash
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorDataField extends PassportElementError
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
*
* @property String $source Error source, must be file
* @property String $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”
* @property String $file_hash Base64-encoded file hash
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorFile extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hash' => 'string',
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
*
* @property String $source Error source, must be files
* @property String $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”
* @property Array<String> $file_hashes List of base64-encoded file hashes
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorFiles extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hashes' => array('string'),
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* 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.
*
* @property String $source Error source, must be front_side
* @property String $type The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”
* @property String $file_hash Base64-encoded hash of the file with the front side of the document
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorFrontSide extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hash' => 'string',
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* 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.
*
* @property String $source Error source, must be reverse_side
* @property String $type The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card”
* @property String $file_hash Base64-encoded hash of the file with the reverse side of the document
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorReverseSide extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hash' => 'string',
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
*
* @property String $source Error source, must be selfie
* @property String $type The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”
* @property String $file_hash Base64-encoded hash of the file with the selfie
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorSelfie extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hash' => 'string',
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
*
* @property String $source Error source, must be translation_file
* @property String $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”
* @property String $file_hash Base64-encoded file hash
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorTranslationFile extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hash' => 'string',
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
*
* @property String $source Error source, must be translation_files
* @property String $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”
* @property Array<String> $file_hashes List of base64-encoded file hashes
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorTranslationFiles extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'file_hashes' => array('string'),
'message' => 'string',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace WeStacks\TeleBot\Objects\Passport\PassportElementError;

use WeStacks\TeleBot\Objects\Passport\PassportElementError;

/**
* Represents an issue in an unspecified place. The error is considered resolved when new data is added.
*
* @property String $source Error source, must be unspecified
* @property String $type Type of element of the user's Telegram Passport which has the issue
* @property String $element_hash Base64-encoded element hash
* @property String $message Error message
*
* @package WeStacks\TeleBot\Objects\Passport\PassportElementError
*/
class PassportElementErrorUnspecified extends PassportElementError
{
protected function relations()
{
return [
'source' => 'string',
'type' => 'string',
'element_hash' => 'string',
'message' => 'string',
];
}
}
32 changes: 32 additions & 0 deletions tests/Unit/PassportElementErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,45 @@
use WeStacks\TeleBot\Exception\TeleBotObjectException;
use WeStacks\TeleBot\Objects\Passport\PassportElementError;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorDataField;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFile;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFiles;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorFrontSide;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorReverseSide;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorSelfie;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorTranslationFile;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorTranslationFiles;
use WeStacks\TeleBot\Objects\Passport\PassportElementError\PassportElementErrorUnspecified;

class PassportElementErrorTest extends TestCase
{
public function testPassportElementError()
{
$object = PassportElementError::create(['source' => 'data']);
$this->assertInstanceOf(PassportElementErrorDataField::class, $object);

$object = PassportElementError::create(['source' => 'front_side']);
$this->assertInstanceOf(PassportElementErrorFrontSide::class, $object);

$object = PassportElementError::create(['source' => 'reverse_side']);
$this->assertInstanceOf(PassportElementErrorReverseSide::class, $object);

$object = PassportElementError::create(['source' => 'selfie']);
$this->assertInstanceOf(PassportElementErrorSelfie::class, $object);

$object = PassportElementError::create(['source' => 'file']);
$this->assertInstanceOf(PassportElementErrorFile::class, $object);

$object = PassportElementError::create(['source' => 'files']);
$this->assertInstanceOf(PassportElementErrorFiles::class, $object);

$object = PassportElementError::create(['source' => 'translation_file']);
$this->assertInstanceOf(PassportElementErrorTranslationFile::class, $object);

$object = PassportElementError::create(['source' => 'translation_files']);
$this->assertInstanceOf(PassportElementErrorTranslationFiles::class, $object);

$object = PassportElementError::create(['source' => 'unspecified']);
$this->assertInstanceOf(PassportElementErrorUnspecified::class, $object);
}

public function testWrongPassportElementError()
Expand Down

0 comments on commit 515a35d

Please sign in to comment.