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

// MessagesGetCommonChatsRequest represents TL type `messages.getCommonChats#e40ca104`.
// Get chats in common with a user
//
// See https://core.telegram.org/method/messages.getCommonChats for reference.
type MessagesGetCommonChatsRequest struct {
	// User ID
	UserID InputUserClass
	// Maximum ID of chat to return (see pagination¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	MaxID int64
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// MessagesGetCommonChatsRequestTypeID is TL type id of MessagesGetCommonChatsRequest.
const MessagesGetCommonChatsRequestTypeID = 0xe40ca104

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

func ( *MessagesGetCommonChatsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetCommonChatsRequest from given interface.
func ( *MessagesGetCommonChatsRequest) ( interface {
	() ( InputUserClass)
	() ( int64)
	() ( int)
}) {
	.UserID = .()
	.MaxID = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesGetCommonChatsRequest) () string {
	return "messages.getCommonChats"
}

// TypeInfo returns info about TL type.
func ( *MessagesGetCommonChatsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getCommonChats",
		ID:   MessagesGetCommonChatsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetCommonChatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getCommonChats#e40ca104 as nil")
	}
	.PutID(MessagesGetCommonChatsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetCommonChatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getCommonChats#e40ca104 as nil")
	}
	if .UserID == nil {
		return fmt.Errorf("unable to encode messages.getCommonChats#e40ca104: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getCommonChats#e40ca104: field user_id: %w", )
	}
	.PutLong(.MaxID)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesGetCommonChatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getCommonChats#e40ca104 to nil")
	}
	if  := .ConsumeID(MessagesGetCommonChatsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.getCommonChats#e40ca104: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetCommonChatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getCommonChats#e40ca104 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getCommonChats#e40ca104: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getCommonChats#e40ca104: field max_id: %w", )
		}
		.MaxID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getCommonChats#e40ca104: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *MessagesGetCommonChatsRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetMaxID returns value of MaxID field.
func ( *MessagesGetCommonChatsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .MaxID
}

// GetLimit returns value of Limit field.
func ( *MessagesGetCommonChatsRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// MessagesGetCommonChats invokes method messages.getCommonChats#e40ca104 returning error if any.
// Get chats in common with a user
//
// Possible errors:
//
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/messages.getCommonChats for reference.
func ( *Client) ( context.Context,  *MessagesGetCommonChatsRequest) (MessagesChatsClass, error) {
	var  MessagesChatsBox

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