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

// MessagesStartHistoryImportRequest represents TL type `messages.startHistoryImport#b43df344`.
// Complete the history import process¹, importing all messages into the chat.
// To be called only after initializing the import with messages.initHistoryImport² and
// uploading all files using messages.uploadImportedMedia³.
//
// Links:
//  1. https://core.telegram.org/api/import
//  2. https://core.telegram.org/method/messages.initHistoryImport
//  3. https://core.telegram.org/method/messages.uploadImportedMedia
//
// See https://core.telegram.org/method/messages.startHistoryImport for reference.
type MessagesStartHistoryImportRequest struct {
	// The Telegram chat where the messages should be imported, click here for more info »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/import
	Peer InputPeerClass
	// Identifier of a history import session, returned by messages.initHistoryImport¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.initHistoryImport
	ImportID int64
}

// MessagesStartHistoryImportRequestTypeID is TL type id of MessagesStartHistoryImportRequest.
const MessagesStartHistoryImportRequestTypeID = 0xb43df344

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesStartHistoryImportRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.startHistoryImport",
		ID:   MessagesStartHistoryImportRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ImportID",
			SchemaName: "import_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesStartHistoryImportRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.startHistoryImport#b43df344 as nil")
	}
	.PutID(MessagesStartHistoryImportRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesStartHistoryImportRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.startHistoryImport#b43df344 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.startHistoryImport#b43df344: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.startHistoryImport#b43df344: field import_id: %w", )
		}
		.ImportID = 
	}
	return nil
}

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

// GetImportID returns value of ImportID field.
func ( *MessagesStartHistoryImportRequest) () ( int64) {
	if  == nil {
		return
	}
	return .ImportID
}

// MessagesStartHistoryImport invokes method messages.startHistoryImport#b43df344 returning error if any.
// Complete the history import process¹, importing all messages into the chat.
// To be called only after initializing the import with messages.initHistoryImport² and
// uploading all files using messages.uploadImportedMedia³.
//
// Links:
//  1. https://core.telegram.org/api/import
//  2. https://core.telegram.org/method/messages.initHistoryImport
//  3. https://core.telegram.org/method/messages.uploadImportedMedia
//
// Possible errors:
//
//	400 IMPORT_ID_INVALID: The specified import ID is invalid.
//
// See https://core.telegram.org/method/messages.startHistoryImport for reference.
func ( *Client) ( context.Context,  *MessagesStartHistoryImportRequest) (bool, error) {
	var  BoolBox

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