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

// StoriesStartLiveRequest represents TL type `stories.startLive#d069ccde`.
//
// See https://core.telegram.org/method/stories.startLive for reference.
type StoriesStartLiveRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Pinned field of StoriesStartLiveRequest.
	Pinned bool
	// Noforwards field of StoriesStartLiveRequest.
	Noforwards bool
	// RtmpStream field of StoriesStartLiveRequest.
	RtmpStream bool
	// Peer field of StoriesStartLiveRequest.
	Peer InputPeerClass
	// Caption field of StoriesStartLiveRequest.
	//
	// Use SetCaption and GetCaption helpers.
	Caption string
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// PrivacyRules field of StoriesStartLiveRequest.
	PrivacyRules []InputPrivacyRuleClass
	// RandomID field of StoriesStartLiveRequest.
	RandomID int64
	// MessagesEnabled field of StoriesStartLiveRequest.
	//
	// Use SetMessagesEnabled and GetMessagesEnabled helpers.
	MessagesEnabled bool
	// SendPaidMessagesStars field of StoriesStartLiveRequest.
	//
	// Use SetSendPaidMessagesStars and GetSendPaidMessagesStars helpers.
	SendPaidMessagesStars int64
}

// StoriesStartLiveRequestTypeID is TL type id of StoriesStartLiveRequest.
const StoriesStartLiveRequestTypeID = 0xd069ccde

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

func ( *StoriesStartLiveRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.RtmpStream == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Caption == "") {
		return false
	}
	if !(.Entities == nil) {
		return false
	}
	if !(.PrivacyRules == nil) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.MessagesEnabled == false) {
		return false
	}
	if !(.SendPaidMessagesStars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesStartLiveRequest from given interface.
func ( *StoriesStartLiveRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( string,  bool)
	() ( []MessageEntityClass,  bool)
	() ( []InputPrivacyRuleClass)
	() ( int64)
	() ( bool,  bool)
	() ( int64,  bool)
}) {
	.Pinned = .()
	.Noforwards = .()
	.RtmpStream = .()
	.Peer = .()
	if ,  := .();  {
		.Caption = 
	}

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

	.PrivacyRules = .()
	.RandomID = .()
	if ,  := .();  {
		.MessagesEnabled = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*StoriesStartLiveRequest) () string {
	return "stories.startLive"
}

// TypeInfo returns info about TL type.
func ( *StoriesStartLiveRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.startLive",
		ID:   StoriesStartLiveRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pinned",
			SchemaName: "pinned",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "RtmpStream",
			SchemaName: "rtmp_stream",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Caption",
			SchemaName: "caption",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PrivacyRules",
			SchemaName: "privacy_rules",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "MessagesEnabled",
			SchemaName: "messages_enabled",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "SendPaidMessagesStars",
			SchemaName: "send_paid_messages_stars",
			Null:       !.Flags.Has(7),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoriesStartLiveRequest) () {
	if !(.Pinned == false) {
		.Flags.Set(2)
	}
	if !(.Noforwards == false) {
		.Flags.Set(4)
	}
	if !(.RtmpStream == false) {
		.Flags.Set(5)
	}
	if !(.Caption == "") {
		.Flags.Set(0)
	}
	if !(.Entities == nil) {
		.Flags.Set(1)
	}
	if !(.MessagesEnabled == false) {
		.Flags.Set(6)
	}
	if !(.SendPaidMessagesStars == 0) {
		.Flags.Set(7)
	}
}

// Encode implements bin.Encoder.
func ( *StoriesStartLiveRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.startLive#d069ccde as nil")
	}
	.PutID(StoriesStartLiveRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesStartLiveRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.startLive#d069ccde as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.startLive#d069ccde: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stories.startLive#d069ccde: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.startLive#d069ccde: field peer: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Caption)
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.Entities))
		for ,  := range .Entities {
			if  == nil {
				return fmt.Errorf("unable to encode stories.startLive#d069ccde: field entities element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode stories.startLive#d069ccde: field entities element with index %d: %w", , )
			}
		}
	}
	.PutVectorHeader(len(.PrivacyRules))
	for ,  := range .PrivacyRules {
		if  == nil {
			return fmt.Errorf("unable to encode stories.startLive#d069ccde: field privacy_rules element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.startLive#d069ccde: field privacy_rules element with index %d: %w", , )
		}
	}
	.PutLong(.RandomID)
	if .Flags.Has(6) {
		.PutBool(.MessagesEnabled)
	}
	if .Flags.Has(7) {
		.PutLong(.SendPaidMessagesStars)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StoriesStartLiveRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.startLive#d069ccde to nil")
	}
	if  := .ConsumeID(StoriesStartLiveRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stories.startLive#d069ccde: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StoriesStartLiveRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.startLive#d069ccde to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field flags: %w", )
		}
	}
	.Pinned = .Flags.Has(2)
	.Noforwards = .Flags.Has(4)
	.RtmpStream = .Flags.Has(5)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field caption: %w", )
		}
		.Caption = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode stories.startLive#d069ccde: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field privacy_rules: %w", )
		}

		if  > 0 {
			.PrivacyRules = make([]InputPrivacyRuleClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPrivacyRule()
			if  != nil {
				return fmt.Errorf("unable to decode stories.startLive#d069ccde: field privacy_rules: %w", )
			}
			.PrivacyRules = append(.PrivacyRules, )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field random_id: %w", )
		}
		.RandomID = 
	}
	if .Flags.Has(6) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field messages_enabled: %w", )
		}
		.MessagesEnabled = 
	}
	if .Flags.Has(7) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode stories.startLive#d069ccde: field send_paid_messages_stars: %w", )
		}
		.SendPaidMessagesStars = 
	}
	return nil
}

