package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type MessagesRequestSimpleWebViewRequest struct {
Flags bin .Fields
FromSwitchWebview bool
FromSideMenu bool
Bot InputUserClass
URL string
StartParam string
ThemeParams DataJSON
Platform string
}
const MessagesRequestSimpleWebViewRequestTypeID = 0x1a46500a
var (
_ bin .Encoder = &MessagesRequestSimpleWebViewRequest {}
_ bin .Decoder = &MessagesRequestSimpleWebViewRequest {}
_ bin .BareEncoder = &MessagesRequestSimpleWebViewRequest {}
_ bin .BareDecoder = &MessagesRequestSimpleWebViewRequest {}
)
func (r *MessagesRequestSimpleWebViewRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .FromSwitchWebview == false ) {
return false
}
if !(r .FromSideMenu == false ) {
return false
}
if !(r .Bot == nil ) {
return false
}
if !(r .URL == "" ) {
return false
}
if !(r .StartParam == "" ) {
return false
}
if !(r .ThemeParams .Zero ()) {
return false
}
if !(r .Platform == "" ) {
return false
}
return true
}
func (r *MessagesRequestSimpleWebViewRequest ) String () string {
if r == nil {
return "MessagesRequestSimpleWebViewRequest(nil)"
}
type Alias MessagesRequestSimpleWebViewRequest
return fmt .Sprintf ("MessagesRequestSimpleWebViewRequest%+v" , Alias (*r ))
}
func (r *MessagesRequestSimpleWebViewRequest ) FillFrom (from interface {
GetFromSwitchWebview () (value bool )
GetFromSideMenu () (value bool )
GetBot () (value InputUserClass )
GetURL () (value string , ok bool )
GetStartParam () (value string , ok bool )
GetThemeParams () (value DataJSON , ok bool )
GetPlatform () (value string )
}) {
r .FromSwitchWebview = from .GetFromSwitchWebview ()
r .FromSideMenu = from .GetFromSideMenu ()
r .Bot = from .GetBot ()
if val , ok := from .GetURL (); ok {
r .URL = val
}
if val , ok := from .GetStartParam (); ok {
r .StartParam = val
}
if val , ok := from .GetThemeParams (); ok {
r .ThemeParams = val
}
r .Platform = from .GetPlatform ()
}
func (*MessagesRequestSimpleWebViewRequest ) TypeID () uint32 {
return MessagesRequestSimpleWebViewRequestTypeID
}
func (*MessagesRequestSimpleWebViewRequest ) TypeName () string {
return "messages.requestSimpleWebView"
}
func (r *MessagesRequestSimpleWebViewRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.requestSimpleWebView" ,
ID : MessagesRequestSimpleWebViewRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "FromSwitchWebview" ,
SchemaName : "from_switch_webview" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "FromSideMenu" ,
SchemaName : "from_side_menu" ,
Null : !r .Flags .Has (2 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !r .Flags .Has (3 ),
},
{
Name : "StartParam" ,
SchemaName : "start_param" ,
Null : !r .Flags .Has (4 ),
},
{
Name : "ThemeParams" ,
SchemaName : "theme_params" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "Platform" ,
SchemaName : "platform" ,
},
}
return typ
}
func (r *MessagesRequestSimpleWebViewRequest ) SetFlags () {
if !(r .FromSwitchWebview == false ) {
r .Flags .Set (1 )
}
if !(r .FromSideMenu == false ) {
r .Flags .Set (2 )
}
if !(r .URL == "" ) {
r .Flags .Set (3 )
}
if !(r .StartParam == "" ) {
r .Flags .Set (4 )
}
if !(r .ThemeParams .Zero ()) {
r .Flags .Set (0 )
}
}
func (r *MessagesRequestSimpleWebViewRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestSimpleWebView#1a46500a as nil" )
}
b .PutID (MessagesRequestSimpleWebViewRequestTypeID )
return r .EncodeBare (b )
}
func (r *MessagesRequestSimpleWebViewRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestSimpleWebView#1a46500a as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestSimpleWebView#1a46500a: field flags: %w" , err )
}
if r .Bot == nil {
return fmt .Errorf ("unable to encode messages.requestSimpleWebView#1a46500a: field bot is nil" )
}
if err := r .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestSimpleWebView#1a46500a: field bot: %w" , err )
}
if r .Flags .Has (3 ) {
b .PutString (r .URL )
}
if r .Flags .Has (4 ) {
b .PutString (r .StartParam )
}
if r .Flags .Has (0 ) {
if err := r .ThemeParams .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestSimpleWebView#1a46500a: field theme_params: %w" , err )
}
}
b .PutString (r .Platform )
return nil
}
func (r *MessagesRequestSimpleWebViewRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestSimpleWebView#1a46500a to nil" )
}
if err := b .ConsumeID (MessagesRequestSimpleWebViewRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: %w" , err )
}
return r .DecodeBare (b )
}
func (r *MessagesRequestSimpleWebViewRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestSimpleWebView#1a46500a to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field flags: %w" , err )
}
}
r .FromSwitchWebview = r .Flags .Has (1 )
r .FromSideMenu = r .Flags .Has (2 )
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field bot: %w" , err )
}
r .Bot = value
}
if r .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field url: %w" , err )
}
r .URL = value
}
if r .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field start_param: %w" , err )
}
r .StartParam = value
}
if r .Flags .Has (0 ) {
if err := r .ThemeParams .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field theme_params: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestSimpleWebView#1a46500a: field platform: %w" , err )
}
r .Platform = value
}
return nil
}
func (r *MessagesRequestSimpleWebViewRequest ) SetFromSwitchWebview (value bool ) {
if value {
r .Flags .Set (1 )
r .FromSwitchWebview = true
} else {
r .Flags .Unset (1 )
r .FromSwitchWebview = false
}
}
func (r *MessagesRequestSimpleWebViewRequest ) GetFromSwitchWebview () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (1 )
}
func (r *MessagesRequestSimpleWebViewRequest ) SetFromSideMenu (value bool ) {
if value {
r .Flags .Set (2 )
r .FromSideMenu = true
} else {
r .Flags .Unset (2 )
r .FromSideMenu = false
}
}
func (r *MessagesRequestSimpleWebViewRequest ) GetFromSideMenu () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (2 )
}
func (r *MessagesRequestSimpleWebViewRequest ) GetBot () (value InputUserClass ) {
if r == nil {
return
}
return r .Bot
}
func (r *MessagesRequestSimpleWebViewRequest ) SetURL (value string ) {
r .Flags .Set (3 )
r .URL = value
}
func (r *MessagesRequestSimpleWebViewRequest ) GetURL () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (3 ) {
return value , false
}
return r .URL , true
}
func (r *MessagesRequestSimpleWebViewRequest ) SetStartParam (value string ) {
r .Flags .Set (4 )
r .StartParam = value
}
func (r *MessagesRequestSimpleWebViewRequest ) GetStartParam () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (4 ) {
return value , false
}
return r .StartParam , true
}
func (r *MessagesRequestSimpleWebViewRequest ) SetThemeParams (value DataJSON ) {
r .Flags .Set (0 )
r .ThemeParams = value
}
func (r *MessagesRequestSimpleWebViewRequest ) GetThemeParams () (value DataJSON , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .ThemeParams , true
}
func (r *MessagesRequestSimpleWebViewRequest ) GetPlatform () (value string ) {
if r == nil {
return
}
return r .Platform
}
func (c *Client ) MessagesRequestSimpleWebView (ctx context .Context , request *MessagesRequestSimpleWebViewRequest ) (*SimpleWebViewResultURL , error ) {
var result SimpleWebViewResultURL
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .