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 MessagesRequestAppWebViewRequest struct {
Flags bin .Fields
WriteAllowed bool
Peer InputPeerClass
App InputBotAppClass
StartParam string
ThemeParams DataJSON
Platform string
}
const MessagesRequestAppWebViewRequestTypeID = 0x8c5a3b3c
var (
_ bin .Encoder = &MessagesRequestAppWebViewRequest {}
_ bin .Decoder = &MessagesRequestAppWebViewRequest {}
_ bin .BareEncoder = &MessagesRequestAppWebViewRequest {}
_ bin .BareDecoder = &MessagesRequestAppWebViewRequest {}
)
func (r *MessagesRequestAppWebViewRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .WriteAllowed == false ) {
return false
}
if !(r .Peer == nil ) {
return false
}
if !(r .App == nil ) {
return false
}
if !(r .StartParam == "" ) {
return false
}
if !(r .ThemeParams .Zero ()) {
return false
}
if !(r .Platform == "" ) {
return false
}
return true
}
func (r *MessagesRequestAppWebViewRequest ) String () string {
if r == nil {
return "MessagesRequestAppWebViewRequest(nil)"
}
type Alias MessagesRequestAppWebViewRequest
return fmt .Sprintf ("MessagesRequestAppWebViewRequest%+v" , Alias (*r ))
}
func (r *MessagesRequestAppWebViewRequest ) FillFrom (from interface {
GetWriteAllowed () (value bool )
GetPeer () (value InputPeerClass )
GetApp () (value InputBotAppClass )
GetStartParam () (value string , ok bool )
GetThemeParams () (value DataJSON , ok bool )
GetPlatform () (value string )
}) {
r .WriteAllowed = from .GetWriteAllowed ()
r .Peer = from .GetPeer ()
r .App = from .GetApp ()
if val , ok := from .GetStartParam (); ok {
r .StartParam = val
}
if val , ok := from .GetThemeParams (); ok {
r .ThemeParams = val
}
r .Platform = from .GetPlatform ()
}
func (*MessagesRequestAppWebViewRequest ) TypeID () uint32 {
return MessagesRequestAppWebViewRequestTypeID
}
func (*MessagesRequestAppWebViewRequest ) TypeName () string {
return "messages.requestAppWebView"
}
func (r *MessagesRequestAppWebViewRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.requestAppWebView" ,
ID : MessagesRequestAppWebViewRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "WriteAllowed" ,
SchemaName : "write_allowed" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "App" ,
SchemaName : "app" ,
},
{
Name : "StartParam" ,
SchemaName : "start_param" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "ThemeParams" ,
SchemaName : "theme_params" ,
Null : !r .Flags .Has (2 ),
},
{
Name : "Platform" ,
SchemaName : "platform" ,
},
}
return typ
}
func (r *MessagesRequestAppWebViewRequest ) SetFlags () {
if !(r .WriteAllowed == false ) {
r .Flags .Set (0 )
}
if !(r .StartParam == "" ) {
r .Flags .Set (1 )
}
if !(r .ThemeParams .Zero ()) {
r .Flags .Set (2 )
}
}
func (r *MessagesRequestAppWebViewRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestAppWebView#8c5a3b3c as nil" )
}
b .PutID (MessagesRequestAppWebViewRequestTypeID )
return r .EncodeBare (b )
}
func (r *MessagesRequestAppWebViewRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode messages.requestAppWebView#8c5a3b3c as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field flags: %w" , err )
}
if r .Peer == nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field peer: %w" , err )
}
if r .App == nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field app is nil" )
}
if err := r .App .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field app: %w" , err )
}
if r .Flags .Has (1 ) {
b .PutString (r .StartParam )
}
if r .Flags .Has (2 ) {
if err := r .ThemeParams .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.requestAppWebView#8c5a3b3c: field theme_params: %w" , err )
}
}
b .PutString (r .Platform )
return nil
}
func (r *MessagesRequestAppWebViewRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestAppWebView#8c5a3b3c to nil" )
}
if err := b .ConsumeID (MessagesRequestAppWebViewRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: %w" , err )
}
return r .DecodeBare (b )
}
func (r *MessagesRequestAppWebViewRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode messages.requestAppWebView#8c5a3b3c to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field flags: %w" , err )
}
}
r .WriteAllowed = r .Flags .Has (0 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field peer: %w" , err )
}
r .Peer = value
}
{
value , err := DecodeInputBotApp (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field app: %w" , err )
}
r .App = value
}
if r .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field start_param: %w" , err )
}
r .StartParam = value
}
if r .Flags .Has (2 ) {
if err := r .ThemeParams .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field theme_params: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.requestAppWebView#8c5a3b3c: field platform: %w" , err )
}
r .Platform = value
}
return nil
}
func (r *MessagesRequestAppWebViewRequest ) SetWriteAllowed (value bool ) {
if value {
r .Flags .Set (0 )
r .WriteAllowed = true
} else {
r .Flags .Unset (0 )
r .WriteAllowed = false
}
}
func (r *MessagesRequestAppWebViewRequest ) GetWriteAllowed () (value bool ) {
if r == nil {
return
}
return r .Flags .Has (0 )
}
func (r *MessagesRequestAppWebViewRequest ) GetPeer () (value InputPeerClass ) {
if r == nil {
return
}
return r .Peer
}
func (r *MessagesRequestAppWebViewRequest ) GetApp () (value InputBotAppClass ) {
if r == nil {
return
}
return r .App
}
func (r *MessagesRequestAppWebViewRequest ) SetStartParam (value string ) {
r .Flags .Set (1 )
r .StartParam = value
}
func (r *MessagesRequestAppWebViewRequest ) GetStartParam () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .StartParam , true
}
func (r *MessagesRequestAppWebViewRequest ) SetThemeParams (value DataJSON ) {
r .Flags .Set (2 )
r .ThemeParams = value
}
func (r *MessagesRequestAppWebViewRequest ) GetThemeParams () (value DataJSON , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (2 ) {
return value , false
}
return r .ThemeParams , true
}
func (r *MessagesRequestAppWebViewRequest ) GetPlatform () (value string ) {
if r == nil {
return
}
return r .Platform
}
func (c *Client ) MessagesRequestAppWebView (ctx context .Context , request *MessagesRequestAppWebViewRequest ) (*AppWebViewResultURL , error ) {
var result AppWebViewResultURL
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 .