// 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{}
)

// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#269dc2c1`.
// Open a bot mini app¹, sending over user information after user confirmation.
// After calling this method, until the user closes the webview, messages
// prolongWebView¹ must be called every 60 seconds.
//
// Links:
//  1. https://core.telegram.org/bots/webapps
//  2. https://core.telegram.org/method/messages.prolongWebView
//
// See https://core.telegram.org/method/messages.requestWebView for reference.
type MessagesRequestWebViewRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the webview was opened by clicking on the bot's menu button »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/menu
	FromBotMenu bool
	// 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 is being opened, and where the resulting message will be sent
	// (see the docs for more info »¹).
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	Peer InputPeerClass
	// Bot that owns the web app¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	Bot InputUserClass
	// Web app URL¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	//
	// Use SetURL and GetURL helpers.
	URL string
	// If the web app was opened from the attachment menu using a attachment menu deep link¹
	// start_param should contain the data from the startattach parameter.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#bot-attachment-or-side-menu-links
	//
	// Use SetStartParam and GetStartParam helpers.
	StartParam string
	// Theme parameters »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#theme-parameters
	//
	// Use SetThemeParams and GetThemeParams helpers.
	ThemeParams DataJSON
	// Short name of the application; 0-64 English letters, digits, and underscores
	Platform string
	// 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, sending the resulting the message as the
	// specified peer.
	//
	// Use SetSendAs and GetSendAs helpers.
	SendAs InputPeerClass
}

// MessagesRequestWebViewRequestTypeID is TL type id of MessagesRequestWebViewRequest.
const MessagesRequestWebViewRequestTypeID = 0x269dc2c1

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

func ( *MessagesRequestWebViewRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.FromBotMenu == false) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.StartParam == "") {
		return false
	}
	if !(.ThemeParams.Zero()) {
		return false
	}
	if !(.Platform == "") {
		return false
	}
	if !(.ReplyTo == nil) {
		return false
	}
	if !(.SendAs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesRequestWebViewRequest from given interface.
func ( *MessagesRequestWebViewRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( InputUserClass)
	() ( string,  bool)
	() ( string,  bool)
	() ( DataJSON,  bool)
	() ( string)
	() ( InputReplyToClass,  bool)
	() ( InputPeerClass,  bool)
}) {
	.FromBotMenu = .()
	.Silent = .()
	.Peer = .()
	.Bot = .()
	if ,  := .();  {
		.URL = 
	}

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

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

	.Platform = .()
	if ,  := .();  {
		.ReplyTo = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesRequestWebViewRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.requestWebView",
		ID:   MessagesRequestWebViewRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FromBotMenu",
			SchemaName: "from_bot_menu",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "URL",
			SchemaName: "url",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "StartParam",
			SchemaName: "start_param",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ThemeParams",
			SchemaName: "theme_params",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Platform",
			SchemaName: "platform",
		},
		{
			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 ( *MessagesRequestWebViewRequest) () {
	if !(.FromBotMenu == false) {
		.Flags.Set(4)
	}
	if !(.Silent == false) {
		.Flags.Set(5)
	}
	if !(.URL == "") {
		.Flags.Set(1)
	}
	if !(.StartParam == "") {
		.Flags.Set(3)
	}
	if !(.ThemeParams.Zero()) {
		.Flags.Set(2)
	}
	if !(.ReplyTo == nil) {
		.Flags.Set(0)
	}
	if !(.SendAs == nil) {
		.Flags.Set(13)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesRequestWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestWebView#269dc2c1 as nil")
	}
	.PutID(MessagesRequestWebViewRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesRequestWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestWebView#269dc2c1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field peer: %w", )
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field bot: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.URL)
	}
	if .Flags.Has(3) {
		.PutString(.StartParam)
	}
	if .Flags.Has(2) {
		if  := .ThemeParams.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field theme_params: %w", )
		}
	}
	.PutString(.Platform)
	if .Flags.Has(0) {
		if .ReplyTo == nil {
			return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field reply_to is nil")
		}
		if  := .ReplyTo.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field reply_to: %w", )
		}
	}
	if .Flags.Has(13) {
		if .SendAs == nil {
			return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field send_as is nil")
		}
		if  := .SendAs.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.requestWebView#269dc2c1: field send_as: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesRequestWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.requestWebView#269dc2c1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field flags: %w", )
		}
	}
	.FromBotMenu = .Flags.Has(4)
	.Silent = .Flags.Has(5)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field bot: %w", )
		}
		.Bot = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field url: %w", )
		}
		.URL = 
	}
	if .Flags.Has(3) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field start_param: %w", )
		}
		.StartParam = 
	}
	if .Flags.Has(2) {
		if  := .ThemeParams.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field theme_params: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field platform: %w", )
		}
		.Platform = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputReplyTo()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field reply_to: %w", )
		}
		.ReplyTo = 
	}
	if .Flags.Has(13) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestWebView#269dc2c1: field send_as: %w", )
		}
		.SendAs = 
	}
	return nil
}

// SetFromBotMenu sets value of FromBotMenu conditional field.
func ( *MessagesRequestWebViewRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.FromBotMenu = true
	} else {
		.Flags.Unset(4)
		.FromBotMenu = false
	}
}

// GetFromBotMenu returns value of FromBotMenu conditional field.
func ( *MessagesRequestWebViewRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

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

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

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

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

// SetURL sets value of URL conditional field.
func ( *MessagesRequestWebViewRequest) ( string) {
	.Flags.Set(1)
	.URL = 
}

// GetURL returns value of URL conditional field and
// boolean which is true if field was set.
func ( *MessagesRequestWebViewRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .URL, true
}

// SetStartParam sets value of StartParam conditional field.
func ( *MessagesRequestWebViewRequest) ( string) {
	.Flags.Set(3)
	.StartParam = 
}

// GetStartParam returns value of StartParam conditional field and
// boolean which is true if field was set.
func ( *MessagesRequestWebViewRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .StartParam, true
}

// SetThemeParams sets value of ThemeParams conditional field.
func ( *MessagesRequestWebViewRequest) ( DataJSON) {
	.Flags.Set(2)
	.ThemeParams = 
}

// GetThemeParams returns value of ThemeParams conditional field and
// boolean which is true if field was set.
func ( *MessagesRequestWebViewRequest) () ( DataJSON,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .ThemeParams, true
}

// GetPlatform returns value of Platform field.
func ( *MessagesRequestWebViewRequest) () ( string) {
	if  == nil {
		return
	}
	return .Platform
}

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

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

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

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

// MessagesRequestWebView invokes method messages.requestWebView#269dc2c1 returning error if any.
// Open a bot mini app¹, sending over user information after user confirmation.
// After calling this method, until the user closes the webview, messages
// prolongWebView¹ must be called every 60 seconds.
//
// Links:
//  1. https://core.telegram.org/bots/webapps
//  2. https://core.telegram.org/method/messages.prolongWebView
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.requestWebView for reference.
func ( *Client) ( context.Context,  *MessagesRequestWebViewRequest) (*WebViewResultURL, error) {
	var  WebViewResultURL

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