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

// ChannelsGetAdminedPublicChannelsRequest represents TL type `channels.getAdminedPublicChannels#f8b036af`.
// Get channels/supergroups/geogroups¹ we're admin in. Usually called when the user
// exceeds the limit² for owned public channels/supergroups/geogroups³, and the user is
// given the choice to remove one of his channels/supergroups/geogroups.
//
// Links:
//  1. https://core.telegram.org/api/channel
//  2. https://core.telegram.org/constructor/config
//  3. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.getAdminedPublicChannels for reference.
type ChannelsGetAdminedPublicChannelsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Get geogroups
	ByLocation bool
	// If set and the user has reached the limit of owned public
	// channels/supergroups/geogroups¹, instead of returning the channel list one of the
	// specified errors² will be returned.Useful to check if a new public channel can indeed
	// be created, even before asking the user to enter a channel username to use in channels
	// checkUsername³/channels.updateUsername⁴.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	//  2) https://core.telegram.org#possible-errors
	//  3) https://core.telegram.org/method/channels.checkUsername
	//  4) https://core.telegram.org/method/channels.updateUsername
	CheckLimit bool
}

// ChannelsGetAdminedPublicChannelsRequestTypeID is TL type id of ChannelsGetAdminedPublicChannelsRequest.
const ChannelsGetAdminedPublicChannelsRequestTypeID = 0xf8b036af

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

func ( *ChannelsGetAdminedPublicChannelsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ByLocation == false) {
		return false
	}
	if !(.CheckLimit == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetAdminedPublicChannelsRequest from given interface.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( interface {
	() ( bool)
	() ( bool)
}) {
	.ByLocation = .()
	.CheckLimit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsGetAdminedPublicChannelsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getAdminedPublicChannels",
		ID:   ChannelsGetAdminedPublicChannelsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ByLocation",
			SchemaName: "by_location",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "CheckLimit",
			SchemaName: "check_limit",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsGetAdminedPublicChannelsRequest) () {
	if !(.ByLocation == false) {
		.Flags.Set(0)
	}
	if !(.CheckLimit == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getAdminedPublicChannels#f8b036af as nil")
	}
	.PutID(ChannelsGetAdminedPublicChannelsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getAdminedPublicChannels#f8b036af as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getAdminedPublicChannels#f8b036af: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getAdminedPublicChannels#f8b036af to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.getAdminedPublicChannels#f8b036af: field flags: %w", )
		}
	}
	.ByLocation = .Flags.Has(0)
	.CheckLimit = .Flags.Has(1)
	return nil
}

// SetByLocation sets value of ByLocation conditional field.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ByLocation = true
	} else {
		.Flags.Unset(0)
		.ByLocation = false
	}
}

// GetByLocation returns value of ByLocation conditional field.
func ( *ChannelsGetAdminedPublicChannelsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetCheckLimit sets value of CheckLimit conditional field.
func ( *ChannelsGetAdminedPublicChannelsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.CheckLimit = true
	} else {
		.Flags.Unset(1)
		.CheckLimit = false
	}
}

// GetCheckLimit returns value of CheckLimit conditional field.
func ( *ChannelsGetAdminedPublicChannelsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// ChannelsGetAdminedPublicChannels invokes method channels.getAdminedPublicChannels#f8b036af returning error if any.
// Get channels/supergroups/geogroups¹ we're admin in. Usually called when the user
// exceeds the limit² for owned public channels/supergroups/geogroups³, and the user is
// given the choice to remove one of his channels/supergroups/geogroups.
//
// Links:
//  1. https://core.telegram.org/api/channel
//  2. https://core.telegram.org/constructor/config
//  3. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNELS_ADMIN_LOCATED_TOO_MUCH: The user has reached the limit of public geogroups.
//	400 CHANNELS_ADMIN_PUBLIC_TOO_MUCH: You're admin of too many public channels, make some channels private to change the username of this channel.
//
// See https://core.telegram.org/method/channels.getAdminedPublicChannels for reference.
func ( *Client) ( context.Context,  *ChannelsGetAdminedPublicChannelsRequest) (MessagesChatsClass, error) {
	var  MessagesChatsBox

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