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

// MessagesGetScheduledHistoryRequest represents TL type `messages.getScheduledHistory#f516760b`.
// Get scheduled messages
//
// See https://core.telegram.org/method/messages.getScheduledHistory for reference.
type MessagesGetScheduledHistoryRequest struct {
	// Peer
	Peer InputPeerClass
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
}

// MessagesGetScheduledHistoryRequestTypeID is TL type id of MessagesGetScheduledHistoryRequest.
const MessagesGetScheduledHistoryRequestTypeID = 0xf516760b

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

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

	return true
}

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

// FillFrom fills MessagesGetScheduledHistoryRequest from given interface.
func ( *MessagesGetScheduledHistoryRequest) ( interface {
	() ( InputPeerClass)
	() ( int64)
}) {
	.Peer = .()
	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetScheduledHistoryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getScheduledHistory",
		ID:   MessagesGetScheduledHistoryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetScheduledHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getScheduledHistory#f516760b as nil")
	}
	.PutID(MessagesGetScheduledHistoryRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetScheduledHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getScheduledHistory#f516760b to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getScheduledHistory#f516760b: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getScheduledHistory#f516760b: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

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

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

// MessagesGetScheduledHistory invokes method messages.getScheduledHistory#f516760b returning error if any.
// Get scheduled messages
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.getScheduledHistory for reference.
func ( *Client) ( context.Context,  *MessagesGetScheduledHistoryRequest) (MessagesMessagesClass, error) {
	var  MessagesMessagesBox

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