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

// BotsSetCustomVerificationRequest represents TL type `bots.setCustomVerification#8b89dfbd`.
// Verify a user or chat on behalf of an organization »¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/verification
//
// See https://core.telegram.org/method/bots.setCustomVerification for reference.
type BotsSetCustomVerificationRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, adds the verification; otherwise removes verification.
	Enabled bool
	// Must not be set if invoked by a bot, must be set to the ID of an owned bot if invoked
	// by a user.
	//
	// Use SetBot and GetBot helpers.
	Bot InputUserClass
	// The peer to verify
	Peer InputPeerClass
	// Custom description for the verification, the UTF-8 length limit for this field is
	// contained in bot_verification_description_length_limit »¹. If not set, Was verified
	// by organization "organization_name" will be used as description.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#bot-verification-description-length-limit
	//
	// Use SetCustomDescription and GetCustomDescription helpers.
	CustomDescription string
}

// BotsSetCustomVerificationRequestTypeID is TL type id of BotsSetCustomVerificationRequest.
const BotsSetCustomVerificationRequestTypeID = 0x8b89dfbd

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

func ( *BotsSetCustomVerificationRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.CustomDescription == "") {
		return false
	}

	return true
}

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

// FillFrom fills BotsSetCustomVerificationRequest from given interface.
func ( *BotsSetCustomVerificationRequest) ( interface {
	() ( bool)
	() ( InputUserClass,  bool)
	() ( InputPeerClass)
	() ( string,  bool)
}) {
	.Enabled = .()
	if ,  := .();  {
		.Bot = 
	}

	.Peer = .()
	if ,  := .();  {
		.CustomDescription = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *BotsSetCustomVerificationRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.setCustomVerification",
		ID:   BotsSetCustomVerificationRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Enabled",
			SchemaName: "enabled",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "CustomDescription",
			SchemaName: "custom_description",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BotsSetCustomVerificationRequest) () {
	if !(.Enabled == false) {
		.Flags.Set(1)
	}
	if !(.Bot == nil) {
		.Flags.Set(0)
	}
	if !(.CustomDescription == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *BotsSetCustomVerificationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setCustomVerification#8b89dfbd as nil")
	}
	.PutID(BotsSetCustomVerificationRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsSetCustomVerificationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.setCustomVerification#8b89dfbd as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .Bot == nil {
			return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field bot is nil")
		}
		if  := .Bot.Encode();  != nil {
			return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field bot: %w", )
		}
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.setCustomVerification#8b89dfbd: field peer: %w", )
	}
	if .Flags.Has(2) {
		.PutString(.CustomDescription)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotsSetCustomVerificationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.setCustomVerification#8b89dfbd to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field flags: %w", )
		}
	}
	.Enabled = .Flags.Has(1)
	if .Flags.Has(0) {
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.setCustomVerification#8b89dfbd: field custom_description: %w", )
		}
		.CustomDescription = 
	}
	return nil
}

// SetEnabled sets value of Enabled conditional field.
func ( *BotsSetCustomVerificationRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Enabled = true
	} else {
		.Flags.Unset(1)
		.Enabled = false
	}
}

// GetEnabled returns value of Enabled conditional field.
func ( *BotsSetCustomVerificationRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetBot sets value of Bot conditional field.
func ( *BotsSetCustomVerificationRequest) ( InputUserClass) {
	.Flags.Set(0)
	.Bot = 
}

// GetBot returns value of Bot conditional field and
// boolean which is true if field was set.
func ( *BotsSetCustomVerificationRequest) () ( InputUserClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Bot, true
}

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

// SetCustomDescription sets value of CustomDescription conditional field.
func ( *BotsSetCustomVerificationRequest) ( string) {
	.Flags.Set(2)
	.CustomDescription = 
}

// GetCustomDescription returns value of CustomDescription conditional field and
// boolean which is true if field was set.
func ( *BotsSetCustomVerificationRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .CustomDescription, true
}

// BotsSetCustomVerification invokes method bots.setCustomVerification#8b89dfbd returning error if any.
// Verify a user or chat on behalf of an organization »¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/verification
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//	403 BOT_VERIFIER_FORBIDDEN: This bot cannot assign verification icons.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/bots.setCustomVerification for reference.
func ( *Client) ( context.Context,  *BotsSetCustomVerificationRequest) (bool, error) {
	var  BoolBox

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