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

// MessagesGetDialogsRequest represents TL type `messages.getDialogs#a0f4cb4f`.
// Returns the current user dialog list.
//
// See https://core.telegram.org/method/messages.getDialogs for reference.
type MessagesGetDialogsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Exclude pinned dialogs
	ExcludePinned bool
	// Peer folder ID, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	//
	// Use SetFolderID and GetFolderID helpers.
	FolderID int
	// Offsets for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetDate int
	// Offsets for pagination, for more info click here¹ (top_message ID used for
	// pagination)
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetID int
	// Offset peer for pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetPeer InputPeerClass
	// Number of list elements to be returned
	Limit int
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
}

// MessagesGetDialogsRequestTypeID is TL type id of MessagesGetDialogsRequest.
const MessagesGetDialogsRequestTypeID = 0xa0f4cb4f

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

func ( *MessagesGetDialogsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ExcludePinned == false) {
		return false
	}
	if !(.FolderID == 0) {
		return false
	}
	if !(.OffsetDate == 0) {
		return false
	}
	if !(.OffsetID == 0) {
		return false
	}
	if !(.OffsetPeer == nil) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetDialogsRequest from given interface.
func ( *MessagesGetDialogsRequest) ( interface {
	() ( bool)
	() ( int,  bool)
	() ( int)
	() ( int)
	() ( InputPeerClass)
	() ( int)
	() ( int64)
}) {
	.ExcludePinned = .()
	if ,  := .();  {
		.FolderID = 
	}

	.OffsetDate = .()
	.OffsetID = .()
	.OffsetPeer = .()
	.Limit = .()
	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetDialogsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getDialogs",
		ID:   MessagesGetDialogsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ExcludePinned",
			SchemaName: "exclude_pinned",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "OffsetDate",
			SchemaName: "offset_date",
		},
		{
			Name:       "OffsetID",
			SchemaName: "offset_id",
		},
		{
			Name:       "OffsetPeer",
			SchemaName: "offset_peer",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesGetDialogsRequest) () {
	if !(.ExcludePinned == false) {
		.Flags.Set(0)
	}
	if !(.FolderID == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getDialogs#a0f4cb4f as nil")
	}
	.PutID(MessagesGetDialogsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getDialogs#a0f4cb4f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getDialogs#a0f4cb4f: field flags: %w", )
	}
	if .Flags.Has(1) {
		.PutInt(.FolderID)
	}
	.PutInt(.OffsetDate)
	.PutInt(.OffsetID)
	if .OffsetPeer == nil {
		return fmt.Errorf("unable to encode messages.getDialogs#a0f4cb4f: field offset_peer is nil")
	}
	if  := .OffsetPeer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getDialogs#a0f4cb4f: field offset_peer: %w", )
	}
	.PutInt(.Limit)
	.PutLong(.Hash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getDialogs#a0f4cb4f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field flags: %w", )
		}
	}
	.ExcludePinned = .Flags.Has(0)
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field folder_id: %w", )
		}
		.FolderID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field offset_date: %w", )
		}
		.OffsetDate = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field offset_id: %w", )
		}
		.OffsetID = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field offset_peer: %w", )
		}
		.OffsetPeer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field limit: %w", )
		}
		.Limit = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDialogs#a0f4cb4f: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// SetExcludePinned sets value of ExcludePinned conditional field.
func ( *MessagesGetDialogsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ExcludePinned = true
	} else {
		.Flags.Unset(0)
		.ExcludePinned = false
	}
}

// GetExcludePinned returns value of ExcludePinned conditional field.
func ( *MessagesGetDialogsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetFolderID sets value of FolderID conditional field.
func ( *MessagesGetDialogsRequest) ( int) {
	.Flags.Set(1)
	.FolderID = 
}

// GetFolderID returns value of FolderID conditional field and
// boolean which is true if field was set.
func ( *MessagesGetDialogsRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .FolderID, true
}

// GetOffsetDate returns value of OffsetDate field.
func ( *MessagesGetDialogsRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetDate
}

// GetOffsetID returns value of OffsetID field.
func ( *MessagesGetDialogsRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetID
}

// GetOffsetPeer returns value of OffsetPeer field.
func ( *MessagesGetDialogsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .OffsetPeer
}

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

// GetHash returns value of Hash field.
func ( *MessagesGetDialogsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// MessagesGetDialogs invokes method messages.getDialogs#a0f4cb4f returning error if any.
// Returns the current user dialog list.
//
// Possible errors:
//
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 FOLDER_ID_INVALID: Invalid folder ID.
//	400 OFFSET_PEER_ID_INVALID: The provided offset peer is invalid.
//
// See https://core.telegram.org/method/messages.getDialogs for reference.
func ( *Client) ( context.Context,  *MessagesGetDialogsRequest) (MessagesDialogsClass, error) {
	var  MessagesDialogsBox

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