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

// MessagesGetSavedDialogsRequest represents TL type `messages.getSavedDialogs#1e91fc99`.
// Returns the current saved dialog list »¹ or monoforum topic list »².
//
// Links:
//  1. https://core.telegram.org/api/saved-messages
//  2. https://core.telegram.org/api/monoforum
//
// See https://core.telegram.org/method/messages.getSavedDialogs for reference.
type MessagesGetSavedDialogsRequest 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
	// If set, fetches the topic list of the passed monoforum, otherwise fetches the saved
	// dialog list.
	//
	// Use SetParentPeer and GetParentPeer helpers.
	ParentPeer InputPeerClass
	// 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 used for caching, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
}

// MessagesGetSavedDialogsRequestTypeID is TL type id of MessagesGetSavedDialogsRequest.
const MessagesGetSavedDialogsRequestTypeID = 0x1e91fc99

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

func ( *MessagesGetSavedDialogsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ExcludePinned == false) {
		return false
	}
	if !(.ParentPeer == nil) {
		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 ( *MessagesGetSavedDialogsRequest) () string {
	if  == nil {
		return "MessagesGetSavedDialogsRequest(nil)"
	}
	type  MessagesGetSavedDialogsRequest
	return fmt.Sprintf("MessagesGetSavedDialogsRequest%+v", (*))
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetSavedDialogsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getSavedDialogs",
		ID:   MessagesGetSavedDialogsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ExcludePinned",
			SchemaName: "exclude_pinned",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ParentPeer",
			SchemaName: "parent_peer",
			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 ( *MessagesGetSavedDialogsRequest) () {
	if !(.ExcludePinned == false) {
		.Flags.Set(0)
	}
	if !(.ParentPeer == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetSavedDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getSavedDialogs#1e91fc99 as nil")
	}
	.PutID(MessagesGetSavedDialogsRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// SetParentPeer sets value of ParentPeer conditional field.
func ( *MessagesGetSavedDialogsRequest) ( InputPeerClass) {
	.Flags.Set(1)
	.ParentPeer = 
}

// GetParentPeer returns value of ParentPeer conditional field and
// boolean which is true if field was set.
func ( *MessagesGetSavedDialogsRequest) () ( InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .ParentPeer, true
}

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

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

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

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

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

// MessagesGetSavedDialogs invokes method messages.getSavedDialogs#1e91fc99 returning error if any.
// Returns the current saved dialog list »¹ or monoforum topic list »².
//
// Links:
//  1. https://core.telegram.org/api/saved-messages
//  2. https://core.telegram.org/api/monoforum
//
// See https://core.telegram.org/method/messages.getSavedDialogs for reference.
func ( *Client) ( context.Context,  *MessagesGetSavedDialogsRequest) (MessagesSavedDialogsClass, error) {
	var  MessagesSavedDialogsBox

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