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

// MessagesRequestMainWebViewRequest represents TL type `messages.requestMainWebView#c9e01e7b`.
// Open a Main Mini App¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-apps
//
// See https://core.telegram.org/method/messages.requestMainWebView for reference.
type MessagesRequestMainWebViewRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, requests to open the mini app in compact mode (as opposed to normal or
	// fullscreen mode). Must be set if the mode parameter of the Main Mini App link¹ is
	// equal to compact.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#main-mini-app-links
	Compact bool
	// If set, requests to open the mini app in fullscreen mode (as opposed to compact or
	// normal mode). Must be set if the mode parameter of the Main Mini App link¹ is equal
	// to fullscreen.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#main-mini-app-links
	Fullscreen bool
	// Currently open chat, may be inputPeerEmpty¹ if no chat is currently open.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerEmpty
	Peer InputPeerClass
	// Bot that owns the main mini app.
	Bot InputUserClass
	// Start parameter, if opening from a Main Mini App link »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#main-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
}

// MessagesRequestMainWebViewRequestTypeID is TL type id of MessagesRequestMainWebViewRequest.
const MessagesRequestMainWebViewRequestTypeID = 0xc9e01e7b

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

func ( *MessagesRequestMainWebViewRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Compact == false) {
		return false
	}
	if !(.Fullscreen == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.StartParam == "") {
		return false
	}
	if !(.ThemeParams.Zero()) {
		return false
	}
	if !(.Platform == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesRequestMainWebViewRequest from given interface.
func ( *MessagesRequestMainWebViewRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( InputUserClass)
	() ( string,  bool)
	() ( DataJSON,  bool)
	() ( string)
}) {
	.Compact = .()
	.Fullscreen = .()
	.Peer = .()
	.Bot = .()
	if ,  := .();  {
		.StartParam = 
	}

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

	.Platform = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesRequestMainWebViewRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.requestMainWebView",
		ID:   MessagesRequestMainWebViewRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Compact",
			SchemaName: "compact",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Fullscreen",
			SchemaName: "fullscreen",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "StartParam",
			SchemaName: "start_param",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ThemeParams",
			SchemaName: "theme_params",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Platform",
			SchemaName: "platform",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesRequestMainWebViewRequest) () {
	if !(.Compact == false) {
		.Flags.Set(7)
	}
	if !(.Fullscreen == false) {
		.Flags.Set(8)
	}
	if !(.StartParam == "") {
		.Flags.Set(1)
	}
	if !(.ThemeParams.Zero()) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesRequestMainWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestMainWebView#c9e01e7b as nil")
	}
	.PutID(MessagesRequestMainWebViewRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesRequestMainWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.requestMainWebView#c9e01e7b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field peer: %w", )
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field bot: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.StartParam)
	}
	if .Flags.Has(0) {
		if  := .ThemeParams.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.requestMainWebView#c9e01e7b: field theme_params: %w", )
		}
	}
	.PutString(.Platform)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesRequestMainWebViewRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.requestMainWebView#c9e01e7b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field flags: %w", )
		}
	}
	.Compact = .Flags.Has(7)
	.Fullscreen = .Flags.Has(8)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field bot: %w", )
		}
		.Bot = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field start_param: %w", )
		}
		.StartParam = 
	}
	if .Flags.Has(0) {
		if  := .ThemeParams.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field theme_params: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.requestMainWebView#c9e01e7b: field platform: %w", )
		}
		.Platform = 
	}
	return nil
}

// SetCompact sets value of Compact conditional field.
func ( *MessagesRequestMainWebViewRequest) ( bool) {
	if  {
		.Flags.Set(7)
		.Compact = true
	} else {
		.Flags.Unset(7)
		.Compact = false
	}
}

// GetCompact returns value of Compact conditional field.
func ( *MessagesRequestMainWebViewRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetFullscreen sets value of Fullscreen conditional field.
func ( *MessagesRequestMainWebViewRequest) ( bool) {
	if  {
		.Flags.Set(8)
		.Fullscreen = true
	} else {
		.Flags.Unset(8)
		.Fullscreen = false
	}
}

// GetFullscreen returns value of Fullscreen conditional field.
func ( *MessagesRequestMainWebViewRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

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

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

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

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

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

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

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

// MessagesRequestMainWebView invokes method messages.requestMainWebView#c9e01e7b returning error if any.
// Open a Main Mini App¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps#main-mini-apps
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/messages.requestMainWebView for reference.
func ( *Client) ( context.Context,  *MessagesRequestMainWebViewRequest) (*WebViewResultURL, error) {
	var  WebViewResultURL

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