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

// MessagesRequestAppWebViewRequest represents TL type `messages.requestAppWebView#8c5a3b3c`.
// Open a bot mini app¹ from a named Mini App deep link², 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/api/links#named-mini-app-links
//  3. https://core.telegram.org/method/messages.prolongWebView
//
// See https://core.telegram.org/method/messages.requestAppWebView for reference.
type MessagesRequestAppWebViewRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag if the bot is asking permission to send messages to the user as
	// specified in the named Mini App deep link¹ docs, and the user agreed.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#named-mini-app-links
	WriteAllowed bool
	// If the client has clicked on the link in a Telegram chat, pass the chat's peer
	// information; otherwise pass the bot's peer information, instead.
	Peer InputPeerClass
	// The app obtained by invoking messages.getBotApp¹ as specified in the named Mini App
	// deep link² docs.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.getBotApp
	//  2) https://core.telegram.org/api/links#named-mini-app-links
	App InputBotAppClass
	// If the startapp query string parameter is present in the named Mini App deep link¹,
	// pass it to start_param.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#named-mini-app-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
}

// MessagesRequestAppWebViewRequestTypeID is TL type id of MessagesRequestAppWebViewRequest.
const MessagesRequestAppWebViewRequestTypeID = 0x8c5a3b3c

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

func ( *MessagesRequestAppWebViewRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.WriteAllowed == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.App == nil) {
		return false
	}
	if !(.StartParam == "") {
		return false
	}
	if !(.ThemeParams.Zero()) {
		return false
	}
	if !(.Platform == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesRequestAppWebViewRequest from given interface.
func ( *MessagesRequestAppWebViewRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( InputBotAppClass)
	() ( string,  bool)
	() ( DataJSON,  bool)
	() ( string)
}) {
	.WriteAllowed = .()
	.Peer = .()
	.App = .()
	if ,  := .();  {
		.StartParam = 
	}

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

	.Platform = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesRequestAppWebViewRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.requestAppWebView",
		ID:   MessagesRequestAppWebViewRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "WriteAllowed",
			SchemaName: "write_allowed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "App",
			SchemaName: "app",
		},
		{
			Name:       "StartParam",
			SchemaName: "start_param",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ThemeParams",
			SchemaName: "theme_params",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Platform",
			SchemaName: "platform",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesRequestAppWebViewRequest) () {
	if !(.WriteAllowed == false) {
		.Flags.Set(0)
	}
	if !(.StartParam == "") {
		.Flags.Set(1)
	}
	if !(.ThemeParams.Zero()) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesRequestAppWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestAppWebView#8c5a3b3c as nil")
	}
	.PutID(MessagesRequestAppWebViewRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesRequestAppWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestAppWebView#8c5a3b3c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field peer: %w", )
	}
	if .App == nil {
		return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field app is nil")
	}
	if  := .App.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field app: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.StartParam)
	}
	if .Flags.Has(2) {
		if  := .ThemeParams.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.requestAppWebView#8c5a3b3c: field theme_params: %w", )
		}
	}
	.PutString(.Platform)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesRequestAppWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.requestAppWebView#8c5a3b3c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field flags: %w", )
		}
	}
	.WriteAllowed = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputBotApp()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field app: %w", )
		}
		.App = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field start_param: %w", )
		}
		.StartParam = 
	}
	if .Flags.Has(2) {
		if  := .ThemeParams.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field theme_params: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestAppWebView#8c5a3b3c: field platform: %w", )
		}
		.Platform = 
	}
	return nil
}

// SetWriteAllowed sets value of WriteAllowed conditional field.
func ( *MessagesRequestAppWebViewRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.WriteAllowed = true
	} else {
		.Flags.Unset(0)
		.WriteAllowed = false
	}
}

// GetWriteAllowed returns value of WriteAllowed conditional field.
func ( *MessagesRequestAppWebViewRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetApp returns value of App field.
func ( *MessagesRequestAppWebViewRequest) () ( InputBotAppClass) {
	if  == nil {
		return
	}
	return .App
}

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

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

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

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

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

// MessagesRequestAppWebView invokes method messages.requestAppWebView#8c5a3b3c returning error if any.
// Open a bot mini app¹ from a named Mini App deep link², 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/api/links#named-mini-app-links
//  3. https://core.telegram.org/method/messages.prolongWebView
//
// See https://core.telegram.org/method/messages.requestAppWebView for reference.
func ( *Client) ( context.Context,  *MessagesRequestAppWebViewRequest) (*AppWebViewResultURL, error) {
	var  AppWebViewResultURL

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