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

// MessagesSendWebViewDataRequest represents TL type `messages.sendWebViewData#dc0242c8`.
// Used by the user to relay data from an opened reply keyboard bot mini app¹ to the bot
// that owns it.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/method/messages.sendWebViewData for reference.
type MessagesSendWebViewDataRequest struct {
	// Bot that owns the web app
	Bot InputUserClass
	// Unique client message ID to prevent duplicate sending of the same event
	RandomID int64
	// Text of the keyboardButtonSimpleWebView¹ that was pressed to open the web app.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonSimpleWebView
	ButtonText string
	// Data to relay to the bot, obtained from a web_app_data_send JS event¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/web-events#web-app-data-send
	Data string
}

// MessagesSendWebViewDataRequestTypeID is TL type id of MessagesSendWebViewDataRequest.
const MessagesSendWebViewDataRequestTypeID = 0xdc0242c8

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

func ( *MessagesSendWebViewDataRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.ButtonText == "") {
		return false
	}
	if !(.Data == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendWebViewDataRequest from given interface.
func ( *MessagesSendWebViewDataRequest) ( interface {
	() ( InputUserClass)
	() ( int64)
	() ( string)
	() ( string)
}) {
	.Bot = .()
	.RandomID = .()
	.ButtonText = .()
	.Data = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSendWebViewDataRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendWebViewData",
		ID:   MessagesSendWebViewDataRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "ButtonText",
			SchemaName: "button_text",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSendWebViewDataRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendWebViewData#dc0242c8 as nil")
	}
	.PutID(MessagesSendWebViewDataRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendWebViewDataRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendWebViewData#dc0242c8 as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode messages.sendWebViewData#dc0242c8: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendWebViewData#dc0242c8: field bot: %w", )
	}
	.PutLong(.RandomID)
	.PutString(.ButtonText)
	.PutString(.Data)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendWebViewDataRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendWebViewData#dc0242c8 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field random_id: %w", )
		}
		.RandomID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field button_text: %w", )
		}
		.ButtonText = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field data: %w", )
		}
		.Data = 
	}
	return nil
}

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

// GetRandomID returns value of RandomID field.
func ( *MessagesSendWebViewDataRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// GetButtonText returns value of ButtonText field.
func ( *MessagesSendWebViewDataRequest) () ( string) {
	if  == nil {
		return
	}
	return .ButtonText
}

// GetData returns value of Data field.
func ( *MessagesSendWebViewDataRequest) () ( string) {
	if  == nil {
		return
	}
	return .Data
}

// MessagesSendWebViewData invokes method messages.sendWebViewData#dc0242c8 returning error if any.
// Used by the user to relay data from an opened reply keyboard bot mini app¹ to the bot
// that owns it.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/method/messages.sendWebViewData for reference.
func ( *Client) ( context.Context,  *MessagesSendWebViewDataRequest) (UpdatesClass, error) {
	var  UpdatesBox

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