# 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 NftItem(TLObject): # type: ignore
"""
Constructor of :obj:`~pyrogram.raw.base.wallet.NftItem`.
Details:
- Layer: ``230``
- ID: ``3441FD1C``
Parameters:
address (``str``):
N/A
owner_address (``str``):
N/A
index (``str``):
N/A
collection_address (``str``, *optional*):
N/A
name (``str``, *optional*):
N/A
description (``str``, *optional*):
N/A
image (:obj:`WebDocument <pyrogram.raw.base.WebDocument>`, *optional*):
N/A
image_small (:obj:`WebDocument <pyrogram.raw.base.WebDocument>`, *optional*):
N/A
content_url (:obj:`WebDocument <pyrogram.raw.base.WebDocument>`, *optional*):
N/A
lottie (:obj:`WebDocument <pyrogram.raw.base.WebDocument>`, *optional*):
N/A
attributes (List of :obj:`wallet.NftAttribute <pyrogram.raw.base.wallet.NftAttribute>`, *optional*):
N/A
extra (:obj:`DataJSON <pyrogram.raw.base.DataJSON>`, *optional*):
N/A
"""
__slots__: List[str] = ["address", "owner_address", "index", "collection_address", "name", "description", "image", "image_small", "content_url", "lottie", "attributes", "extra"]
ID = 0x3441fd1c
QUALNAME = "types.wallet.NftItem"
def __init__(self, *, address: str, owner_address: str, index: str, collection_address: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None, image: "raw.base.WebDocument" = None, image_small: "raw.base.WebDocument" = None, content_url: "raw.base.WebDocument" = None, lottie: "raw.base.WebDocument" = None, attributes: Optional[List["raw.base.wallet.NftAttribute"]] = None, extra: "raw.base.DataJSON" = None) -> None:
self.address = address # string
self.owner_address = owner_address # string
self.index = index # string
self.collection_address = collection_address # flags.0?string
self.name = name # flags.1?string
self.description = description # flags.2?string
self.image = image # flags.3?WebDocument
self.image_small = image_small # flags.4?WebDocument
self.content_url = content_url # flags.5?WebDocument
self.lottie = lottie # flags.6?WebDocument
self.attributes = attributes # flags.7?Vector<wallet.NftAttribute>
self.extra = extra # flags.8?DataJSON
@staticmethod
def read(b: BytesIO, *args: Any) -> "NftItem":
flags = Int.read(b)
collection_address = String.read(b) if flags & (1 << 0) else None
address = String.read(b)
owner_address = String.read(b)
index = String.read(b)
name = String.read(b) if flags & (1 << 1) else None
description = String.read(b) if flags & (1 << 2) else None
image = TLObject.read(b) if flags & (1 << 3) else None
image_small = TLObject.read(b) if flags & (1 << 4) else None
content_url = TLObject.read(b) if flags & (1 << 5) else None
lottie = TLObject.read(b) if flags & (1 << 6) else None
attributes = TLObject.read(b) if flags & (1 << 7) else []
extra = TLObject.read(b) if flags & (1 << 8) else None
return NftItem(address=address, owner_address=owner_address, index=index, collection_address=collection_address, name=name, description=description, image=image, image_small=image_small, content_url=content_url, lottie=lottie, attributes=attributes, extra=extra)
def write(self, *args) -> bytes:
b = BytesIO()
b.write(Int(self.ID, False))
flags = 0
flags |= (1 << 0) if self.collection_address is not None else 0
flags |= (1 << 1) if self.name is not None else 0
flags |= (1 << 2) if self.description is not None else 0
flags |= (1 << 3) if self.image is not None else 0
flags |= (1 << 4) if self.image_small is not None else 0
flags |= (1 << 5) if self.content_url is not None else 0
flags |= (1 << 6) if self.lottie is not None else 0
flags |= (1 << 7) if self.attributes else 0
flags |= (1 << 8) if self.extra is not None else 0
b.write(Int(flags))
if self.collection_address is not None:
b.write(String(self.collection_address))
b.write(String(self.address))
b.write(String(self.owner_address))
b.write(String(self.index))
if self.name is not None:
b.write(String(self.name))
if self.description is not None:
b.write(String(self.description))
if self.image is not None:
b.write(self.image.write())
if self.image_small is not None:
b.write(self.image_small.write())
if self.content_url is not None:
b.write(self.content_url.write())
if self.lottie is not None:
b.write(self.lottie.write())
if self.attributes:
b.write(Vector(self.attributes))
if self.extra is not None:
b.write(self.extra.write())
return b.getvalue()