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

// MessagesGetSearchResultsCalendarRequest represents TL type `messages.getSearchResultsCalendar#49f0bde9`.
// Returns information about the next messages of the specified type in the chat split by
// days.
// Returns the results in reverse chronological order.
// Can return partial results for the last returned day.
//
// See https://core.telegram.org/method/messages.getSearchResultsCalendar for reference.
type MessagesGetSearchResultsCalendarRequest struct {
	// Peer where to search
	Peer InputPeerClass
	// Message filter, inputMessagesFilterEmpty¹, inputMessagesFilterMyMentions² filters
	// are not supported by this method.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputMessagesFilterEmpty
	//  2) https://core.telegram.org/constructor/inputMessagesFilterMyMentions
	Filter MessagesFilterClass
	// Offsets for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetID int
	// Offsets for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetDate int
}

// MessagesGetSearchResultsCalendarRequestTypeID is TL type id of MessagesGetSearchResultsCalendarRequest.
const MessagesGetSearchResultsCalendarRequestTypeID = 0x49f0bde9

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

func ( *MessagesGetSearchResultsCalendarRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Filter == nil) {
		return false
	}
	if !(.OffsetID == 0) {
		return false
	}
	if !(.OffsetDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetSearchResultsCalendarRequest from given interface.
func ( *MessagesGetSearchResultsCalendarRequest) ( interface {
	() ( InputPeerClass)
	() ( MessagesFilterClass)
	() ( int)
	() ( int)
}) {
	.Peer = .()
	.Filter = .()
	.OffsetID = .()
	.OffsetDate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetSearchResultsCalendarRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getSearchResultsCalendar",
		ID:   MessagesGetSearchResultsCalendarRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Filter",
			SchemaName: "filter",
		},
		{
			Name:       "OffsetID",
			SchemaName: "offset_id",
		},
		{
			Name:       "OffsetDate",
			SchemaName: "offset_date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetSearchResultsCalendarRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getSearchResultsCalendar#49f0bde9 as nil")
	}
	.PutID(MessagesGetSearchResultsCalendarRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetSearchResultsCalendarRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getSearchResultsCalendar#49f0bde9 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field peer: %w", )
	}
	if .Filter == nil {
		return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field filter is nil")
	}
	if  := .Filter.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field filter: %w", )
	}
	.PutInt(.OffsetID)
	.PutInt(.OffsetDate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetSearchResultsCalendarRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getSearchResultsCalendar#49f0bde9 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeMessagesFilter()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field filter: %w", )
		}
		.Filter = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field offset_id: %w", )
		}
		.OffsetID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field offset_date: %w", )
		}
		.OffsetDate = 
	}
	return nil
}

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

// GetFilter returns value of Filter field.
func ( *MessagesGetSearchResultsCalendarRequest) () ( MessagesFilterClass) {
	if  == nil {
		return
	}
	return .Filter
}

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

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

// MessagesGetSearchResultsCalendar invokes method messages.getSearchResultsCalendar#49f0bde9 returning error if any.
// Returns information about the next messages of the specified type in the chat split by
// days.
// Returns the results in reverse chronological order.
// Can return partial results for the last returned day.
//
// Possible errors:
//
//	400 FILTER_NOT_SUPPORTED: The specified filter cannot be used in this context.
//
// See https://core.telegram.org/method/messages.getSearchResultsCalendar for reference.
func ( *Client) ( context.Context,  *MessagesGetSearchResultsCalendarRequest) (*MessagesSearchResultsCalendar, error) {
	var  MessagesSearchResultsCalendar

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