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

// WebViewResultURL represents TL type `webViewResultUrl#4d22ff98`.
// Contains the webview URL with appropriate theme and user info parameters added
//
// See https://core.telegram.org/constructor/webViewResultUrl for reference.
type WebViewResultURL struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the app must be opened in fullsize mode instead of compact mode.
	Fullsize bool
	// If set, the app must be opened in fullscreen
	Fullscreen bool
	// SameOrigin field of WebViewResultURL.
	SameOrigin bool
	// Webview session ID (only returned by inline button mini apps¹, menu button mini
	// apps², attachment menu mini apps³).
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps#inline-button-mini-apps
	//  2) https://core.telegram.org/api/bots/webapps#menu-button-mini-apps
	//  3) https://core.telegram.org/api/bots/webapps#attachment-menu-mini-apps
	//
	// Use SetQueryID and GetQueryID helpers.
	QueryID int64
	// Webview URL to open
	URL string
}

// WebViewResultURLTypeID is TL type id of WebViewResultURL.
const WebViewResultURLTypeID = 0x4d22ff98

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

func ( *WebViewResultURL) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Fullsize == false) {
		return false
	}
	if !(.Fullscreen == false) {
		return false
	}
	if !(.SameOrigin == false) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills WebViewResultURL from given interface.
func ( *WebViewResultURL) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64,  bool)
	() ( string)
}) {
	.Fullsize = .()
	.Fullscreen = .()
	.SameOrigin = .()
	if ,  := .();  {
		.QueryID = 
	}

	.URL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WebViewResultURL) () tdp.Type {
	 := tdp.Type{
		Name: "webViewResultUrl",
		ID:   WebViewResultURLTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Fullsize",
			SchemaName: "fullsize",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Fullscreen",
			SchemaName: "fullscreen",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "SameOrigin",
			SchemaName: "same_origin",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WebViewResultURL) () {
	if !(.Fullsize == false) {
		.Flags.Set(1)
	}
	if !(.Fullscreen == false) {
		.Flags.Set(2)
	}
	if !(.SameOrigin == false) {
		.Flags.Set(3)
	}
	if !(.QueryID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *WebViewResultURL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webViewResultUrl#4d22ff98 as nil")
	}
	.PutID(WebViewResultURLTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebViewResultURL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webViewResultUrl#4d22ff98 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode webViewResultUrl#4d22ff98: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutLong(.QueryID)
	}
	.PutString(.URL)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebViewResultURL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webViewResultUrl#4d22ff98 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode webViewResultUrl#4d22ff98: field flags: %w", )
		}
	}
	.Fullsize = .Flags.Has(1)
	.Fullscreen = .Flags.Has(2)
	.SameOrigin = .Flags.Has(3)
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webViewResultUrl#4d22ff98: field query_id: %w", )
		}
		.QueryID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webViewResultUrl#4d22ff98: field url: %w", )
		}
		.URL = 
	}
	return nil
}

// SetFullsize sets value of Fullsize conditional field.
func ( *WebViewResultURL) ( bool) {
	if  {
		.Flags.Set(1)
		.Fullsize = true
	} else {
		.Flags.Unset(1)
		.Fullsize = false
	}
}

// GetFullsize returns value of Fullsize conditional field.
func ( *WebViewResultURL) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetFullscreen sets value of Fullscreen conditional field.
func ( *WebViewResultURL) ( bool) {
	if  {
		.Flags.Set(2)
		.Fullscreen = true
	} else {
		.Flags.Unset(2)
		.Fullscreen = false
	}
}

// GetFullscreen returns value of Fullscreen conditional field.
func ( *WebViewResultURL) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetSameOrigin sets value of SameOrigin conditional field.
func ( *WebViewResultURL) ( bool) {
	if  {
		.Flags.Set(3)
		.SameOrigin = true
	} else {
		.Flags.Unset(3)
		.SameOrigin = false
	}
}

// GetSameOrigin returns value of SameOrigin conditional field.
func ( *WebViewResultURL) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetQueryID sets value of QueryID conditional field.
func ( *WebViewResultURL) ( int64) {
	.Flags.Set(0)
	.QueryID = 
}

// GetQueryID returns value of QueryID conditional field and
// boolean which is true if field was set.
func ( *WebViewResultURL) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .QueryID, true
}

// GetURL returns value of URL field.
func ( *WebViewResultURL) () ( string) {
	if  == nil {
		return
	}
	return .URL
}