diff --git a/src/TgBotLib/Objects/EncryptedCredentials.php b/src/TgBotLib/Objects/EncryptedCredentials.php new file mode 100644 index 0000000..f3a7171 --- /dev/null +++ b/src/TgBotLib/Objects/EncryptedCredentials.php @@ -0,0 +1,88 @@ +data; + } + + /** + * Base64-encoded data hash for data authentication + * + * @return string + */ + public function getHash(): string + { + return $this->hash; + } + + /** + * Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption + * + * @return string + */ + public function getSecret(): string + { + return $this->secret; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'data' => $this->data, + 'hash' => $this->hash, + 'secret' => $this->secret, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->data = @$data['data']; + $object->hash = @$data['hash']; + $object->secret = @$data['secret']; + + return $object; + } + } \ No newline at end of file