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

// MessagesGetWebPageRequest represents TL type `messages.getWebPage#8d9692a3`.
// Get instant view¹ page
//
// Links:
//  1. https://instantview.telegram.org
//
// See https://core.telegram.org/method/messages.getWebPage for reference.
type MessagesGetWebPageRequest struct {
	// URL of IV page to fetch
	URL string
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
}

// MessagesGetWebPageRequestTypeID is TL type id of MessagesGetWebPageRequest.
const MessagesGetWebPageRequestTypeID = 0x8d9692a3

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

func ( *MessagesGetWebPageRequest) () bool {
	if  == nil {
		return true
	}
	if !(.URL == "") {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetWebPageRequest from given interface.
func ( *MessagesGetWebPageRequest) ( interface {
	() ( string)
	() ( int)
}) {
	.URL = .()
	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetWebPageRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getWebPage",
		ID:   MessagesGetWebPageRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetWebPageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getWebPage#8d9692a3 as nil")
	}
	.PutID(MessagesGetWebPageRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetWebPageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getWebPage#8d9692a3 as nil")
	}
	.PutString(.URL)
	.PutInt(.Hash)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesGetWebPageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getWebPage#8d9692a3 to nil")
	}
	if  := .ConsumeID(MessagesGetWebPageRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.getWebPage#8d9692a3: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetWebPageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getWebPage#8d9692a3 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getWebPage#8d9692a3: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getWebPage#8d9692a3: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

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

// GetHash returns value of Hash field.
func ( *MessagesGetWebPageRequest) () ( int) {
	if  == nil {
		return
	}
	return .Hash
}

// MessagesGetWebPage invokes method messages.getWebPage#8d9692a3 returning error if any.
// Get instant view¹ page
//
// Links:
//  1. https://instantview.telegram.org
//
// Possible errors:
//
//	400 WC_CONVERT_URL_INVALID: WC convert URL invalid.
//
// See https://core.telegram.org/method/messages.getWebPage for reference.
func ( *Client) ( context.Context,  *MessagesGetWebPageRequest) (*MessagesWebPage, error) {
	var  MessagesWebPage

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