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 InputInvoiceMessage struct {
Peer InputPeerClass
MsgID int
}
const InputInvoiceMessageTypeID = 0xc5b56859
func (i InputInvoiceMessage ) construct () InputInvoiceClass { return &i }
var (
_ bin .Encoder = &InputInvoiceMessage {}
_ bin .Decoder = &InputInvoiceMessage {}
_ bin .BareEncoder = &InputInvoiceMessage {}
_ bin .BareDecoder = &InputInvoiceMessage {}
_ InputInvoiceClass = &InputInvoiceMessage {}
)
func (i *InputInvoiceMessage ) Zero () bool {
if i == nil {
return true
}
if !(i .Peer == nil ) {
return false
}
if !(i .MsgID == 0 ) {
return false
}
return true
}
func (i *InputInvoiceMessage ) String () string {
if i == nil {
return "InputInvoiceMessage(nil)"
}
type Alias InputInvoiceMessage
return fmt .Sprintf ("InputInvoiceMessage%+v" , Alias (*i ))
}
func (i *InputInvoiceMessage ) FillFrom (from interface {
GetPeer () (value InputPeerClass )
GetMsgID () (value int )
}) {
i .Peer = from .GetPeer ()
i .MsgID = from .GetMsgID ()
}
func (*InputInvoiceMessage ) TypeID () uint32 {
return InputInvoiceMessageTypeID
}
func (*InputInvoiceMessage ) TypeName () string {
return "inputInvoiceMessage"
}
func (i *InputInvoiceMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputInvoiceMessage" ,
ID : InputInvoiceMessageTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
}
return typ
}
func (i *InputInvoiceMessage ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoiceMessage#c5b56859 as nil" )
}
b .PutID (InputInvoiceMessageTypeID )
return i .EncodeBare (b )
}
func (i *InputInvoiceMessage ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoiceMessage#c5b56859 as nil" )
}
if i .Peer == nil {
return fmt .Errorf ("unable to encode inputInvoiceMessage#c5b56859: field peer is nil" )
}
if err := i .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputInvoiceMessage#c5b56859: field peer: %w" , err )
}
b .PutInt (i .MsgID )
return nil
}
func (i *InputInvoiceMessage ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoiceMessage#c5b56859 to nil" )
}
if err := b .ConsumeID (InputInvoiceMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputInvoiceMessage#c5b56859: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputInvoiceMessage ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoiceMessage#c5b56859 to nil" )
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputInvoiceMessage#c5b56859: field peer: %w" , err )
}
i .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputInvoiceMessage#c5b56859: field msg_id: %w" , err )
}
i .MsgID = value
}
return nil
}
func (i *InputInvoiceMessage ) GetPeer () (value InputPeerClass ) {
if i == nil {
return
}
return i .Peer
}
func (i *InputInvoiceMessage ) GetMsgID () (value int ) {
if i == nil {
return
}
return i .MsgID
}
type InputInvoiceSlug struct {
Slug string
}
const InputInvoiceSlugTypeID = 0xc326caef
func (i InputInvoiceSlug ) construct () InputInvoiceClass { return &i }
var (
_ bin .Encoder = &InputInvoiceSlug {}
_ bin .Decoder = &InputInvoiceSlug {}
_ bin .BareEncoder = &InputInvoiceSlug {}
_ bin .BareDecoder = &InputInvoiceSlug {}
_ InputInvoiceClass = &InputInvoiceSlug {}
)
func (i *InputInvoiceSlug ) Zero () bool {
if i == nil {
return true
}
if !(i .Slug == "" ) {
return false
}
return true
}
func (i *InputInvoiceSlug ) String () string {
if i == nil {
return "InputInvoiceSlug(nil)"
}
type Alias InputInvoiceSlug
return fmt .Sprintf ("InputInvoiceSlug%+v" , Alias (*i ))
}
func (i *InputInvoiceSlug ) FillFrom (from interface {
GetSlug () (value string )
}) {
i .Slug = from .GetSlug ()
}
func (*InputInvoiceSlug ) TypeID () uint32 {
return InputInvoiceSlugTypeID
}
func (*InputInvoiceSlug ) TypeName () string {
return "inputInvoiceSlug"
}
func (i *InputInvoiceSlug ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputInvoiceSlug" ,
ID : InputInvoiceSlugTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slug" ,
SchemaName : "slug" ,
},
}
return typ
}
func (i *InputInvoiceSlug ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoiceSlug#c326caef as nil" )
}
b .PutID (InputInvoiceSlugTypeID )
return i .EncodeBare (b )
}
func (i *InputInvoiceSlug ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoiceSlug#c326caef as nil" )
}
b .PutString (i .Slug )
return nil
}
func (i *InputInvoiceSlug ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoiceSlug#c326caef to nil" )
}
if err := b .ConsumeID (InputInvoiceSlugTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputInvoiceSlug#c326caef: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputInvoiceSlug ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoiceSlug#c326caef to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputInvoiceSlug#c326caef: field slug: %w" , err )
}
i .Slug = value
}
return nil
}
func (i *InputInvoiceSlug ) GetSlug () (value string ) {
if i == nil {
return
}
return i .Slug
}
type InputInvoicePremiumGiftCode struct {
Purpose InputStorePaymentPurposeClass
Option PremiumGiftCodeOption
}
const InputInvoicePremiumGiftCodeTypeID = 0x98986c0d
func (i InputInvoicePremiumGiftCode ) construct () InputInvoiceClass { return &i }
var (
_ bin .Encoder = &InputInvoicePremiumGiftCode {}
_ bin .Decoder = &InputInvoicePremiumGiftCode {}
_ bin .BareEncoder = &InputInvoicePremiumGiftCode {}
_ bin .BareDecoder = &InputInvoicePremiumGiftCode {}
_ InputInvoiceClass = &InputInvoicePremiumGiftCode {}
)
func (i *InputInvoicePremiumGiftCode ) Zero () bool {
if i == nil {
return true
}
if !(i .Purpose == nil ) {
return false
}
if !(i .Option .Zero ()) {
return false
}
return true
}
func (i *InputInvoicePremiumGiftCode ) String () string {
if i == nil {
return "InputInvoicePremiumGiftCode(nil)"
}
type Alias InputInvoicePremiumGiftCode
return fmt .Sprintf ("InputInvoicePremiumGiftCode%+v" , Alias (*i ))
}
func (i *InputInvoicePremiumGiftCode ) FillFrom (from interface {
GetPurpose () (value InputStorePaymentPurposeClass )
GetOption () (value PremiumGiftCodeOption )
}) {
i .Purpose = from .GetPurpose ()
i .Option = from .GetOption ()
}
func (*InputInvoicePremiumGiftCode ) TypeID () uint32 {
return InputInvoicePremiumGiftCodeTypeID
}
func (*InputInvoicePremiumGiftCode ) TypeName () string {
return "inputInvoicePremiumGiftCode"
}
func (i *InputInvoicePremiumGiftCode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputInvoicePremiumGiftCode" ,
ID : InputInvoicePremiumGiftCodeTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Purpose" ,
SchemaName : "purpose" ,
},
{
Name : "Option" ,
SchemaName : "option" ,
},
}
return typ
}
func (i *InputInvoicePremiumGiftCode ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoicePremiumGiftCode#98986c0d as nil" )
}
b .PutID (InputInvoicePremiumGiftCodeTypeID )
return i .EncodeBare (b )
}
func (i *InputInvoicePremiumGiftCode ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputInvoicePremiumGiftCode#98986c0d as nil" )
}
if i .Purpose == nil {
return fmt .Errorf ("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose is nil" )
}
if err := i .Purpose .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w" , err )
}
if err := i .Option .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputInvoicePremiumGiftCode#98986c0d: field option: %w" , err )
}
return nil
}
func (i *InputInvoicePremiumGiftCode ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoicePremiumGiftCode#98986c0d to nil" )
}
if err := b .ConsumeID (InputInvoicePremiumGiftCodeTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputInvoicePremiumGiftCode#98986c0d: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputInvoicePremiumGiftCode ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputInvoicePremiumGiftCode#98986c0d to nil" )
}
{
value , err := DecodeInputStorePaymentPurpose (b )
if err != nil {
return fmt .Errorf ("unable to decode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w" , err )
}
i .Purpose = value
}
{
if err := i .Option .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputInvoicePremiumGiftCode#98986c0d: field option: %w" , err )
}
}
return nil
}
func (i *InputInvoicePremiumGiftCode ) GetPurpose () (value InputStorePaymentPurposeClass ) {
if i == nil {
return
}
return i .Purpose
}
func (i *InputInvoicePremiumGiftCode ) GetOption () (value PremiumGiftCodeOption ) {
if i == nil {
return
}
return i .Option
}
const InputInvoiceClassName = "InputInvoice"
type InputInvoiceClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputInvoiceClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputInvoice (buf *bin .Buffer ) (InputInvoiceClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputInvoiceMessageTypeID :
v := InputInvoiceMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputInvoiceClass: %w" , err )
}
return &v , nil
case InputInvoiceSlugTypeID :
v := InputInvoiceSlug {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputInvoiceClass: %w" , err )
}
return &v , nil
case InputInvoicePremiumGiftCodeTypeID :
v := InputInvoicePremiumGiftCode {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputInvoiceClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputInvoiceClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputInvoiceBox struct {
InputInvoice InputInvoiceClass
}
func (b *InputInvoiceBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputInvoiceBox to nil" )
}
v , err := DecodeInputInvoice (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputInvoice = v
return nil
}
func (b *InputInvoiceBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputInvoice == nil {
return fmt .Errorf ("unable to encode InputInvoiceClass as nil" )
}
return b .InputInvoice .Encode (buf )
}
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 .