from ...tl.tlobject import TLObject


class LangPackStringPluralized(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    langPackStringPluralized#6c47ac9f flags:# key:string zero_value:flags.0?string one_value:flags.1?string two_value:flags.2?string few_value:flags.3?string many_value:flags.4?string other_value:string = LangPackString"""

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

    def __init__(self, key, other_value, zero_value=None, one_value=None, two_value=None, few_value=None, many_value=None):
        """
        :param key: Telegram type: "string".
        :param zero_value: Telegram type: "string".
        :param one_value: Telegram type: "string".
        :param two_value: Telegram type: "string".
        :param few_value: Telegram type: "string".
        :param many_value: Telegram type: "string".
        :param other_value: Telegram type: "string".

        Constructor for LangPackString: Instance of either LangPackString, LangPackStringPluralized, LangPackStringDeleted.
        """
        super().__init__()

        self.key = key
        self.zero_value = zero_value
        self.one_value = one_value
        self.two_value = two_value
        self.few_value = few_value
        self.many_value = many_value
        self.other_value = other_value

    def to_dict(self):
        return {
            'key': self.key,
            'zero_value': self.zero_value,
            'one_value': self.one_value,
            'two_value': self.two_value,
            'few_value': self.few_value,
            'many_value': self.many_value,
            'other_value': self.other_value,
        }

    def on_send(self, writer):
        writer.write_int(LangPackStringPluralized.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.zero_value else 0
        flags |= (1 << 1) if self.one_value else 0
        flags |= (1 << 2) if self.two_value else 0
        flags |= (1 << 3) if self.few_value else 0
        flags |= (1 << 4) if self.many_value else 0
        writer.write_int(flags)

        writer.tgwrite_string(self.key)
        if self.zero_value:
            writer.tgwrite_string(self.zero_value)

        if self.one_value:
            writer.tgwrite_string(self.one_value)

        if self.two_value:
            writer.tgwrite_string(self.two_value)

        if self.few_value:
            writer.tgwrite_string(self.few_value)

        if self.many_value:
            writer.tgwrite_string(self.many_value)

        writer.tgwrite_string(self.other_value)

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

    def on_response(self, reader):
        flags = reader.read_int()

        self.key = reader.tgread_string()
        if (flags & (1 << 0)) != 0:
            self.zero_value = reader.tgread_string()

        if (flags & (1 << 1)) != 0:
            self.one_value = reader.tgread_string()

        if (flags & (1 << 2)) != 0:
            self.two_value = reader.tgread_string()

        if (flags & (1 << 3)) != 0:
            self.few_value = reader.tgread_string()

        if (flags & (1 << 4)) != 0:
            self.many_value = reader.tgread_string()

        self.other_value = reader.tgread_string()

    def __repr__(self):
        return 'langPackStringPluralized#6c47ac9f flags:# key:string zero_value:flags.0?string one_value:flags.1?string two_value:flags.2?string few_value:flags.3?string many_value:flags.4?string other_value:string = LangPackString'

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

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