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

// CommunitiesCreateRequest represents TL type `communities.create#a63859ec`.
//
// See https://core.telegram.org/method/communities.create for reference.
type CommunitiesCreateRequest struct {
	// Flags field of CommunitiesCreateRequest.
	Flags bin.Fields
	// Hidden field of CommunitiesCreateRequest.
	Hidden bool
	// Title field of CommunitiesCreateRequest.
	Title string
	// About field of CommunitiesCreateRequest.
	//
	// Use SetAbout and GetAbout helpers.
	About string
	// Peer field of CommunitiesCreateRequest.
	Peer InputPeerClass
}

// CommunitiesCreateRequestTypeID is TL type id of CommunitiesCreateRequest.
const CommunitiesCreateRequestTypeID = 0xa63859ec

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

func ( *CommunitiesCreateRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Hidden == false) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.About == "") {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CommunitiesCreateRequest from given interface.
func ( *CommunitiesCreateRequest) ( interface {
	() ( bool)
	() ( string)
	() ( string,  bool)
	() ( InputPeerClass)
}) {
	.Hidden = .()
	.Title = .()
	if ,  := .();  {
		.About = 
	}

	.Peer = .()
}

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

// TypeName returns name of type in TL schema.
func (*CommunitiesCreateRequest) () string {
	return "communities.create"
}

// TypeInfo returns info about TL type.
func ( *CommunitiesCreateRequest) () tdp.Type {
	 := tdp.Type{
		Name: "communities.create",
		ID:   CommunitiesCreateRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hidden",
			SchemaName: "hidden",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "About",
			SchemaName: "about",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *CommunitiesCreateRequest) () {
	if !(.Hidden == false) {
		.Flags.Set(1)
	}
	if !(.About == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *CommunitiesCreateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.create#a63859ec as nil")
	}
	.PutID(CommunitiesCreateRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CommunitiesCreateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.create#a63859ec as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.create#a63859ec: field flags: %w", )
	}
	.PutString(.Title)
	if .Flags.Has(0) {
		.PutString(.About)
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode communities.create#a63859ec: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.create#a63859ec: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *CommunitiesCreateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.create#a63859ec to nil")
	}
	if  := .ConsumeID(CommunitiesCreateRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode communities.create#a63859ec: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *CommunitiesCreateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.create#a63859ec to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode communities.create#a63859ec: field flags: %w", )
		}
	}
	.Hidden = .Flags.Has(1)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode communities.create#a63859ec: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode communities.create#a63859ec: field about: %w", )
		}
		.About = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode communities.create#a63859ec: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// SetHidden sets value of Hidden conditional field.
func ( *CommunitiesCreateRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Hidden = true
	} else {
		.Flags.Unset(1)
		.Hidden = false
	}
}

// GetHidden returns value of Hidden conditional field.
func ( *CommunitiesCreateRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// SetAbout sets value of About conditional field.
func ( *CommunitiesCreateRequest) ( string) {
	.Flags.Set(0)
	.About = 
}

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

// GetPeer returns value of Peer field.
func ( *CommunitiesCreateRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// CommunitiesCreate invokes method communities.create#a63859ec returning error if any.
//
// See https://core.telegram.org/method/communities.create for reference.
func ( *Client) ( context.Context,  *CommunitiesCreateRequest) (UpdatesClass, error) {
	var  UpdatesBox

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