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

// BotsCreateBotRequest represents TL type `bots.createBot#e5b17f2b`.
// Create a managed bot »¹ owned by the current user and controlled by the specified
// manager bot.
//
// Links:
//  1. https://core.telegram.org/api/bots/managed-bots#creating-a-managed-bot
//
// See https://core.telegram.org/method/bots.createBot for reference.
type BotsCreateBotRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set only if the creation prompt was opened from a managed bot creation request deep
	// link »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/links#managed-bot-creation-request-links
	ViaDeeplink bool
	// Display name of the bot, 1–64 characters
	Name string
	// Username for the bot, as validated by bots.checkUsername¹
	//
	// Links:
	//  1) https://core.telegram.org/method/bots.checkUsername
	Username string
	// The manager bot that will control the created bot; must have the user¹
	// bot_can_manage_bots flag set
	//
	// Links:
	//  1) https://core.telegram.org/constructor/user
	ManagerID InputUserClass
}

// BotsCreateBotRequestTypeID is TL type id of BotsCreateBotRequest.
const BotsCreateBotRequestTypeID = 0xe5b17f2b

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

func ( *BotsCreateBotRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ViaDeeplink == false) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Username == "") {
		return false
	}
	if !(.ManagerID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BotsCreateBotRequest from given interface.
func ( *BotsCreateBotRequest) ( interface {
	() ( bool)
	() ( string)
	() ( string)
	() ( InputUserClass)
}) {
	.ViaDeeplink = .()
	.Name = .()
	.Username = .()
	.ManagerID = .()
}

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

// TypeName returns name of type in TL schema.
func (*BotsCreateBotRequest) () string {
	return "bots.createBot"
}

// TypeInfo returns info about TL type.
func ( *BotsCreateBotRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.createBot",
		ID:   BotsCreateBotRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ViaDeeplink",
			SchemaName: "via_deeplink",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "Username",
			SchemaName: "username",
		},
		{
			Name:       "ManagerID",
			SchemaName: "manager_id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BotsCreateBotRequest) () {
	if !(.ViaDeeplink == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *BotsCreateBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.createBot#e5b17f2b as nil")
	}
	.PutID(BotsCreateBotRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsCreateBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.createBot#e5b17f2b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.createBot#e5b17f2b: field flags: %w", )
	}
	.PutString(.Name)
	.PutString(.Username)
	if .ManagerID == nil {
		return fmt.Errorf("unable to encode bots.createBot#e5b17f2b: field manager_id is nil")
	}
	if  := .ManagerID.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.createBot#e5b17f2b: field manager_id: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsCreateBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.createBot#e5b17f2b to nil")
	}
	if  := .ConsumeID(BotsCreateBotRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.createBot#e5b17f2b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsCreateBotRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.createBot#e5b17f2b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode bots.createBot#e5b17f2b: field flags: %w", )
		}
	}
	.ViaDeeplink = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.createBot#e5b17f2b: field name: %w", )
		}
		.Name = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.createBot#e5b17f2b: field username: %w", )
		}
		.Username = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.createBot#e5b17f2b: field manager_id: %w", )
		}
		.ManagerID = 
	}
	return nil
}

// SetViaDeeplink sets value of ViaDeeplink conditional field.
func ( *BotsCreateBotRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ViaDeeplink = true
	} else {
		.Flags.Unset(0)
		.ViaDeeplink = false
	}
}

// GetViaDeeplink returns value of ViaDeeplink conditional field.
func ( *BotsCreateBotRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetName returns value of Name field.
func ( *BotsCreateBotRequest) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetUsername returns value of Username field.
func ( *BotsCreateBotRequest) () ( string) {
	if  == nil {
		return
	}
	return .Username
}

// GetManagerID returns value of ManagerID field.
func ( *BotsCreateBotRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .ManagerID
}

// BotsCreateBot invokes method bots.createBot#e5b17f2b returning error if any.
// Create a managed bot »¹ owned by the current user and controlled by the specified
// manager bot.
//
// Links:
//  1. https://core.telegram.org/api/bots/managed-bots#creating-a-managed-bot
//
// Possible errors:
//
//	400 BOT_CREATE_LIMIT_EXCEEDED: The current user already owns the maximum allowed number of owned bots, as specified by bots_create_limit_default » and bots_create_limit_premium »; if the current user doesn't have Telegram Premium, upgrading to Premium will allow them to create more bots.
//	400 MANAGER_INVALID: The specified manager bot is invalid.
//	400 MANAGER_PERMISSION_MISSING: The specified manager bot does not have the user.bot_can_manage_bots flag set.
//	400 NAME_INVALID: The specified bot name is invalid.
//	400 USERNAME_INVALID: The provided username is not valid.
//	400 USERNAME_OCCUPIED: The provided username is already occupied.
//	400 USERNAME_SUFFIX_MISSING: The required bot suffix is missing from the passed username.
//
// See https://core.telegram.org/method/bots.createBot for reference.
func ( *Client) ( context.Context,  *BotsCreateBotRequest) (UserClass, error) {
	var  UserBox

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