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

// MessagesInitHistoryImportRequest represents TL type `messages.initHistoryImport#34090c3b`.
// Import chat history from a foreign chat app into a specific Telegram chat, click here
// for more info about imported chats »¹.
//
// Links:
//  1. https://core.telegram.org/api/import
//
// See https://core.telegram.org/method/messages.initHistoryImport for reference.
type MessagesInitHistoryImportRequest struct {
	// The Telegram chat where the history should be imported¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/import
	Peer InputPeerClass
	// File with messages to import.
	File InputFileClass
	// Number of media files associated with the chat that will be uploaded using messages
	// uploadImportedMedia¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.uploadImportedMedia
	MediaCount int
}

// MessagesInitHistoryImportRequestTypeID is TL type id of MessagesInitHistoryImportRequest.
const MessagesInitHistoryImportRequestTypeID = 0x34090c3b

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

func ( *MessagesInitHistoryImportRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.File == nil) {
		return false
	}
	if !(.MediaCount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesInitHistoryImportRequest from given interface.
func ( *MessagesInitHistoryImportRequest) ( interface {
	() ( InputPeerClass)
	() ( InputFileClass)
	() ( int)
}) {
	.Peer = .()
	.File = .()
	.MediaCount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesInitHistoryImportRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.initHistoryImport",
		ID:   MessagesInitHistoryImportRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "File",
			SchemaName: "file",
		},
		{
			Name:       "MediaCount",
			SchemaName: "media_count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesInitHistoryImportRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.initHistoryImport#34090c3b as nil")
	}
	.PutID(MessagesInitHistoryImportRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesInitHistoryImportRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.initHistoryImport#34090c3b as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.initHistoryImport#34090c3b: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.initHistoryImport#34090c3b: field peer: %w", )
	}
	if .File == nil {
		return fmt.Errorf("unable to encode messages.initHistoryImport#34090c3b: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.initHistoryImport#34090c3b: field file: %w", )
	}
	.PutInt(.MediaCount)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesInitHistoryImportRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.initHistoryImport#34090c3b to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.initHistoryImport#34090c3b: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode messages.initHistoryImport#34090c3b: field file: %w", )
		}
		.File = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.initHistoryImport#34090c3b: field media_count: %w", )
		}
		.MediaCount = 
	}
	return nil
}

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

// GetFile returns value of File field.
func ( *MessagesInitHistoryImportRequest) () ( InputFileClass) {
	if  == nil {
		return
	}
	return .File
}

// GetMediaCount returns value of MediaCount field.
func ( *MessagesInitHistoryImportRequest) () ( int) {
	if  == nil {
		return
	}
	return .MediaCount
}

// MessagesInitHistoryImport invokes method messages.initHistoryImport#34090c3b returning error if any.
// Import chat history from a foreign chat app into a specific Telegram chat, click here
// for more info about imported chats »¹.
//
// Links:
//  1. https://core.telegram.org/api/import
//
// Possible errors:
//
//	400 IMPORT_FILE_INVALID: The specified chat export file is invalid.
//	400 IMPORT_FORMAT_UNRECOGNIZED: The specified chat export file was exported from an unsupported chat app.
//	406 PREVIOUS_CHAT_IMPORT_ACTIVE_WAIT_%dMIN: Import for this chat is already in progress, wait %d minutes before starting a new one.
//
// See https://core.telegram.org/method/messages.initHistoryImport for reference.
func ( *Client) ( context.Context,  *MessagesInitHistoryImportRequest) (*MessagesHistoryImport, error) {
	var  MessagesHistoryImport

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