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

// ConnectedBot represents TL type `connectedBot#33ed001`.
// Contains info about a connected business bot »¹.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//
// See https://core.telegram.org/constructor/connectedBot for reference.
type ConnectedBot struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// ID of the connected bot
	BotID int64
	// Specifies the private chats that a connected business bot »¹ may receive messages
	// and interact with.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/connected-business-bots
	Recipients BusinessBotRecipients
	// Business bot rights.
	Rights BusinessBotRights
	// Device field of ConnectedBot.
	//
	// Use SetDevice and GetDevice helpers.
	Device string
	// Date field of ConnectedBot.
	//
	// Use SetDate and GetDate helpers.
	Date int
	// Location field of ConnectedBot.
	//
	// Use SetLocation and GetLocation helpers.
	Location string
}

// ConnectedBotTypeID is TL type id of ConnectedBot.
const ConnectedBotTypeID = 0x33ed001

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

func ( *ConnectedBot) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.Recipients.Zero()) {
		return false
	}
	if !(.Rights.Zero()) {
		return false
	}
	if !(.Device == "") {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Location == "") {
		return false
	}

	return true
}

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

// FillFrom fills ConnectedBot from given interface.
func ( *ConnectedBot) ( interface {
	() ( int64)
	() ( BusinessBotRecipients)
	() ( BusinessBotRights)
	() ( string,  bool)
	() ( int,  bool)
	() ( string,  bool)
}) {
	.BotID = .()
	.Recipients = .()
	.Rights = .()
	if ,  := .();  {
		.Device = 
	}

	if ,  := .();  {
		.Date = 
	}

	if ,  := .();  {
		.Location = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *ConnectedBot) () tdp.Type {
	 := tdp.Type{
		Name: "connectedBot",
		ID:   ConnectedBotTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "Recipients",
			SchemaName: "recipients",
		},
		{
			Name:       "Rights",
			SchemaName: "rights",
		},
		{
			Name:       "Device",
			SchemaName: "device",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Date",
			SchemaName: "date",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Location",
			SchemaName: "location",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ConnectedBot) () {
	if !(.Device == "") {
		.Flags.Set(0)
	}
	if !(.Date == 0) {
		.Flags.Set(1)
	}
	if !(.Location == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *ConnectedBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode connectedBot#33ed001 as nil")
	}
	.PutID(ConnectedBotTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ConnectedBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode connectedBot#33ed001 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode connectedBot#33ed001: field flags: %w", )
	}
	.PutLong(.BotID)
	if  := .Recipients.Encode();  != nil {
		return fmt.Errorf("unable to encode connectedBot#33ed001: field recipients: %w", )
	}
	if  := .Rights.Encode();  != nil {
		return fmt.Errorf("unable to encode connectedBot#33ed001: field rights: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Device)
	}
	if .Flags.Has(1) {
		.PutInt(.Date)
	}
	if .Flags.Has(2) {
		.PutString(.Location)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ConnectedBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode connectedBot#33ed001 to nil")
	}
	if  := .ConsumeID(ConnectedBotTypeID);  != nil {
		return fmt.Errorf("unable to decode connectedBot#33ed001: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ConnectedBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode connectedBot#33ed001 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		if  := .Recipients.Decode();  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field recipients: %w", )
		}
	}
	{
		if  := .Rights.Decode();  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field rights: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field device: %w", )
		}
		.Device = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field date: %w", )
		}
		.Date = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode connectedBot#33ed001: field location: %w", )
		}
		.Location = 
	}
	return nil
}

// GetBotID returns value of BotID field.
func ( *ConnectedBot) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

// GetRecipients returns value of Recipients field.
func ( *ConnectedBot) () ( BusinessBotRecipients) {
	if  == nil {
		return
	}
	return .Recipients
}

// GetRights returns value of Rights field.
func ( *ConnectedBot) () ( BusinessBotRights) {
	if  == nil {
		return
	}
	return .Rights
}

// SetDevice sets value of Device conditional field.
func ( *ConnectedBot) ( string) {
	.Flags.Set(0)
	.Device = 
}

// GetDevice returns value of Device conditional field and
// boolean which is true if field was set.
func ( *ConnectedBot) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Device, true
}

// SetDate sets value of Date conditional field.
func ( *ConnectedBot) ( int) {
	.Flags.Set(1)
	.Date = 
}

// GetDate returns value of Date conditional field and
// boolean which is true if field was set.
func ( *ConnectedBot) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Date, true
}

// SetLocation sets value of Location conditional field.
func ( *ConnectedBot) ( string) {
	.Flags.Set(2)
	.Location = 
}

// GetLocation returns value of Location conditional field and
// boolean which is true if field was set.
func ( *ConnectedBot) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Location, true
}