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 LabeledPrice struct {
Label string
Amount int64
}
const LabeledPriceTypeID = 0xcb296bf8
var (
_ bin .Encoder = &LabeledPrice {}
_ bin .Decoder = &LabeledPrice {}
_ bin .BareEncoder = &LabeledPrice {}
_ bin .BareDecoder = &LabeledPrice {}
)
func (l *LabeledPrice ) Zero () bool {
if l == nil {
return true
}
if !(l .Label == "" ) {
return false
}
if !(l .Amount == 0 ) {
return false
}
return true
}
func (l *LabeledPrice ) String () string {
if l == nil {
return "LabeledPrice(nil)"
}
type Alias LabeledPrice
return fmt .Sprintf ("LabeledPrice%+v" , Alias (*l ))
}
func (l *LabeledPrice ) FillFrom (from interface {
GetLabel () (value string )
GetAmount () (value int64 )
}) {
l .Label = from .GetLabel ()
l .Amount = from .GetAmount ()
}
func (*LabeledPrice ) TypeID () uint32 {
return LabeledPriceTypeID
}
func (*LabeledPrice ) TypeName () string {
return "labeledPrice"
}
func (l *LabeledPrice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "labeledPrice" ,
ID : LabeledPriceTypeID ,
}
if l == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Label" ,
SchemaName : "label" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (l *LabeledPrice ) Encode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode labeledPrice#cb296bf8 as nil" )
}
b .PutID (LabeledPriceTypeID )
return l .EncodeBare (b )
}
func (l *LabeledPrice ) EncodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode labeledPrice#cb296bf8 as nil" )
}
b .PutString (l .Label )
b .PutLong (l .Amount )
return nil
}
func (l *LabeledPrice ) Decode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode labeledPrice#cb296bf8 to nil" )
}
if err := b .ConsumeID (LabeledPriceTypeID ); err != nil {
return fmt .Errorf ("unable to decode labeledPrice#cb296bf8: %w" , err )
}
return l .DecodeBare (b )
}
func (l *LabeledPrice ) DecodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode labeledPrice#cb296bf8 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode labeledPrice#cb296bf8: field label: %w" , err )
}
l .Label = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode labeledPrice#cb296bf8: field amount: %w" , err )
}
l .Amount = value
}
return nil
}
func (l *LabeledPrice ) GetLabel () (value string ) {
if l == nil {
return
}
return l .Label
}
func (l *LabeledPrice ) GetAmount () (value int64 ) {
if l == nil {
return
}
return l .Amount
}
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 .