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

// StickersSetStickerSetThumbRequest represents TL type `stickers.setStickerSetThumb#a76a5392`.
// Set stickerset thumbnail
//
// See https://core.telegram.org/method/stickers.setStickerSetThumb for reference.
type StickersSetStickerSetThumbRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Stickerset
	Stickerset InputStickerSetClass
	// Thumbnail (only for normal stickersets, not custom emoji stickersets).
	//
	// Use SetThumb and GetThumb helpers.
	Thumb InputDocumentClass
	// Only for custom emoji stickersetsĀ¹, ID of a custom emoji present in the set to use as
	// thumbnail; pass 0 to fallback to the first custom emoji of the set.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//
	// Use SetThumbDocumentID and GetThumbDocumentID helpers.
	ThumbDocumentID int64
}

// StickersSetStickerSetThumbRequestTypeID is TL type id of StickersSetStickerSetThumbRequest.
const StickersSetStickerSetThumbRequestTypeID = 0xa76a5392

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

func ( *StickersSetStickerSetThumbRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Stickerset == nil) {
		return false
	}
	if !(.Thumb == nil) {
		return false
	}
	if !(.ThumbDocumentID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StickersSetStickerSetThumbRequest from given interface.
func ( *StickersSetStickerSetThumbRequest) ( interface {
	() ( InputStickerSetClass)
	() ( InputDocumentClass,  bool)
	() ( int64,  bool)
}) {
	.Stickerset = .()
	if ,  := .();  {
		.Thumb = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*StickersSetStickerSetThumbRequest) () string {
	return "stickers.setStickerSetThumb"
}

// TypeInfo returns info about TL type.
func ( *StickersSetStickerSetThumbRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stickers.setStickerSetThumb",
		ID:   StickersSetStickerSetThumbRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Stickerset",
			SchemaName: "stickerset",
		},
		{
			Name:       "Thumb",
			SchemaName: "thumb",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ThumbDocumentID",
			SchemaName: "thumb_document_id",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StickersSetStickerSetThumbRequest) () {
	if !(.Thumb == nil) {
		.Flags.Set(0)
	}
	if !(.ThumbDocumentID == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *StickersSetStickerSetThumbRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stickers.setStickerSetThumb#a76a5392 as nil")
	}
	.PutID(StickersSetStickerSetThumbRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StickersSetStickerSetThumbRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stickers.setStickerSetThumb#a76a5392 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stickers.setStickerSetThumb#a76a5392: field flags: %w", )
	}
	if .Stickerset == nil {
		return fmt.Errorf("unable to encode stickers.setStickerSetThumb#a76a5392: field stickerset is nil")
	}
	if  := .Stickerset.Encode();  != nil {
		return fmt.Errorf("unable to encode stickers.setStickerSetThumb#a76a5392: field stickerset: %w", )
	}
	if .Flags.Has(0) {
		if .Thumb == nil {
			return fmt.Errorf("unable to encode stickers.setStickerSetThumb#a76a5392: field thumb is nil")
		}
		if  := .Thumb.Encode();  != nil {
			return fmt.Errorf("unable to encode stickers.setStickerSetThumb#a76a5392: field thumb: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutLong(.ThumbDocumentID)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StickersSetStickerSetThumbRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stickers.setStickerSetThumb#a76a5392 to nil")
	}
	if  := .ConsumeID(StickersSetStickerSetThumbRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stickers.setStickerSetThumb#a76a5392: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StickersSetStickerSetThumbRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stickers.setStickerSetThumb#a76a5392 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stickers.setStickerSetThumb#a76a5392: field flags: %w", )
		}
	}
	{
		,  := DecodeInputStickerSet()
		if  != nil {
			return fmt.Errorf("unable to decode stickers.setStickerSetThumb#a76a5392: field stickerset: %w", )
		}
		.Stickerset = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode stickers.setStickerSetThumb#a76a5392: field thumb: %w", )
		}
		.Thumb = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode stickers.setStickerSetThumb#a76a5392: field thumb_document_id: %w", )
		}
		.ThumbDocumentID = 
	}
	return nil
}

// GetStickerset returns value of Stickerset field.
func ( *StickersSetStickerSetThumbRequest) () ( InputStickerSetClass) {
	if  == nil {
		return
	}
	return .Stickerset
}

// SetThumb sets value of Thumb conditional field.
func ( *StickersSetStickerSetThumbRequest) ( InputDocumentClass) {
	.Flags.Set(0)
	.Thumb = 
}

// GetThumb returns value of Thumb conditional field and
// boolean which is true if field was set.
func ( *StickersSetStickerSetThumbRequest) () ( InputDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Thumb, true
}

// SetThumbDocumentID sets value of ThumbDocumentID conditional field.
func ( *StickersSetStickerSetThumbRequest) ( int64) {
	.Flags.Set(1)
	.ThumbDocumentID = 
}

// GetThumbDocumentID returns value of ThumbDocumentID conditional field and
// boolean which is true if field was set.
func ( *StickersSetStickerSetThumbRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .ThumbDocumentID, true
}

// GetThumbAsNotEmpty returns mapped value of Thumb conditional field and
// boolean which is true if field was set.
func ( *StickersSetStickerSetThumbRequest) () (*InputDocument, bool) {
	if ,  := .GetThumb();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// StickersSetStickerSetThumb invokes method stickers.setStickerSetThumb#a76a5392 returning error if any.
// Set stickerset thumbnail
//
// Possible errors:
//
//	400 STICKERSET_INVALID: The provided sticker set is invalid.
//	400 STICKER_THUMB_PNG_NOPNG: Incorrect stickerset thumb file provided, PNG / WEBP expected.
//	400 STICKER_THUMB_TGS_NOTGS: Incorrect stickerset TGS thumb file provided.
//
// See https://core.telegram.org/method/stickers.setStickerSetThumb for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *StickersSetStickerSetThumbRequest) (MessagesStickerSetClass, error) {
	var  MessagesStickerSetBox

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