Source code for pyrogram.raw.types.ton_connect_session

#  Pyrogram - Telegram MTProto API Client Library for Python
#  Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
#  This file is part of Pyrogram.
#
#  Pyrogram is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  Pyrogram is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with Pyrogram.  If not, see <http://www.gnu.org/licenses/>.

from io import BytesIO

from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from typing import List, Optional, Any

# # # # # # # # # # # # # # # # # # # # # # # #
#               !!! WARNING !!!               #
#          This is a generated file!          #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #


[docs] class TonConnectSession(TLObject): # type: ignore """ Constructor of :obj:`~pyrogram.raw.base.TonConnectSession`. Details: - Layer: ``230`` - ID: ``126556C6`` Parameters: id (``int`` ``64-bit``): N/A dapp_client_id (``str``): N/A nonce (``bytes``): N/A date (``int`` ``32-bit``): N/A pending (``bool``, *optional*): N/A closing (``bool``, *optional*): N/A closed (``bool``, *optional*): N/A client_id (``str``, *optional*): N/A manifest (:obj:`TonConnectManifest <pyrogram.raw.base.TonConnectManifest>`, *optional*): N/A manifest_error (``int`` ``32-bit``, *optional*): N/A Functions: This object can be returned by 1 function. .. currentmodule:: pyrogram.raw.functions .. autosummary:: :nosignatures: wallet.TonConnectCreateSession """ __slots__: List[str] = ["id", "dapp_client_id", "nonce", "date", "pending", "closing", "closed", "client_id", "manifest", "manifest_error"] ID = 0x126556c6 QUALNAME = "types.TonConnectSession" def __init__(self, *, id: int, dapp_client_id: str, nonce: bytes, date: int, pending: Optional[bool] = None, closing: Optional[bool] = None, closed: Optional[bool] = None, client_id: Optional[str] = None, manifest: "raw.base.TonConnectManifest" = None, manifest_error: Optional[int] = None) -> None: self.id = id # long self.dapp_client_id = dapp_client_id # string self.nonce = nonce # bytes self.date = date # int self.pending = pending # flags.0?true self.closing = closing # flags.1?true self.closed = closed # flags.2?true self.client_id = client_id # flags.3?string self.manifest = manifest # flags.4?TonConnectManifest self.manifest_error = manifest_error # flags.5?int @staticmethod def read(b: BytesIO, *args: Any) -> "TonConnectSession": flags = Int.read(b) pending = True if flags & (1 << 0) else False closing = True if flags & (1 << 1) else False closed = True if flags & (1 << 2) else False id = Long.read(b) dapp_client_id = String.read(b) client_id = String.read(b) if flags & (1 << 3) else None nonce = Bytes.read(b) manifest = TLObject.read(b) if flags & (1 << 4) else None manifest_error = Int.read(b) if flags & (1 << 5) else None date = Int.read(b) return TonConnectSession(id=id, dapp_client_id=dapp_client_id, nonce=nonce, date=date, pending=pending, closing=closing, closed=closed, client_id=client_id, manifest=manifest, manifest_error=manifest_error) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.pending else 0 flags |= (1 << 1) if self.closing else 0 flags |= (1 << 2) if self.closed else 0 flags |= (1 << 3) if self.client_id is not None else 0 flags |= (1 << 4) if self.manifest is not None else 0 flags |= (1 << 5) if self.manifest_error is not None else 0 b.write(Int(flags)) b.write(Long(self.id)) b.write(String(self.dapp_client_id)) if self.client_id is not None: b.write(String(self.client_id)) b.write(Bytes(self.nonce)) if self.manifest is not None: b.write(self.manifest.write()) if self.manifest_error is not None: b.write(Int(self.manifest_error)) b.write(Int(self.date)) return b.getvalue()