from ...tl.tlobject import TLObject


class LangPackDifference(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    langPackDifference#f385c1f6 lang_code:string from_version:int version:int strings:Vector<LangPackString> = LangPackDifference"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0xf385c1f6
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0x52662d55

    def __init__(self, lang_code, from_version, version, strings):
        """
        :param lang_code: Telegram type: "string".
        :param from_version: Telegram type: "int".
        :param version: Telegram type: "int".
        :param strings: Telegram type: "LangPackString". Must be a list.

        Constructor for LangPackDifference: Instance of LangPackDifference.
        """
        super().__init__()

        self.lang_code = lang_code
        self.from_version = from_version
        self.version = version
        self.strings = strings

    def to_dict(self):
        return {
            'lang_code': self.lang_code,
            'from_version': self.from_version,
            'version': self.version,
            'strings': [] if self.strings is None else [None if x is None else x.to_dict() for x in self.strings],
        }

    def on_send(self, writer):
        writer.write_int(LangPackDifference.constructor_id, signed=False)
        writer.tgwrite_string(self.lang_code)
        writer.write_int(self.from_version)
        writer.write_int(self.version)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.strings))
        for _x in self.strings:
            _x.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return LangPackDifference(None, None, None, None)

    def on_response(self, reader):
        self.lang_code = reader.tgread_string()
        self.from_version = reader.read_int()
        self.version = reader.read_int()
        reader.read_int()  # Vector's constructor ID
        self.strings = []  # Initialize an empty list
        _len = reader.read_int()
        for _ in range(_len):
            _x = reader.tgread_object()
            self.strings.append(_x)

    def __repr__(self):
        return 'langPackDifference#f385c1f6 lang_code:string from_version:int version:int strings:Vector<LangPackString> = LangPackDifference'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
