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

// StoriesGetAllStoriesRequest represents TL type `stories.getAllStories#eeb0d625`.
// Fetch the List of active (or active and hidden) stories, see here »¹ for more info
// on watching stories.
//
// Links:
//  1. https://core.telegram.org/api/stories#watching-stories
//
// See https://core.telegram.org/method/stories.getAllStories for reference.
type StoriesGetAllStoriesRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If next and state are both set, uses the passed state to paginate to the next results;
	// if neither state nor next are set, fetches the initial page; if state is set and next
	// is not set, check for changes in the active/hidden peerset, see here »¹ for more
	// info on the full flow.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#watching-stories
	Next bool
	// If set, fetches the hidden active story list, otherwise fetches the active story list,
	// see here »¹ for more info on the full flow.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#watching-stories
	Hidden bool
	// If next and state are both set, uses the passed state to paginate to the next results;
	// if neither state nor next are set, fetches the initial page; if state is set and next
	// is not set, check for changes in the active/hidden peerset, see here »¹ for more
	// info on the full flow.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#watching-stories
	//
	// Use SetState and GetState helpers.
	State string
}

// StoriesGetAllStoriesRequestTypeID is TL type id of StoriesGetAllStoriesRequest.
const StoriesGetAllStoriesRequestTypeID = 0xeeb0d625

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

func ( *StoriesGetAllStoriesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Next == false) {
		return false
	}
	if !(.Hidden == false) {
		return false
	}
	if !(.State == "") {
		return false
	}

	return true
}

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

// FillFrom fills StoriesGetAllStoriesRequest from given interface.
func ( *StoriesGetAllStoriesRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( string,  bool)
}) {
	.Next = .()
	.Hidden = .()
	if ,  := .();  {
		.State = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesGetAllStoriesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.getAllStories",
		ID:   StoriesGetAllStoriesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Next",
			SchemaName: "next",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Hidden",
			SchemaName: "hidden",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "State",
			SchemaName: "state",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *StoriesGetAllStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getAllStories#eeb0d625 as nil")
	}
	.PutID(StoriesGetAllStoriesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesGetAllStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getAllStories#eeb0d625 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.getAllStories#eeb0d625: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.State)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesGetAllStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getAllStories#eeb0d625 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.getAllStories#eeb0d625: field flags: %w", )
		}
	}
	.Next = .Flags.Has(1)
	.Hidden = .Flags.Has(2)
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getAllStories#eeb0d625: field state: %w", )
		}
		.State = 
	}
	return nil
}

// SetNext sets value of Next conditional field.
func ( *StoriesGetAllStoriesRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Next = true
	} else {
		.Flags.Unset(1)
		.Next = false
	}
}

// GetNext returns value of Next conditional field.
func ( *StoriesGetAllStoriesRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

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

// SetState sets value of State conditional field.
func ( *StoriesGetAllStoriesRequest) ( string) {
	.Flags.Set(0)
	.State = 
}

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

// StoriesGetAllStories invokes method stories.getAllStories#eeb0d625 returning error if any.
// Fetch the List of active (or active and hidden) stories, see here »¹ for more info
// on watching stories.
//
// Links:
//  1. https://core.telegram.org/api/stories#watching-stories
//
// See https://core.telegram.org/method/stories.getAllStories for reference.
func ( *Client) ( context.Context,  *StoriesGetAllStoriesRequest) (StoriesAllStoriesClass, error) {
	var  StoriesAllStoriesBox

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