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

// BotsAnswerWebhookJSONQueryRequest represents TL type `bots.answerWebhookJSONQuery#e6213f4d`.
// Answers a custom query; for bots only
//
// See https://core.telegram.org/method/bots.answerWebhookJSONQuery for reference.
type BotsAnswerWebhookJSONQueryRequest struct {
	// Identifier of a custom query
	QueryID int64
	// JSON-serialized answer to the query
	Data DataJSON
}

// BotsAnswerWebhookJSONQueryRequestTypeID is TL type id of BotsAnswerWebhookJSONQueryRequest.
const BotsAnswerWebhookJSONQueryRequestTypeID = 0xe6213f4d

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

func ( *BotsAnswerWebhookJSONQueryRequest) () bool {
	if  == nil {
		return true
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.Data.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills BotsAnswerWebhookJSONQueryRequest from given interface.
func ( *BotsAnswerWebhookJSONQueryRequest) ( interface {
	() ( int64)
	() ( DataJSON)
}) {
	.QueryID = .()
	.Data = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotsAnswerWebhookJSONQueryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.answerWebhookJSONQuery",
		ID:   BotsAnswerWebhookJSONQueryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsAnswerWebhookJSONQueryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.answerWebhookJSONQuery#e6213f4d as nil")
	}
	.PutID(BotsAnswerWebhookJSONQueryRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsAnswerWebhookJSONQueryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.answerWebhookJSONQuery#e6213f4d as nil")
	}
	.PutLong(.QueryID)
	if  := .Data.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.answerWebhookJSONQuery#e6213f4d: field data: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotsAnswerWebhookJSONQueryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.answerWebhookJSONQuery#e6213f4d to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode bots.answerWebhookJSONQuery#e6213f4d: field query_id: %w", )
		}
		.QueryID = 
	}
	{
		if  := .Data.Decode();  != nil {
			return fmt.Errorf("unable to decode bots.answerWebhookJSONQuery#e6213f4d: field data: %w", )
		}
	}
	return nil
}

// GetQueryID returns value of QueryID field.
func ( *BotsAnswerWebhookJSONQueryRequest) () ( int64) {
	if  == nil {
		return
	}
	return .QueryID
}

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

// BotsAnswerWebhookJSONQuery invokes method bots.answerWebhookJSONQuery#e6213f4d returning error if any.
// Answers a custom query; for bots only
//
// Possible errors:
//
//	400 DATA_JSON_INVALID: The provided JSON data is invalid.
//	400 QUERY_ID_INVALID: The query ID 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.answerWebhookJSONQuery for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *BotsAnswerWebhookJSONQueryRequest) (bool, error) {
	var  BoolBox

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