// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// MessagesProlongWebViewRequest represents TL type `messages.prolongWebView#b0d81a83`.
// Indicate to the server (from the user side) that the user is still using a web app.
// If the method returns a QUERY_ID_INVALID error, the webview must be closed.
//
// See https://core.telegram.org/method/messages.prolongWebView for reference.
type MessagesProlongWebViewRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the inline message that will be sent by the bot on behalf of the user once the
	// web app interaction is terminated¹ should be sent silently (no notifications for the
	// receivers).
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.sendWebViewResultMessage
	Silent bool
	// Dialog where the web app was opened.
	Peer InputPeerClass
	// Bot that owns the web app¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	Bot InputUserClass
	// Web app interaction ID obtained from messages.requestWebView¹
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.requestWebView
	QueryID int64
	// If set, indicates that the inline message that will be sent by the bot on behalf of
	// the user once the web app interaction is terminated¹ should be sent in reply to the
	// specified message or story.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.sendWebViewResultMessage
	//
	// Use SetReplyTo and GetReplyTo helpers.
	ReplyTo InputReplyToClass
	// Open the web app as the specified peer
	//
	// Use SetSendAs and GetSendAs helpers.
	SendAs InputPeerClass
}

// MessagesProlongWebViewRequestTypeID is TL type id of MessagesProlongWebViewRequest.
const MessagesProlongWebViewRequestTypeID = 0xb0d81a83

// Ensuring interfaces in compile-time for MessagesProlongWebViewRequest.
var (
	_ bin.Encoder     = &MessagesProlongWebViewRequest{}
	_ bin.Decoder     = &MessagesProlongWebViewRequest{}
	_ bin.BareEncoder = &MessagesProlongWebViewRequest{}
	_ bin.BareDecoder = &MessagesProlongWebViewRequest{}
)

func ( *MessagesProlongWebViewRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.ReplyTo == nil) {
		return false
	}
	if !(.SendAs == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *MessagesProlongWebViewRequest) () string {
	if  == nil {
		return "MessagesProlongWebViewRequest(nil)"
	}
	type  MessagesProlongWebViewRequest
	return fmt.Sprintf("MessagesProlongWebViewRequest%+v", (*))
}

// FillFrom fills MessagesProlongWebViewRequest from given interface.
func ( *MessagesProlongWebViewRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( InputUserClass)
	() ( int64)
	() ( InputReplyToClass,  bool)
	() ( InputPeerClass,  bool)
}) {
	.Silent = .()
	.Peer = .()
	.Bot = .()
	.QueryID = .()
	if ,  := .();  {
		.ReplyTo = 
	}

	if ,  := .();  {
		.SendAs = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessagesProlongWebViewRequest) () uint32 {
	return MessagesProlongWebViewRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*MessagesProlongWebViewRequest) () string {
	return "messages.prolongWebView"
}

// TypeInfo returns info about TL type.
func ( *MessagesProlongWebViewRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.prolongWebView",
		ID:   MessagesProlongWebViewRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "ReplyTo",
			SchemaName: "reply_to",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SendAs",
			SchemaName: "send_as",
			Null:       !.Flags.Has(13),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesProlongWebViewRequest) () {
	if !(.Silent == false) {
		.Flags.Set(5)
	}
	if !(.ReplyTo == nil) {
		.Flags.Set(0)
	}
	if !(.SendAs == nil) {
		.Flags.Set(13)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesProlongWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.prolongWebView#b0d81a83 as nil")
	}
	.PutID(MessagesProlongWebViewRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesProlongWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.prolongWebView#b0d81a83 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field peer: %w", )
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field bot: %w", )
	}
	.PutLong(.QueryID)
	if .Flags.Has(0) {
		if .ReplyTo == nil {
			return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field reply_to is nil")
		}
		if  := .ReplyTo.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field reply_to: %w", )
		}
	}
	if .Flags.Has(13) {
		if .SendAs == nil {
			return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field send_as is nil")
		}
		if  := .SendAs.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.prolongWebView#b0d81a83: field send_as: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesProlongWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.prolongWebView#b0d81a83 to nil")
	}
	if  := .ConsumeID(MessagesProlongWebViewRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesProlongWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.prolongWebView#b0d81a83 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field flags: %w", )
		}
	}
	.Silent = .Flags.Has(5)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field query_id: %w", )
		}
		.QueryID = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputReplyTo()
		if  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field reply_to: %w", )
		}
		.ReplyTo = 
	}
	if .Flags.Has(13) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.prolongWebView#b0d81a83: field send_as: %w", )
		}
		.SendAs = 
	}
	return nil
}

// SetSilent sets value of Silent conditional field.
func ( *MessagesProlongWebViewRequest) ( bool) {
	if  {
		.Flags.Set(5)
		.Silent = true
	} else {
		.Flags.Unset(5)
		.Silent = false
	}
}

// GetSilent returns value of Silent conditional field.
func ( *MessagesProlongWebViewRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// GetPeer returns value of Peer field.
func ( *MessagesProlongWebViewRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetBot returns value of Bot field.
func ( *MessagesProlongWebViewRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .Bot
}

// GetQueryID returns value of QueryID field.
func ( *MessagesProlongWebViewRequest) () ( int64) {
	if  == nil {
		return
	}
	return .QueryID
}

// SetReplyTo sets value of ReplyTo conditional field.
func ( *MessagesProlongWebViewRequest) ( InputReplyToClass) {
	.Flags.Set(0)
	.ReplyTo = 
}

// GetReplyTo returns value of ReplyTo conditional field and
// boolean which is true if field was set.
func ( *MessagesProlongWebViewRequest) () ( InputReplyToClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ReplyTo, true
}

// SetSendAs sets value of SendAs conditional field.
func ( *MessagesProlongWebViewRequest) ( InputPeerClass) {
	.Flags.Set(13)
	.SendAs = 
}

// GetSendAs returns value of SendAs conditional field and
// boolean which is true if field was set.
func ( *MessagesProlongWebViewRequest) () ( InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .SendAs, true
}

// MessagesProlongWebView invokes method messages.prolongWebView#b0d81a83 returning error if any.
// Indicate to the server (from the user side) that the user is still using a web app.
// If the method returns a QUERY_ID_INVALID error, the webview must be closed.
//
// See https://core.telegram.org/method/messages.prolongWebView for reference.
func ( *Client) ( context.Context,  *MessagesProlongWebViewRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}