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

// ContactsToggleTopPeersRequest represents TL type `contacts.toggleTopPeers#8514bdda`.
// Enable/disable top peersĀ¹
//
// Links:
//  1. https://core.telegram.org/api/top-rating
//
// See https://core.telegram.org/method/contacts.toggleTopPeers for reference.
type ContactsToggleTopPeersRequest struct {
	// Enable/disable
	Enabled bool
}

// ContactsToggleTopPeersRequestTypeID is TL type id of ContactsToggleTopPeersRequest.
const ContactsToggleTopPeersRequestTypeID = 0x8514bdda

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

func ( *ContactsToggleTopPeersRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Enabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsToggleTopPeersRequest from given interface.
func ( *ContactsToggleTopPeersRequest) ( interface {
	() ( bool)
}) {
	.Enabled = .()
}

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

// TypeName returns name of type in TL schema.
func (*ContactsToggleTopPeersRequest) () string {
	return "contacts.toggleTopPeers"
}

// TypeInfo returns info about TL type.
func ( *ContactsToggleTopPeersRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.toggleTopPeers",
		ID:   ContactsToggleTopPeersRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsToggleTopPeersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.toggleTopPeers#8514bdda as nil")
	}
	.PutID(ContactsToggleTopPeersRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsToggleTopPeersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.toggleTopPeers#8514bdda as nil")
	}
	.PutBool(.Enabled)
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactsToggleTopPeersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.toggleTopPeers#8514bdda to nil")
	}
	if  := .ConsumeID(ContactsToggleTopPeersRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode contacts.toggleTopPeers#8514bdda: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactsToggleTopPeersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.toggleTopPeers#8514bdda to nil")
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.toggleTopPeers#8514bdda: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

// GetEnabled returns value of Enabled field.
func ( *ContactsToggleTopPeersRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Enabled
}

// ContactsToggleTopPeers invokes method contacts.toggleTopPeers#8514bdda returning error if any.
// Enable/disable top peersĀ¹
//
// Links:
//  1. https://core.telegram.org/api/top-rating
//
// See https://core.telegram.org/method/contacts.toggleTopPeers for reference.
func ( *Client) ( context.Context,  bool) (bool, error) {
	var  BoolBox

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