from telethon.tl.mtproto_request import MTProtoRequest


class Link(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    contacts.link#3ace484c my_link:ContactLink foreign_link:ContactLink user:User = contacts.Link"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x3ace484c

    def __init__(self, my_link, foreign_link, user):
        """
        :param my_link: Telegram type: «ContactLink».
        :param foreign_link: Telegram type: «ContactLink».
        :param user: Telegram type: «User».
        """
        super().__init__()

        self.my_link = my_link
        self.foreign_link = foreign_link
        self.user = user

    def on_send(self, writer):
        writer.write_int(Link.constructor_id, signed=False)
        self.my_link.on_send(writer)
        self.foreign_link.on_send(writer)
        self.user.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return Link(None, None, None)

    def on_response(self, reader):
        self.my_link = reader.tgread_object()
        self.foreign_link = reader.tgread_object()
        self.user = reader.tgread_object()

    def __repr__(self):
        return 'contacts.link#3ace484c my_link:ContactLink foreign_link:ContactLink user:User = contacts.Link'

    def __str__(self):
        return '(contacts.link (ID: 0x3ace484c) = (my_link={}, foreign_link={}, user={}))'.format(str(self.my_link), str(self.foreign_link), str(self.user))
