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

// MessagesSaveGifRequest represents TL type `messages.saveGif#327a30cb`.
// Add GIF to saved gifs list
//
// See https://core.telegram.org/method/messages.saveGif for reference.
type MessagesSaveGifRequest struct {
	// GIF to save
	ID InputDocumentClass
	// Whether to remove GIF from saved gifs list
	Unsave bool
}

// MessagesSaveGifRequestTypeID is TL type id of MessagesSaveGifRequest.
const MessagesSaveGifRequestTypeID = 0x327a30cb

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

func ( *MessagesSaveGifRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSaveGifRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.saveGif",
		ID:   MessagesSaveGifRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Unsave",
			SchemaName: "unsave",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSaveGifRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveGif#327a30cb as nil")
	}
	.PutID(MessagesSaveGifRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSaveGifRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.saveGif#327a30cb as nil")
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode messages.saveGif#327a30cb: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.saveGif#327a30cb: field id: %w", )
	}
	.PutBool(.Unsave)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSaveGifRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.saveGif#327a30cb to nil")
	}
	if  := .ConsumeID(MessagesSaveGifRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.saveGif#327a30cb: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSaveGifRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.saveGif#327a30cb to nil")
	}
	{
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveGif#327a30cb: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.saveGif#327a30cb: field unsave: %w", )
		}
		.Unsave = 
	}
	return nil
}

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

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

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

// MessagesSaveGif invokes method messages.saveGif#327a30cb returning error if any.
// Add GIF to saved gifs list
//
// Possible errors:
//
//	400 GIF_ID_INVALID: The provided GIF ID is invalid.
//
// See https://core.telegram.org/method/messages.saveGif for reference.
func ( *Client) ( context.Context,  *MessagesSaveGifRequest) (bool, error) {
	var  BoolBox

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