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

// ChannelsCreateChannelRequest represents TL type `channels.createChannel#91006707`.
// Create a supergroup/channel¹.
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.createChannel for reference.
type ChannelsCreateChannelRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to create a channel¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Broadcast bool
	// Whether to create a supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Megagroup bool
	// Whether the supergroup is being created to import messages from a foreign chat service
	// using messages.initHistoryImport¹
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.initHistoryImport
	ForImport bool
	// Whether to create a forum¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	Forum bool
	// Channel title
	Title string
	// Channel description
	About string
	// Geogroup location, see here »¹ for more info on geogroups.
	//
	// Links:
	//  1) https://core.telegram.org/api/nearby
	//
	// Use SetGeoPoint and GetGeoPoint helpers.
	GeoPoint InputGeoPointClass
	// Geogroup address, see here »¹ for more info on geogroups.
	//
	// Links:
	//  1) https://core.telegram.org/api/nearby
	//
	// Use SetAddress and GetAddress helpers.
	Address string
	// Time-to-live of all messages that will be sent in the supergroup: once message
	// date+message.ttl_period === time(), the message will be deleted on the server, and
	// must be deleted locally as well. You can use messages.setDefaultHistoryTTL¹ to edit
	// this value later.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.setDefaultHistoryTTL
	//
	// Use SetTTLPeriod and GetTTLPeriod helpers.
	TTLPeriod int
}

// ChannelsCreateChannelRequestTypeID is TL type id of ChannelsCreateChannelRequest.
const ChannelsCreateChannelRequestTypeID = 0x91006707

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

func ( *ChannelsCreateChannelRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Broadcast == false) {
		return false
	}
	if !(.Megagroup == false) {
		return false
	}
	if !(.ForImport == false) {
		return false
	}
	if !(.Forum == false) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.About == "") {
		return false
	}
	if !(.GeoPoint == nil) {
		return false
	}
	if !(.Address == "") {
		return false
	}
	if !(.TTLPeriod == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsCreateChannelRequest from given interface.
func ( *ChannelsCreateChannelRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string)
	() ( string)
	() ( InputGeoPointClass,  bool)
	() ( string,  bool)
	() ( int,  bool)
}) {
	.Broadcast = .()
	.Megagroup = .()
	.ForImport = .()
	.Forum = .()
	.Title = .()
	.About = .()
	if ,  := .();  {
		.GeoPoint = 
	}

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

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

}

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

// TypeName returns name of type in TL schema.
func (*ChannelsCreateChannelRequest) () string {
	return "channels.createChannel"
}

// TypeInfo returns info about TL type.
func ( *ChannelsCreateChannelRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.createChannel",
		ID:   ChannelsCreateChannelRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Broadcast",
			SchemaName: "broadcast",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Megagroup",
			SchemaName: "megagroup",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ForImport",
			SchemaName: "for_import",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Forum",
			SchemaName: "forum",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "About",
			SchemaName: "about",
		},
		{
			Name:       "GeoPoint",
			SchemaName: "geo_point",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Address",
			SchemaName: "address",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "TTLPeriod",
			SchemaName: "ttl_period",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsCreateChannelRequest) () {
	if !(.Broadcast == false) {
		.Flags.Set(0)
	}
	if !(.Megagroup == false) {
		.Flags.Set(1)
	}
	if !(.ForImport == false) {
		.Flags.Set(3)
	}
	if !(.Forum == false) {
		.Flags.Set(5)
	}
	if !(.GeoPoint == nil) {
		.Flags.Set(2)
	}
	if !(.Address == "") {
		.Flags.Set(2)
	}
	if !(.TTLPeriod == 0) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsCreateChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.createChannel#91006707 as nil")
	}
	.PutID(ChannelsCreateChannelRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsCreateChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.createChannel#91006707 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.createChannel#91006707: field flags: %w", )
	}
	.PutString(.Title)
	.PutString(.About)
	if .Flags.Has(2) {
		if .GeoPoint == nil {
			return fmt.Errorf("unable to encode channels.createChannel#91006707: field geo_point is nil")
		}
		if  := .GeoPoint.Encode();  != nil {
			return fmt.Errorf("unable to encode channels.createChannel#91006707: field geo_point: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutString(.Address)
	}
	if .Flags.Has(4) {
		.PutInt(.TTLPeriod)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsCreateChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.createChannel#91006707 to nil")
	}
	if  := .ConsumeID(ChannelsCreateChannelRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.createChannel#91006707: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsCreateChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.createChannel#91006707 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field flags: %w", )
		}
	}
	.Broadcast = .Flags.Has(0)
	.Megagroup = .Flags.Has(1)
	.ForImport = .Flags.Has(3)
	.Forum = .Flags.Has(5)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field about: %w", )
		}
		.About = 
	}
	if .Flags.Has(2) {
		,  := DecodeInputGeoPoint()
		if  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field geo_point: %w", )
		}
		.GeoPoint = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field address: %w", )
		}
		.Address = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.createChannel#91006707: field ttl_period: %w", )
		}
		.TTLPeriod = 
	}
	return nil
}

