from ....tl.mtproto_request import MTProtoRequest


class GetStringsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    langpack.getStrings#2e1ee318 lang_code:string keys:Vector<string> = Vector<LangPackString>"""

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

    def __init__(self, lang_code, keys):
        """
        :param lang_code: Telegram type: "string".
        :param keys: Telegram type: "string". Must be a list.

        :returns Vector<LangPackString>: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.lang_code = lang_code
        self.keys = keys

    def to_dict(self):
        return {
            'lang_code': self.lang_code,
            'keys': [] if self.keys is None else self.keys[:],
        }

    def on_send(self, writer):
        writer.write_int(GetStringsRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.lang_code)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.keys))
        for keys_item in self.keys:
            writer.tgwrite_string(keys_item)

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

    def on_response(self, reader):
        self.result = reader.tgread_vector()

    def __repr__(self):
        return 'langpack.getStrings#2e1ee318 lang_code:string keys:Vector<string> = Vector<LangPackString>'

    def __str__(self):
        return '(langpack.getStrings (ID: 0x2e1ee318) = (lang_code={}, keys={}))'.format(str(self.lang_code), None if not self.keys else [str(_) for _ in self.keys])
