// Code generated by gotdgen, DO NOT EDIT. package tg import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // 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{} ) // PaymentFormMethod represents TL type `paymentFormMethod#88f8f21b`. // Represents an additional payment method // // See https://core.telegram.org/constructor/paymentFormMethod for reference. type PaymentFormMethod struct { // URL to open in a webview to process the payment URL string // Payment method description Title string } // PaymentFormMethodTypeID is TL type id of PaymentFormMethod. const PaymentFormMethodTypeID = 0x88f8f21b // Ensuring interfaces in compile-time for PaymentFormMethod. var ( _ bin.Encoder = &PaymentFormMethod{} _ bin.Decoder = &PaymentFormMethod{} _ bin.BareEncoder = &PaymentFormMethod{} _ bin.BareDecoder = &PaymentFormMethod{} ) func (p *PaymentFormMethod) Zero() bool { if p == nil { return true } if !(p.URL == "") { return false } if !(p.Title == "") { return false } return true } // String implements fmt.Stringer. func (p *PaymentFormMethod) String() string { if p == nil { return "PaymentFormMethod(nil)" } type Alias PaymentFormMethod return fmt.Sprintf("PaymentFormMethod%+v", Alias(*p)) } // FillFrom fills PaymentFormMethod from given interface. func (p *PaymentFormMethod) FillFrom(from interface { GetURL() (value string) GetTitle() (value string) }) { p.URL = from.GetURL() p.Title = from.GetTitle() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*PaymentFormMethod) TypeID() uint32 { return PaymentFormMethodTypeID } // TypeName returns name of type in TL schema. func (*PaymentFormMethod) TypeName() string { return "paymentFormMethod" } // TypeInfo returns info about TL type. func (p *PaymentFormMethod) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "paymentFormMethod", ID: PaymentFormMethodTypeID, } if p == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "URL", SchemaName: "url", }, { Name: "Title", SchemaName: "title", }, } return typ } // Encode implements bin.Encoder. func (p *PaymentFormMethod) Encode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode paymentFormMethod#88f8f21b as nil") } b.PutID(PaymentFormMethodTypeID) return p.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (p *PaymentFormMethod) EncodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode paymentFormMethod#88f8f21b as nil") } b.PutString(p.URL) b.PutString(p.Title) return nil } // Decode implements bin.Decoder. func (p *PaymentFormMethod) Decode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode paymentFormMethod#88f8f21b to nil") } if err := b.ConsumeID(PaymentFormMethodTypeID); err != nil { return fmt.Errorf("unable to decode paymentFormMethod#88f8f21b: %w", err) } return p.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (p *PaymentFormMethod) DecodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode paymentFormMethod#88f8f21b to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode paymentFormMethod#88f8f21b: field url: %w", err) } p.URL = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode paymentFormMethod#88f8f21b: field title: %w", err) } p.Title = value } return nil } // GetURL returns value of URL field. func (p *PaymentFormMethod) GetURL() (value string) { if p == nil { return } return p.URL } // GetTitle returns value of Title field. func (p *PaymentFormMethod) GetTitle() (value string) { if p == nil { return } return p.Title }