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

// WebViewMessageSent represents TL type `webViewMessageSent#c94511c`.
// Info about a sent inline webview message
//
// See https://core.telegram.org/constructor/webViewMessageSent for reference.
type WebViewMessageSent struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Message ID
	//
	// Use SetMsgID and GetMsgID helpers.
	MsgID InputBotInlineMessageIDClass
}

// WebViewMessageSentTypeID is TL type id of WebViewMessageSent.
const WebViewMessageSentTypeID = 0xc94511c

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

func ( *WebViewMessageSent) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MsgID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WebViewMessageSent from given interface.
func ( *WebViewMessageSent) ( interface {
	() ( InputBotInlineMessageIDClass,  bool)
}) {
	if ,  := .();  {
		.MsgID = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*WebViewMessageSent) () string {
	return "webViewMessageSent"
}

// TypeInfo returns info about TL type.
func ( *WebViewMessageSent) () tdp.Type {
	 := tdp.Type{
		Name: "webViewMessageSent",
		ID:   WebViewMessageSentTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WebViewMessageSent) () {
	if !(.MsgID == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *WebViewMessageSent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webViewMessageSent#c94511c as nil")
	}
	.PutID(WebViewMessageSentTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebViewMessageSent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webViewMessageSent#c94511c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .MsgID == nil {
			return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field msg_id is nil")
		}
		if  := .MsgID.Encode();  != nil {
			return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field msg_id: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebViewMessageSent) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webViewMessageSent#c94511c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webViewMessageSent#c94511c: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeInputBotInlineMessageID()
		if  != nil {
			return fmt.Errorf("unable to decode webViewMessageSent#c94511c: field msg_id: %w", )
		}
		.MsgID = 
	}
	return nil
}

// SetMsgID sets value of MsgID conditional field.
func ( *WebViewMessageSent) ( InputBotInlineMessageIDClass) {
	.Flags.Set(0)
	.MsgID = 
}

// GetMsgID returns value of MsgID conditional field and
// boolean which is true if field was set.
func ( *WebViewMessageSent) () ( InputBotInlineMessageIDClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .MsgID, true
}