-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
442 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportElementError; | ||
|
||
/** | ||
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an | ||
* administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is | ||
* off in the target group | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#setchattitle | ||
*/ | ||
class SetPassportDataErrors extends TelegramMethods | ||
{ | ||
/** | ||
* User identifier | ||
* @var string | ||
*/ | ||
public $user_id = 0; | ||
|
||
/** | ||
* A JSON-serialized array describing the errors | ||
* @var PassportElementError[] | ||
*/ | ||
public $errors = []; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'user_id', | ||
'errors', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Custom; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\CustomType; | ||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportFile; | ||
use unreal4u\TelegramAPI\Telegram\Types\PhotoSize; | ||
use unreal4u\TelegramAPI\Interfaces\CustomArrayType; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Mockup class to generate a real telegram update representation | ||
*/ | ||
class PassportFileArray extends CustomType implements CustomArrayType | ||
{ | ||
public function __construct(array $data = null, LoggerInterface $logger = null) | ||
{ | ||
if (count($data) !== 0) { | ||
foreach ($data as $id => $passportFile) { | ||
$this->data[$id] = new PassportFile($passportFile, $logger); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Traverses through our $data, yielding the result set | ||
* | ||
* @return PhotoSize[] | ||
*/ | ||
public function traverseObject(): \Generator | ||
{ | ||
foreach ($this->data as $passportFile) { | ||
yield $passportFile; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport\ElementError; | ||
|
||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportElementError; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class DataField extends PassportElementError | ||
{ | ||
public $source = 'data'; | ||
|
||
/** | ||
* Name of the data field which has the error | ||
* @var string | ||
*/ | ||
public $field_name = ''; | ||
|
||
/** | ||
* Base64-encoded data hash | ||
* @var string | ||
*/ | ||
public $data_hash = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport\ElementError; | ||
|
||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportElementError; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class FrontSide extends PassportElementError | ||
{ | ||
public $source = 'front_side'; | ||
|
||
/** | ||
* Base64-encoded hash of the file with the front side of the document | ||
* @var string | ||
*/ | ||
public $file_hash = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport\ElementError; | ||
|
||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportElementError; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class ReverseSide extends PassportElementError | ||
{ | ||
public $source = 'reverse_side'; | ||
|
||
/** | ||
* Base64-encoded hash of the file with the front side of the document | ||
* @var string | ||
*/ | ||
public $file_hash = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport\ElementError; | ||
|
||
use unreal4u\TelegramAPI\Telegram\Types\Passport\PassportElementError; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is july 2018 | ||
* | ||
* @see https://core.telegram.org/bots/api#passportelementerrorselfie | ||
*/ | ||
class Selfie extends PassportElementError | ||
{ | ||
public $source = 'selfie'; | ||
|
||
/** | ||
* Base64-encoded hash of the file with the front side of the document | ||
* @var string | ||
*/ | ||
public $file_hash = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class EncryptedCredentials extends TelegramTypes | ||
{ | ||
/** | ||
* Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for | ||
* EncryptedPassportElement decryption and authentication | ||
* @var string | ||
*/ | ||
public $data = ''; | ||
|
||
/** | ||
* Base64-encoded data hash for data authentication | ||
* @var string | ||
*/ | ||
public $hash = ''; | ||
|
||
/** | ||
* Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption | ||
* @var string | ||
*/ | ||
public $secret = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\PassportFileArray; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class EncryptedPassportElement extends TelegramTypes | ||
{ | ||
/** | ||
* 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". | ||
* @var string | ||
*/ | ||
public $type = ''; | ||
|
||
/** | ||
* 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. | ||
* @var string | ||
*/ | ||
public $data = ''; | ||
|
||
/** | ||
* Optional. User's verified phone number, available only for "phone_number" type | ||
* @var string | ||
*/ | ||
public $phone_number = ''; | ||
|
||
/** | ||
* Optional. User's verified email address, available only for "email" type | ||
* @var string | ||
*/ | ||
public $email = ''; | ||
|
||
/** | ||
* 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. | ||
* @var PassportFileArray | ||
*/ | ||
public $files; | ||
|
||
/** | ||
* 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. | ||
* @var PassportFile | ||
*/ | ||
public $front_side; | ||
|
||
/** | ||
* 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. | ||
* @var PassportFile | ||
*/ | ||
public $reverse_side; | ||
|
||
/** | ||
* 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. | ||
* @var PassportFile | ||
*/ | ||
public $selfie; | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'type', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Passport; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
|
||
/** | ||
* This object represents information about an order | ||
* | ||
* Objects defined as-is may 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#orderinfo | ||
*/ | ||
class PassportData extends TelegramTypes | ||
{ | ||
/** | ||
* Array with information about documents and other Telegram Passport elements that was shared with the bot | ||
* @var string | ||
*/ | ||
public $data; | ||
|
||
/** | ||
* Encrypted credentials required to decrypt the data | ||
* @var EncryptedCredentials | ||
*/ | ||
public $credentials; | ||
|
||
protected function mapSubObjects(string $key, array $data): TelegramTypes | ||
{ | ||
switch ($key) { | ||
case 'data': | ||
// TODO | ||
case 'credentials': | ||
return new EncryptedCredentials($data, $this->logger); | ||
} | ||
|
||
return parent::mapSubObjects($key, $data); | ||
} | ||
} |
Oops, something went wrong.