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

// ContactsResetTopPeerRatingRequest represents TL type `contacts.resetTopPeerRating#1ae373ac`.
// Reset ratingĀ¹ of top peer
//
// Links:
//  1. https://core.telegram.org/api/top-rating
//
// See https://core.telegram.org/method/contacts.resetTopPeerRating for reference.
type ContactsResetTopPeerRatingRequest struct {
	// Top peer category
	Category TopPeerCategoryClass
	// Peer whose rating should be reset
	Peer InputPeerClass
}

// ContactsResetTopPeerRatingRequestTypeID is TL type id of ContactsResetTopPeerRatingRequest.
const ContactsResetTopPeerRatingRequestTypeID = 0x1ae373ac

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

func ( *ContactsResetTopPeerRatingRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Category == nil) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsResetTopPeerRatingRequest from given interface.
func ( *ContactsResetTopPeerRatingRequest) ( interface {
	() ( TopPeerCategoryClass)
	() ( InputPeerClass)
}) {
	.Category = .()
	.Peer = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsResetTopPeerRatingRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.resetTopPeerRating",
		ID:   ContactsResetTopPeerRatingRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Category",
			SchemaName: "category",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsResetTopPeerRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resetTopPeerRating#1ae373ac as nil")
	}
	.PutID(ContactsResetTopPeerRatingRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsResetTopPeerRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resetTopPeerRating#1ae373ac as nil")
	}
	if .Category == nil {
		return fmt.Errorf("unable to encode contacts.resetTopPeerRating#1ae373ac: field category is nil")
	}
	if  := .Category.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.resetTopPeerRating#1ae373ac: field category: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode contacts.resetTopPeerRating#1ae373ac: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.resetTopPeerRating#1ae373ac: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactsResetTopPeerRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.resetTopPeerRating#1ae373ac to nil")
	}
	if  := .ConsumeID(ContactsResetTopPeerRatingRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode contacts.resetTopPeerRating#1ae373ac: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactsResetTopPeerRatingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.resetTopPeerRating#1ae373ac to nil")
	}
	{
		,  := DecodeTopPeerCategory()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resetTopPeerRating#1ae373ac: field category: %w", )
		}
		.Category = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resetTopPeerRating#1ae373ac: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// GetCategory returns value of Category field.
func ( *ContactsResetTopPeerRatingRequest) () ( TopPeerCategoryClass) {
	if  == nil {
		return
	}
	return .Category
}

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

// ContactsResetTopPeerRating invokes method contacts.resetTopPeerRating#1ae373ac returning error if any.
// Reset ratingĀ¹ of top peer
//
// Links:
//  1. https://core.telegram.org/api/top-rating
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/contacts.resetTopPeerRating for reference.
func ( *Client) ( context.Context,  *ContactsResetTopPeerRatingRequest) (bool, error) {
	var  BoolBox

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