// SetBroadcast sets value of Broadcast conditional field.
func ( *ChannelsCreateChannelRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Broadcast = true
	} else {
		.Flags.Unset(0)
		.Broadcast = false
	}
}

// GetBroadcast returns value of Broadcast conditional field.
func ( *ChannelsCreateChannelRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetMegagroup sets value of Megagroup conditional field.
func ( *ChannelsCreateChannelRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Megagroup = true
	} else {
		.Flags.Unset(1)
		.Megagroup = false
	}
}

// GetMegagroup returns value of Megagroup conditional field.
func ( *ChannelsCreateChannelRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetForImport sets value of ForImport conditional field.
func ( *ChannelsCreateChannelRequest) ( bool) {
	if  {
		.Flags.Set(3)
		.ForImport = true
	} else {
		.Flags.Unset(3)
		.ForImport = false
	}
}

// GetForImport returns value of ForImport conditional field.
func ( *ChannelsCreateChannelRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetForum sets value of Forum conditional field.
func ( *ChannelsCreateChannelRequest) ( bool) {
	if  {
		.Flags.Set(5)
		.Forum = true
	} else {
		.Flags.Unset(5)
		.Forum = false
	}
}

// GetForum returns value of Forum conditional field.
func ( *ChannelsCreateChannelRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

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

// GetAbout returns value of About field.
func ( *ChannelsCreateChannelRequest) () ( string) {
	if  == nil {
		return
	}
	return .About
}

// SetGeoPoint sets value of GeoPoint conditional field.
func ( *ChannelsCreateChannelRequest) ( InputGeoPointClass) {
	.Flags.Set(2)
	.GeoPoint = 
}

// GetGeoPoint returns value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *ChannelsCreateChannelRequest) () ( InputGeoPointClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .GeoPoint, true
}

// SetAddress sets value of Address conditional field.
func ( *ChannelsCreateChannelRequest) ( string) {
	.Flags.Set(2)
	.Address = 
}

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

// SetTTLPeriod sets value of TTLPeriod conditional field.
func ( *ChannelsCreateChannelRequest) ( int) {
	.Flags.Set(4)
	.TTLPeriod = 
}

// GetTTLPeriod returns value of TTLPeriod conditional field and
// boolean which is true if field was set.
func ( *ChannelsCreateChannelRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .TTLPeriod, true
}

// GetGeoPointAsNotEmpty returns mapped value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *ChannelsCreateChannelRequest) () (*InputGeoPoint, bool) {
	if ,  := .GetGeoPoint();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// ChannelsCreateChannel invokes method channels.createChannel#91006707 returning error if any.
// Create a supergroup/channel¹.
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 ADDRESS_INVALID: The specified geopoint address is invalid.
//	400 CHANNELS_ADMIN_LOCATED_TOO_MUCH: The user has reached the limit of public geogroups.
//	400 CHANNELS_TOO_MUCH: You have joined too many channels/supergroups.
//	400 CHAT_ABOUT_TOO_LONG: Chat about too long.
//	500 CHAT_INVALID: Invalid chat.
//	400 CHAT_TITLE_EMPTY: No chat title provided.
//	400 TTL_PERIOD_INVALID: The specified TTL period is invalid.
//	406 USER_RESTRICTED: You're spamreported, you can't create channels or chats.
//
// See https://core.telegram.org/method/channels.createChannel for reference.
func ( *Client) ( context.Context,  *ChannelsCreateChannelRequest) (UpdatesClass, error) {
	var  UpdatesBox

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