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

// MessagesSetHistoryTTLRequest represents TL type `messages.setHistoryTTL#b80e5fe4`.
// Set maximum Time-To-Live of all messages in the specified chat
//
// See https://core.telegram.org/method/messages.setHistoryTTL for reference.
type MessagesSetHistoryTTLRequest struct {
	// The dialog
	Peer InputPeerClass
	// Automatically delete all messages sent in the chat after this many seconds
	Period int
}

// MessagesSetHistoryTTLRequestTypeID is TL type id of MessagesSetHistoryTTLRequest.
const MessagesSetHistoryTTLRequestTypeID = 0xb80e5fe4

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

func ( *MessagesSetHistoryTTLRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Period == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetHistoryTTLRequest from given interface.
func ( *MessagesSetHistoryTTLRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
}) {
	.Peer = .()
	.Period = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetHistoryTTLRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setHistoryTTL",
		ID:   MessagesSetHistoryTTLRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Period",
			SchemaName: "period",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSetHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setHistoryTTL#b80e5fe4 as nil")
	}
	.PutID(MessagesSetHistoryTTLRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setHistoryTTL#b80e5fe4 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.setHistoryTTL#b80e5fe4: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setHistoryTTL#b80e5fe4: field peer: %w", )
	}
	.PutInt(.Period)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setHistoryTTL#b80e5fe4 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setHistoryTTL#b80e5fe4: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setHistoryTTL#b80e5fe4: field period: %w", )
		}
		.Period = 
	}
	return nil
}

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

// GetPeriod returns value of Period field.
func ( *MessagesSetHistoryTTLRequest) () ( int) {
	if  == nil {
		return
	}
	return .Period
}

// MessagesSetHistoryTTL invokes method messages.setHistoryTTL#b80e5fe4 returning error if any.
// Set maximum Time-To-Live of all messages in the specified chat
//
// Possible errors:
//
//	400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
//	400 TTL_PERIOD_INVALID: The specified TTL period is invalid.
//
// See https://core.telegram.org/method/messages.setHistoryTTL for reference.
func ( *Client) ( context.Context,  *MessagesSetHistoryTTLRequest) (UpdatesClass, error) {
	var  UpdatesBox

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