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

// MessagesSearchSentMediaRequest represents TL type `messages.searchSentMedia#107e31a0`.
// View and search recently sent media.
// This method does not support pagination.
//
// See https://core.telegram.org/method/messages.searchSentMedia for reference.
type MessagesSearchSentMediaRequest struct {
	// Optional search query
	Q string
	// Message filter
	Filter MessagesFilterClass
	// Maximum number of results to return (max 100).
	Limit int
}

// MessagesSearchSentMediaRequestTypeID is TL type id of MessagesSearchSentMediaRequest.
const MessagesSearchSentMediaRequestTypeID = 0x107e31a0

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

func ( *MessagesSearchSentMediaRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Q == "") {
		return false
	}
	if !(.Filter == nil) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSearchSentMediaRequest from given interface.
func ( *MessagesSearchSentMediaRequest) ( interface {
	() ( string)
	() ( MessagesFilterClass)
	() ( int)
}) {
	.Q = .()
	.Filter = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSearchSentMediaRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.searchSentMedia",
		ID:   MessagesSearchSentMediaRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Q",
			SchemaName: "q",
		},
		{
			Name:       "Filter",
			SchemaName: "filter",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSearchSentMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.searchSentMedia#107e31a0 as nil")
	}
	.PutID(MessagesSearchSentMediaRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSearchSentMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.searchSentMedia#107e31a0 as nil")
	}
	.PutString(.Q)
	if .Filter == nil {
		return fmt.Errorf("unable to encode messages.searchSentMedia#107e31a0: field filter is nil")
	}
	if  := .Filter.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.searchSentMedia#107e31a0: field filter: %w", )
	}
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSearchSentMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.searchSentMedia#107e31a0 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.searchSentMedia#107e31a0: field q: %w", )
		}
		.Q = 
	}
	{
		,  := DecodeMessagesFilter()
		if  != nil {
			return fmt.Errorf("unable to decode messages.searchSentMedia#107e31a0: field filter: %w", )
		}
		.Filter = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.searchSentMedia#107e31a0: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// GetQ returns value of Q field.
func ( *MessagesSearchSentMediaRequest) () ( string) {
	if  == nil {
		return
	}
	return .Q
}

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

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

// MessagesSearchSentMedia invokes method messages.searchSentMedia#107e31a0 returning error if any.
// View and search recently sent media.
// This method does not support pagination.
//
// Possible errors:
//
//	400 FILTER_NOT_SUPPORTED: The specified filter cannot be used in this context.
//
// See https://core.telegram.org/method/messages.searchSentMedia for reference.
func ( *Client) ( context.Context,  *MessagesSearchSentMediaRequest) (MessagesMessagesClass, error) {
	var  MessagesMessagesBox

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