"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject


class ClearSavedInfoRequest(TLObject):
    constructor_id = 0xd83d70c1
    subclass_of_id = 0xf5b399ac

    def __init__(self, credentials=None, info=None):
        """
        :param credentials: Telegram type: "true".
        :param info: Telegram type: "true".

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.credentials = credentials
        self.info = info

    def to_dict(self):
        return {
            'credentials': self.credentials,
            'info': self.info,
        }

    def on_send(self, writer):
        writer.write_int(ClearSavedInfoRequest.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.credentials else 0
        flags |= (1 << 1) if self.info else 0
        writer.write_int(flags)


    @staticmethod
    def empty():
        return ClearSavedInfoRequest(None, None)

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

    def __repr__(self):
        return 'payments.clearSavedInfo#d83d70c1 flags:# credentials:flags.0?true info:flags.1?true = Bool'

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

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



class GetPaymentFormRequest(TLObject):
    constructor_id = 0x99f09745
    subclass_of_id = 0xa0483f19

    def __init__(self, msg_id):
        """
        :param msg_id: Telegram type: "int".

        :returns payments.PaymentForm: Instance of PaymentForm.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.msg_id = msg_id

    def to_dict(self):
        return {
            'msg_id': self.msg_id,
        }

    def on_send(self, writer):
        writer.write_int(GetPaymentFormRequest.constructor_id, signed=False)
        writer.write_int(self.msg_id)

    @staticmethod
    def empty():
        return GetPaymentFormRequest(None)

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

    def __repr__(self):
        return 'payments.getPaymentForm#99f09745 msg_id:int = payments.PaymentForm'

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

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



class GetPaymentReceiptRequest(TLObject):
    constructor_id = 0xa092a980
    subclass_of_id = 0x590093c9

    def __init__(self, msg_id):
        """
        :param msg_id: Telegram type: "int".

        :returns payments.PaymentReceipt: Instance of PaymentReceipt.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.msg_id = msg_id

    def to_dict(self):
        return {
            'msg_id': self.msg_id,
        }

    def on_send(self, writer):
        writer.write_int(GetPaymentReceiptRequest.constructor_id, signed=False)
        writer.write_int(self.msg_id)

    @staticmethod
    def empty():
        return GetPaymentReceiptRequest(None)

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

    def __repr__(self):
        return 'payments.getPaymentReceipt#a092a980 msg_id:int = payments.PaymentReceipt'

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

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



class GetSavedInfoRequest(TLObject):
    constructor_id = 0x227d824b
    subclass_of_id = 0xad3cf146

    def __init__(self):
        super().__init__()
        self.result = None
        self.content_related = True

    @staticmethod
    def to_dict():
        return {}

    def on_send(self, writer):
        writer.write_int(GetSavedInfoRequest.constructor_id, signed=False)

    @staticmethod
    def empty():
        return GetSavedInfoRequest()

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

    def __repr__(self):
        return 'payments.getSavedInfo#227d824b = payments.SavedInfo'

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

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



class SendPaymentFormRequest(TLObject):
    constructor_id = 0x2b8879b3
    subclass_of_id = 0x8ae16a9d

    def __init__(self, msg_id, credentials, requested_info_id=None, shipping_option_id=None):
        """
        :param msg_id: Telegram type: "int".
        :param requested_info_id: Telegram type: "string".
        :param shipping_option_id: Telegram type: "string".
        :param credentials: Telegram type: "InputPaymentCredentials".

        :returns payments.PaymentResult: Instance of either PaymentResult, PaymentVerficationNeeded.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.msg_id = msg_id
        self.requested_info_id = requested_info_id
        self.shipping_option_id = shipping_option_id
        self.credentials = credentials

    def to_dict(self):
        return {
            'msg_id': self.msg_id,
            'requested_info_id': self.requested_info_id,
            'shipping_option_id': self.shipping_option_id,
            'credentials': None if self.credentials is None else self.credentials.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(SendPaymentFormRequest.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.requested_info_id else 0
        flags |= (1 << 1) if self.shipping_option_id else 0
        writer.write_int(flags)

        writer.write_int(self.msg_id)
        if self.requested_info_id:
            writer.tgwrite_string(self.requested_info_id)

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

        self.credentials.on_send(writer)

    @staticmethod
    def empty():
        return SendPaymentFormRequest(None, None, None, None)

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

    def __repr__(self):
        return 'payments.sendPaymentForm#2b8879b3 flags:# msg_id:int requested_info_id:flags.0?string shipping_option_id:flags.1?string credentials:InputPaymentCredentials = payments.PaymentResult'

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

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



class ValidateRequestedInfoRequest(TLObject):
    constructor_id = 0x770a8e74
    subclass_of_id = 0x8f8044b7

    def __init__(self, msg_id, info, save=None):
        """
        :param save: Telegram type: "true".
        :param msg_id: Telegram type: "int".
        :param info: Telegram type: "PaymentRequestedInfo".

        :returns payments.ValidatedRequestedInfo: Instance of ValidatedRequestedInfo.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.save = save
        self.msg_id = msg_id
        self.info = info

    def to_dict(self):
        return {
            'save': self.save,
            'msg_id': self.msg_id,
            'info': None if self.info is None else self.info.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(ValidateRequestedInfoRequest.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.save else 0
        writer.write_int(flags)

        writer.write_int(self.msg_id)
        self.info.on_send(writer)

    @staticmethod
    def empty():
        return ValidateRequestedInfoRequest(None, None, None)

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

    def __repr__(self):
        return 'payments.validateRequestedInfo#770a8e74 flags:# save:flags.0?true msg_id:int info:PaymentRequestedInfo = payments.ValidatedRequestedInfo'

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

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

