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

// BotsSendCustomRequestRequest represents TL type `bots.sendCustomRequest#aa2769ed`.
// Sends a custom request; for bots only
//
// See https://core.telegram.org/method/bots.sendCustomRequest for reference.
type BotsSendCustomRequestRequest struct {
	// The method name
	CustomMethod string
	// JSON-serialized method parameters
	Params DataJSON
}

// BotsSendCustomRequestRequestTypeID is TL type id of BotsSendCustomRequestRequest.
const BotsSendCustomRequestRequestTypeID = 0xaa2769ed

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *BotsSendCustomRequestRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.sendCustomRequest#aa2769ed as nil")
	}
	.PutID(BotsSendCustomRequestRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// BotsSendCustomRequest invokes method bots.sendCustomRequest#aa2769ed returning error if any.
// Sends a custom request; for bots only
//
// Possible errors:
//
//	400 DATA_JSON_INVALID: The provided JSON data is invalid.
//	400 METHOD_INVALID: The specified method is invalid.
//	403 USER_BOT_INVALID: User accounts must provide the bot method parameter when calling this method. If there is no such method parameter, this method can only be invoked by bot accounts.
//
// See https://core.telegram.org/method/bots.sendCustomRequest for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *BotsSendCustomRequestRequest) (*DataJSON, error) {
	var  DataJSON

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