"""File auto-generated by tglib TL generator. Do not edit manually."""
from ..tlobject import TLObject
from ..tlobject import TLRequest
from typing import Optional, List, Union
import os
import struct
from datetime import datetime


class GetDifferenceRequest(TLRequest):
    """TL type: langpack.getDifference"""
    CONSTRUCTOR_ID = 0xcd984aa5
    SUBCLASS_OF_ID = 0x52662d55

    def __init__(self, lang_pack: str, lang_code: str, from_version: int):
        self.lang_pack = lang_pack
        self.lang_code = lang_code
        self.from_version = from_version

    def to_dict(self):
        return {
            '_': 'GetDifferenceRequest',
            'lang_pack': self.lang_pack,
            'lang_code': self.lang_code,
            'from_version': self.from_version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_pack))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        buf.write(struct.pack('<i', self.from_version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_pack = reader.tgread_string()
        _args['lang_pack'] = _val_lang_pack
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        _val_from_version = reader.read_int()
        _args['from_version'] = _val_from_version
        return cls(**_args)


class GetLangPackRequest(TLRequest):
    """TL type: langpack.getLangPack"""
    CONSTRUCTOR_ID = 0xf2f2330a
    SUBCLASS_OF_ID = 0x52662d55

    def __init__(self, lang_pack: str, lang_code: str):
        self.lang_pack = lang_pack
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'GetLangPackRequest',
            'lang_pack': self.lang_pack,
            'lang_code': self.lang_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_pack))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_pack = reader.tgread_string()
        _args['lang_pack'] = _val_lang_pack
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class GetLanguageRequest(TLRequest):
    """TL type: langpack.getLanguage"""
    CONSTRUCTOR_ID = 0x6a596502
    SUBCLASS_OF_ID = 0xabac89b7

    def __init__(self, lang_pack: str, lang_code: str):
        self.lang_pack = lang_pack
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'GetLanguageRequest',
            'lang_pack': self.lang_pack,
            'lang_code': self.lang_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_pack))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_pack = reader.tgread_string()
        _args['lang_pack'] = _val_lang_pack
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class GetLanguagesRequest(TLRequest):
    """TL type: langpack.getLanguages"""
    CONSTRUCTOR_ID = 0x42c6978f
    SUBCLASS_OF_ID = 0x280912c9

    def __init__(self, lang_pack: str):
        self.lang_pack = lang_pack

    def to_dict(self):
        return {
            '_': 'GetLanguagesRequest',
            'lang_pack': self.lang_pack,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_pack))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_pack = reader.tgread_string()
        _args['lang_pack'] = _val_lang_pack
        return cls(**_args)


class GetStringsRequest(TLRequest):
    """TL type: langpack.getStrings"""
    CONSTRUCTOR_ID = 0xefea3803
    SUBCLASS_OF_ID = 0xc7b7353d

    def __init__(self, lang_pack: str, lang_code: str, keys: List[str]):
        self.lang_pack = lang_pack
        self.lang_code = lang_code
        self.keys = keys

    def to_dict(self):
        return {
            '_': 'GetStringsRequest',
            'lang_pack': self.lang_pack,
            'lang_code': self.lang_code,
            'keys': self.keys,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_pack))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.keys)))
        for item in self.keys:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_pack = reader.tgread_string()
        _args['lang_pack'] = _val_lang_pack
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        reader.read_int(signed=False)  # skip vector id
        _count_keys = reader.read_int()
        _list_keys = []
        for _ in range(_count_keys):
            _item_keys = reader.tgread_string()
            _list_keys.append(_item_keys)
        _args['keys'] = _list_keys
        return cls(**_args)

