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

// InputWebDocument represents TL type `inputWebDocument#9bed434d`.
// The document
//
// See https://core.telegram.org/constructor/inputWebDocument for reference.
type InputWebDocument struct {
	// Remote document URL to be downloaded using the appropriate method¹
	//
	// Links:
	//  1) https://core.telegram.org/api/files
	URL string
	// Remote file size
	Size int
	// Mime type
	MimeType string
	// Attributes for media types
	Attributes []DocumentAttributeClass
}

// InputWebDocumentTypeID is TL type id of InputWebDocument.
const InputWebDocumentTypeID = 0x9bed434d

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

func ( *InputWebDocument) () bool {
	if  == nil {
		return true
	}
	if !(.URL == "") {
		return false
	}
	if !(.Size == 0) {
		return false
	}
	if !(.MimeType == "") {
		return false
	}
	if !(.Attributes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputWebDocument from given interface.
func ( *InputWebDocument) ( interface {
	() ( string)
	() ( int)
	() ( string)
	() ( []DocumentAttributeClass)
}) {
	.URL = .()
	.Size = .()
	.MimeType = .()
	.Attributes = .()
}

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

// TypeName returns name of type in TL schema.
func (*InputWebDocument) () string {
	return "inputWebDocument"
}

// TypeInfo returns info about TL type.
func ( *InputWebDocument) () tdp.Type {
	 := tdp.Type{
		Name: "inputWebDocument",
		ID:   InputWebDocumentTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "Size",
			SchemaName: "size",
		},
		{
			Name:       "MimeType",
			SchemaName: "mime_type",
		},
		{
			Name:       "Attributes",
			SchemaName: "attributes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputWebDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWebDocument#9bed434d as nil")
	}
	.PutID(InputWebDocumentTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputWebDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputWebDocument#9bed434d as nil")
	}
	.PutString(.URL)
	.PutInt(.Size)
	.PutString(.MimeType)
	.PutVectorHeader(len(.Attributes))
	for ,  := range .Attributes {
		if  == nil {
			return fmt.Errorf("unable to encode inputWebDocument#9bed434d: field attributes element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode inputWebDocument#9bed434d: field attributes element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputWebDocument) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputWebDocument#9bed434d to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputWebDocument#9bed434d: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputWebDocument#9bed434d: field size: %w", )
		}
		.Size = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputWebDocument#9bed434d: field mime_type: %w", )
		}
		.MimeType = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputWebDocument#9bed434d: field attributes: %w", )
		}

		if  > 0 {
			.Attributes = make([]DocumentAttributeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeDocumentAttribute()
			if  != nil {
				return fmt.Errorf("unable to decode inputWebDocument#9bed434d: field attributes: %w", )
			}
			.Attributes = append(.Attributes, )
		}
	}
	return nil
}

// GetURL returns value of URL field.
func ( *InputWebDocument) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// GetSize returns value of Size field.
func ( *InputWebDocument) () ( int) {
	if  == nil {
		return
	}
	return .Size
}

// GetMimeType returns value of MimeType field.
func ( *InputWebDocument) () ( string) {
	if  == nil {
		return
	}
	return .MimeType
}

// GetAttributes returns value of Attributes field.
func ( *InputWebDocument) () ( []DocumentAttributeClass) {
	if  == nil {
		return
	}
	return .Attributes
}

// MapAttributes returns field Attributes wrapped in DocumentAttributeClassArray helper.
func ( *InputWebDocument) () ( DocumentAttributeClassArray) {
	return DocumentAttributeClassArray(.Attributes)
}