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

// MessagesSetDefaultHistoryTTLRequest represents TL type `messages.setDefaultHistoryTTL#9eb51445`.
// Changes the default value of the Time-To-Live setting, applied to all new chats.
//
// See https://core.telegram.org/method/messages.setDefaultHistoryTTL for reference.
type MessagesSetDefaultHistoryTTLRequest struct {
	// The new default Time-To-Live of all messages sent in new chats.
	Period int
}

// MessagesSetDefaultHistoryTTLRequestTypeID is TL type id of MessagesSetDefaultHistoryTTLRequest.
const MessagesSetDefaultHistoryTTLRequestTypeID = 0x9eb51445

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesSetDefaultHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setDefaultHistoryTTL#9eb51445 as nil")
	}
	.PutID(MessagesSetDefaultHistoryTTLRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetDefaultHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setDefaultHistoryTTL#9eb51445 as nil")
	}
	.PutInt(.Period)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetDefaultHistoryTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setDefaultHistoryTTL#9eb51445 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setDefaultHistoryTTL#9eb51445: field period: %w", )
		}
		.Period = 
	}
	return nil
}

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

// MessagesSetDefaultHistoryTTL invokes method messages.setDefaultHistoryTTL#9eb51445 returning error if any.
// Changes the default value of the Time-To-Live setting, applied to all new chats.
//
// See https://core.telegram.org/method/messages.setDefaultHistoryTTL for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  int) (bool, error) {
	var  BoolBox

	 := &MessagesSetDefaultHistoryTTLRequest{
		Period: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}