// SetPinned sets value of Pinned conditional field.
func ( *StoriesStartLiveRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.Pinned = true
	} else {
		.Flags.Unset(2)
		.Pinned = false
	}
}

// GetPinned returns value of Pinned conditional field.
func ( *StoriesStartLiveRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetNoforwards sets value of Noforwards conditional field.
func ( *StoriesStartLiveRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.Noforwards = true
	} else {
		.Flags.Unset(4)
		.Noforwards = false
	}
}

// GetNoforwards returns value of Noforwards conditional field.
func ( *StoriesStartLiveRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetRtmpStream sets value of RtmpStream conditional field.
func ( *StoriesStartLiveRequest) ( bool) {
	if  {
		.Flags.Set(5)
		.RtmpStream = true
	} else {
		.Flags.Unset(5)
		.RtmpStream = false
	}
}

// GetRtmpStream returns value of RtmpStream conditional field.
func ( *StoriesStartLiveRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

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

// SetCaption sets value of Caption conditional field.
func ( *StoriesStartLiveRequest) ( string) {
	.Flags.Set(0)
	.Caption = 
}

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

// SetEntities sets value of Entities conditional field.
func ( *StoriesStartLiveRequest) ( []MessageEntityClass) {
	.Flags.Set(1)
	.Entities = 
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func ( *StoriesStartLiveRequest) () ( []MessageEntityClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Entities, true
}

// GetPrivacyRules returns value of PrivacyRules field.
func ( *StoriesStartLiveRequest) () ( []InputPrivacyRuleClass) {
	if  == nil {
		return
	}
	return .PrivacyRules
}

// GetRandomID returns value of RandomID field.
func ( *StoriesStartLiveRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// SetMessagesEnabled sets value of MessagesEnabled conditional field.
func ( *StoriesStartLiveRequest) ( bool) {
	.Flags.Set(6)
	.MessagesEnabled = 
}

// GetMessagesEnabled returns value of MessagesEnabled conditional field and
// boolean which is true if field was set.
func ( *StoriesStartLiveRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .MessagesEnabled, true
}

// SetSendPaidMessagesStars sets value of SendPaidMessagesStars conditional field.
func ( *StoriesStartLiveRequest) ( int64) {
	.Flags.Set(7)
	.SendPaidMessagesStars = 
}

// GetSendPaidMessagesStars returns value of SendPaidMessagesStars conditional field and
// boolean which is true if field was set.
func ( *StoriesStartLiveRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .SendPaidMessagesStars, true
}

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *StoriesStartLiveRequest) () ( MessageEntityClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return MessageEntityClassArray(.Entities), true
}

// MapPrivacyRules returns field PrivacyRules wrapped in InputPrivacyRuleClassArray helper.
func ( *StoriesStartLiveRequest) () ( InputPrivacyRuleClassArray) {
	return InputPrivacyRuleClassArray(.PrivacyRules)
}

// StoriesStartLive invokes method stories.startLive#d069ccde returning error if any.
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/stories.startLive for reference.
func ( *Client) ( context.Context,  *StoriesStartLiveRequest) (UpdatesClass, error) {
	var  UpdatesBox

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