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

// MessagesSaveRecentStickerRequest represents TL type `messages.saveRecentSticker#392718f8`.
// Add/remove sticker from recent stickers list
//
// See https://core.telegram.org/method/messages.saveRecentSticker for reference.
type MessagesSaveRecentStickerRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to add/remove stickers recently attached to photo or video files
	Attached bool
	// Sticker
	ID InputDocumentClass
	// Whether to save or unsave the sticker
	Unsave bool
}

// MessagesSaveRecentStickerRequestTypeID is TL type id of MessagesSaveRecentStickerRequest.
const MessagesSaveRecentStickerRequestTypeID = 0x392718f8

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

func ( *MessagesSaveRecentStickerRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Attached == false) {
		return false
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSaveRecentStickerRequest from given interface.
func ( *MessagesSaveRecentStickerRequest) ( interface {
	() ( bool)
	() ( InputDocumentClass)
	() ( bool)
}) {
	.Attached = .()
	.ID = .()
	.Unsave = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSaveRecentStickerRequest) () string {
	return "messages.saveRecentSticker"
}

// TypeInfo returns info about TL type.
func ( *MessagesSaveRecentStickerRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.saveRecentSticker",
		ID:   MessagesSaveRecentStickerRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Attached",
			SchemaName: "attached",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Unsave",
			SchemaName: "unsave",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesSaveRecentStickerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveRecentSticker#392718f8 as nil")
	}
	.PutID(MessagesSaveRecentStickerRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSaveRecentStickerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveRecentSticker#392718f8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.saveRecentSticker#392718f8: field flags: %w", )
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode messages.saveRecentSticker#392718f8: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.saveRecentSticker#392718f8: field id: %w", )
	}
	.PutBool(.Unsave)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSaveRecentStickerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.saveRecentSticker#392718f8 to nil")
	}
	if  := .ConsumeID(MessagesSaveRecentStickerRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.saveRecentSticker#392718f8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSaveRecentStickerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.saveRecentSticker#392718f8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.saveRecentSticker#392718f8: field flags: %w", )
		}
	}
	.Attached = .Flags.Has(0)
	{
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveRecentSticker#392718f8: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveRecentSticker#392718f8: field unsave: %w", )
		}
		.Unsave = 
	}
	return nil
}

// SetAttached sets value of Attached conditional field.
func ( *MessagesSaveRecentStickerRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Attached = true
	} else {
		.Flags.Unset(0)
		.Attached = false
	}
}

// GetAttached returns value of Attached conditional field.
func ( *MessagesSaveRecentStickerRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetUnsave returns value of Unsave field.
func ( *MessagesSaveRecentStickerRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Unsave
}

// GetIDAsNotEmpty returns mapped value of ID field.
func ( *MessagesSaveRecentStickerRequest) () (*InputDocument, bool) {
	return .ID.AsNotEmpty()
}

// MessagesSaveRecentSticker invokes method messages.saveRecentSticker#392718f8 returning error if any.
// Add/remove sticker from recent stickers list
//
// Possible errors:
//
//	400 STICKER_ID_INVALID: The provided sticker ID is invalid.
//
// See https://core.telegram.org/method/messages.saveRecentSticker for reference.
func ( *Client) ( context.Context,  *MessagesSaveRecentStickerRequest) (bool, error) {
	var  BoolBox

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