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

// ContactsBlockRequest represents TL type `contacts.block#2e2e8734`.
// Adds a peer to a blocklist, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/block
//
// See https://core.telegram.org/method/contacts.block for reference.
type ContactsBlockRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the peer should be added to the story blocklist; if not set, the peer will be
	// added to the main blocklist, see here »¹ for more info.
	//
	// Links:
	//  1) https://core.telegram.org/api/block
	MyStoriesFrom bool
	// Peer
	ID InputPeerClass
}

// ContactsBlockRequestTypeID is TL type id of ContactsBlockRequest.
const ContactsBlockRequestTypeID = 0x2e2e8734

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

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

	return true
}

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

// FillFrom fills ContactsBlockRequest from given interface.
func ( *ContactsBlockRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
}) {
	.MyStoriesFrom = .()
	.ID = .()
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *ContactsBlockRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.block#2e2e8734 as nil")
	}
	.PutID(ContactsBlockRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsBlockRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.block#2e2e8734 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.block#2e2e8734: field flags: %w", )
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode contacts.block#2e2e8734: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.block#2e2e8734: field id: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactsBlockRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.block#2e2e8734 to nil")
	}
	if  := .ConsumeID(ContactsBlockRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode contacts.block#2e2e8734: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactsBlockRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.block#2e2e8734 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode contacts.block#2e2e8734: field flags: %w", )
		}
	}
	.MyStoriesFrom = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.block#2e2e8734: field id: %w", )
		}
		.ID = 
	}
	return nil
}

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

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

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

// ContactsBlock invokes method contacts.block#2e2e8734 returning error if any.
// Adds a peer to a blocklist, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/block
//
// Possible errors:
//
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CONTACT_ID_INVALID: The provided contact ID is invalid.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/contacts.block for reference.
func ( *Client) ( context.Context,  *ContactsBlockRequest) (bool, error) {
	var  BoolBox

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