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

// BusinessIntro represents TL type `businessIntro#5a0a066d`.
// Telegram Business introduction »¹.
//
// Links:
//  1. https://core.telegram.org/api/business#business-introduction
//
// See https://core.telegram.org/constructor/businessIntro for reference.
type BusinessIntro struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Title of the introduction message (max intro_title_length_limit »¹ UTF-8 characters).
	//
	// Links:
	//  1) https://core.telegram.org/api/config#intro-title-length-limit
	Title string
	// Profile introduction (max intro_description_length_limit »¹ UTF-8 characters).
	//
	// Links:
	//  1) https://core.telegram.org/api/config#intro-description-length-limit
	Description string
	// Optional introduction sticker¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers
	//
	// Use SetSticker and GetSticker helpers.
	Sticker DocumentClass
}

// BusinessIntroTypeID is TL type id of BusinessIntro.
const BusinessIntroTypeID = 0x5a0a066d

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

func ( *BusinessIntro) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Sticker == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BusinessIntro from given interface.
func ( *BusinessIntro) ( interface {
	() ( string)
	() ( string)
	() ( DocumentClass,  bool)
}) {
	.Title = .()
	.Description = .()
	if ,  := .();  {
		.Sticker = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *BusinessIntro) () tdp.Type {
	 := tdp.Type{
		Name: "businessIntro",
		ID:   BusinessIntroTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Description",
			SchemaName: "description",
		},
		{
			Name:       "Sticker",
			SchemaName: "sticker",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BusinessIntro) () {
	if !(.Sticker == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *BusinessIntro) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessIntro#5a0a066d as nil")
	}
	.PutID(BusinessIntroTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BusinessIntro) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessIntro#5a0a066d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode businessIntro#5a0a066d: field flags: %w", )
	}
	.PutString(.Title)
	.PutString(.Description)
	if .Flags.Has(0) {
		if .Sticker == nil {
			return fmt.Errorf("unable to encode businessIntro#5a0a066d: field sticker is nil")
		}
		if  := .Sticker.Encode();  != nil {
			return fmt.Errorf("unable to encode businessIntro#5a0a066d: field sticker: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BusinessIntro) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessIntro#5a0a066d to nil")
	}
	if  := .ConsumeID(BusinessIntroTypeID);  != nil {
		return fmt.Errorf("unable to decode businessIntro#5a0a066d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BusinessIntro) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessIntro#5a0a066d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode businessIntro#5a0a066d: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode businessIntro#5a0a066d: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode businessIntro#5a0a066d: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(0) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode businessIntro#5a0a066d: field sticker: %w", )
		}
		.Sticker = 
	}
	return nil
}

// GetTitle returns value of Title field.
func ( *BusinessIntro) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetDescription returns value of Description field.
func ( *BusinessIntro) () ( string) {
	if  == nil {
		return
	}
	return .Description
}

// SetSticker sets value of Sticker conditional field.
func ( *BusinessIntro) ( DocumentClass) {
	.Flags.Set(0)
	.Sticker = 
}

// GetSticker returns value of Sticker conditional field and
// boolean which is true if field was set.
func ( *BusinessIntro) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Sticker, true
}

// GetStickerAsNotEmpty returns mapped value of Sticker conditional field and
// boolean which is true if field was set.
func ( *BusinessIntro) () (*Document, bool) {
	if ,  := .GetSticker();  {
		return .AsNotEmpty()
	}
	return nil, false
}