from ....tl.mtproto_request import MTProtoRequest


class CancelCodeRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool"""

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

    def __init__(self, phone_number, phone_code_hash):
        """
        :param phone_number: Telegram type: «string».
        :param phone_code_hash: Telegram type: «string».

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

        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash

    def on_send(self, writer):
        writer.write_int(CancelCodeRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.phone_number)
        writer.tgwrite_string(self.phone_code_hash)

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

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

    def __repr__(self):
        return 'auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool'

    def __str__(self):
        return '(auth.cancelCode (ID: 0x1f040578) = (phone_number={}, phone_code_hash={}))'.format(str(self.phone_number), str(self.phone_code_hash))
