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

// BotsInvokeWebViewCustomMethodRequest represents TL type `bots.invokeWebViewCustomMethod#87fc5e7`.
// Send a custom request from a mini bot app¹, triggered by a
// web_app_invoke_custom_method event »².
// The response should be sent using a custom_method_invoked¹ event, see here »² for
// more info on the flow.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/web-events#web-app-invoke-custom-method
//  3. https://core.telegram.org/api/bots/webapps#custom-method-invoked
//  4. https://core.telegram.org/api/web-events#web-app-invoke-custom-method
//
// See https://core.telegram.org/method/bots.invokeWebViewCustomMethod for reference.
type BotsInvokeWebViewCustomMethodRequest struct {
	// Identifier of the bot associated to the mini bot app¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	Bot InputUserClass
	// Identifier of the custom method to invoke
	CustomMethod string
	// Method parameters
	Params DataJSON
}

// BotsInvokeWebViewCustomMethodRequestTypeID is TL type id of BotsInvokeWebViewCustomMethodRequest.
const BotsInvokeWebViewCustomMethodRequestTypeID = 0x87fc5e7

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

func ( *BotsInvokeWebViewCustomMethodRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.CustomMethod == "") {
		return false
	}
	if !(.Params.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills BotsInvokeWebViewCustomMethodRequest from given interface.
func ( *BotsInvokeWebViewCustomMethodRequest) ( interface {
	() ( InputUserClass)
	() ( string)
	() ( DataJSON)
}) {
	.Bot = .()
	.CustomMethod = .()
	.Params = .()
}

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

// TypeName returns name of type in TL schema.
func (*BotsInvokeWebViewCustomMethodRequest) () string {
	return "bots.invokeWebViewCustomMethod"
}

// TypeInfo returns info about TL type.
func ( *BotsInvokeWebViewCustomMethodRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.invokeWebViewCustomMethod",
		ID:   BotsInvokeWebViewCustomMethodRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "CustomMethod",
			SchemaName: "custom_method",
		},
		{
			Name:       "Params",
			SchemaName: "params",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsInvokeWebViewCustomMethodRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.invokeWebViewCustomMethod#87fc5e7 as nil")
	}
	.PutID(BotsInvokeWebViewCustomMethodRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsInvokeWebViewCustomMethodRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.invokeWebViewCustomMethod#87fc5e7 as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.invokeWebViewCustomMethod#87fc5e7: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.invokeWebViewCustomMethod#87fc5e7: field bot: %w", )
	}
	.PutString(.CustomMethod)
	if  := .Params.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.invokeWebViewCustomMethod#87fc5e7: field params: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsInvokeWebViewCustomMethodRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.invokeWebViewCustomMethod#87fc5e7 to nil")
	}
	if  := .ConsumeID(BotsInvokeWebViewCustomMethodRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.invokeWebViewCustomMethod#87fc5e7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsInvokeWebViewCustomMethodRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.invokeWebViewCustomMethod#87fc5e7 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.invokeWebViewCustomMethod#87fc5e7: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.invokeWebViewCustomMethod#87fc5e7: field custom_method: %w", )
		}
		.CustomMethod = 
	}
	{
		if  := .Params.Decode();  != nil {
			return fmt.Errorf("unable to decode bots.invokeWebViewCustomMethod#87fc5e7: field params: %w", )
		}
	}
	return nil
}

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

// GetCustomMethod returns value of CustomMethod field.
func ( *BotsInvokeWebViewCustomMethodRequest) () ( string) {
	if  == nil {
		return
	}
	return .CustomMethod
}

// GetParams returns value of Params field.
func ( *BotsInvokeWebViewCustomMethodRequest) () ( DataJSON) {
	if  == nil {
		return
	}
	return .Params
}

// BotsInvokeWebViewCustomMethod invokes method bots.invokeWebViewCustomMethod#87fc5e7 returning error if any.
// Send a custom request from a mini bot app¹, triggered by a
// web_app_invoke_custom_method event »².
// The response should be sent using a custom_method_invoked¹ event, see here »² for
// more info on the flow.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/web-events#web-app-invoke-custom-method
//  3. https://core.telegram.org/api/bots/webapps#custom-method-invoked
//  4. https://core.telegram.org/api/web-events#web-app-invoke-custom-method
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.invokeWebViewCustomMethod for reference.
func ( *Client) ( context.Context,  *BotsInvokeWebViewCustomMethodRequest) (*DataJSON, error) {
	var  DataJSON

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