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

// ContactsSetBlockedRequest represents TL type `contacts.setBlocked#94c65c76`.
// Replace the contents of an entire blocklist, see here for more info »¹.
//
// Links:
//  1. https://core.telegram.org/api/block
//
// See https://core.telegram.org/method/contacts.setBlocked for reference.
type ContactsSetBlockedRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to edit the story blocklist; if not set, will edit the main blocklist. See
	// here »¹ for differences between the two.
	//
	// Links:
	//  1) https://core.telegram.org/api/block
	MyStoriesFrom bool
	// Full content of the blocklist.
	ID []InputPeerClass
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// ContactsSetBlockedRequestTypeID is TL type id of ContactsSetBlockedRequest.
const ContactsSetBlockedRequestTypeID = 0x94c65c76

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

func ( *ContactsSetBlockedRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MyStoriesFrom == false) {
		return false
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsSetBlockedRequest from given interface.
func ( *ContactsSetBlockedRequest) ( interface {
	() ( bool)
	() ( []InputPeerClass)
	() ( int)
}) {
	.MyStoriesFrom = .()
	.ID = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*ContactsSetBlockedRequest) () string {
	return "contacts.setBlocked"
}

// TypeInfo returns info about TL type.
func ( *ContactsSetBlockedRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.setBlocked",
		ID:   ContactsSetBlockedRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MyStoriesFrom",
			SchemaName: "my_stories_from",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ContactsSetBlockedRequest) () {
	if !(.MyStoriesFrom == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ContactsSetBlockedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.setBlocked#94c65c76 as nil")
	}
	.PutID(ContactsSetBlockedRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsSetBlockedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.setBlocked#94c65c76 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.setBlocked#94c65c76: field flags: %w", )
	}
	.PutVectorHeader(len(.ID))
	for ,  := range .ID {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.setBlocked#94c65c76: field id element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.setBlocked#94c65c76: field id element with index %d: %w", , )
		}
	}
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactsSetBlockedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.setBlocked#94c65c76 to nil")
	}
	if  := .ConsumeID(ContactsSetBlockedRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode contacts.setBlocked#94c65c76: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactsSetBlockedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.setBlocked#94c65c76 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode contacts.setBlocked#94c65c76: field flags: %w", )
		}
	}
	.MyStoriesFrom = .Flags.Has(0)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.setBlocked#94c65c76: field id: %w", )
		}

		if  > 0 {
			.ID = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode contacts.setBlocked#94c65c76: field id: %w", )
			}
			.ID = append(.ID, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.setBlocked#94c65c76: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetMyStoriesFrom sets value of MyStoriesFrom conditional field.
func ( *ContactsSetBlockedRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.MyStoriesFrom = true
	} else {
		.Flags.Unset(0)
		.MyStoriesFrom = false
	}
}

// GetMyStoriesFrom returns value of MyStoriesFrom conditional field.
func ( *ContactsSetBlockedRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetID returns value of ID field.
func ( *ContactsSetBlockedRequest) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .ID
}

// GetLimit returns value of Limit field.
func ( *ContactsSetBlockedRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// MapID returns field ID wrapped in InputPeerClassArray helper.
func ( *ContactsSetBlockedRequest) () ( InputPeerClassArray) {
	return InputPeerClassArray(.ID)
}

// ContactsSetBlocked invokes method contacts.setBlocked#94c65c76 returning error if any.
// Replace the contents of an entire blocklist, see here for more info »¹.
//
// Links:
//  1. https://core.telegram.org/api/block
//
// See https://core.telegram.org/method/contacts.setBlocked for reference.
func ( *Client) ( context.Context,  *ContactsSetBlockedRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}