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 PaymentsCurrencyRates struct {
Rates []CurrencyRate
}
const PaymentsCurrencyRatesTypeID = 0xbbcce4c2
var (
_ bin .Encoder = &PaymentsCurrencyRates {}
_ bin .Decoder = &PaymentsCurrencyRates {}
_ bin .BareEncoder = &PaymentsCurrencyRates {}
_ bin .BareDecoder = &PaymentsCurrencyRates {}
)
func (c *PaymentsCurrencyRates ) Zero () bool {
if c == nil {
return true
}
if !(c .Rates == nil ) {
return false
}
return true
}
func (c *PaymentsCurrencyRates ) String () string {
if c == nil {
return "PaymentsCurrencyRates(nil)"
}
type Alias PaymentsCurrencyRates
return fmt .Sprintf ("PaymentsCurrencyRates%+v" , Alias (*c ))
}
func (c *PaymentsCurrencyRates ) FillFrom (from interface {
GetRates () (value []CurrencyRate )
}) {
c .Rates = from .GetRates ()
}
func (*PaymentsCurrencyRates ) TypeID () uint32 {
return PaymentsCurrencyRatesTypeID
}
func (*PaymentsCurrencyRates ) TypeName () string {
return "payments.currencyRates"
}
func (c *PaymentsCurrencyRates ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.currencyRates" ,
ID : PaymentsCurrencyRatesTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Rates" ,
SchemaName : "rates" ,
},
}
return typ
}
func (c *PaymentsCurrencyRates ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.currencyRates#bbcce4c2 as nil" )
}
b .PutID (PaymentsCurrencyRatesTypeID )
return c .EncodeBare (b )
}
func (c *PaymentsCurrencyRates ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.currencyRates#bbcce4c2 as nil" )
}
b .PutVectorHeader (len (c .Rates ))
for idx , v := range c .Rates {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.currencyRates#bbcce4c2: field rates element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *PaymentsCurrencyRates ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.currencyRates#bbcce4c2 to nil" )
}
if err := b .ConsumeID (PaymentsCurrencyRatesTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.currencyRates#bbcce4c2: %w" , err )
}
return c .DecodeBare (b )
}
func (c *PaymentsCurrencyRates ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.currencyRates#bbcce4c2 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.currencyRates#bbcce4c2: field rates: %w" , err )
}
if headerLen > 0 {
c .Rates = make ([]CurrencyRate , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value CurrencyRate
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.currencyRates#bbcce4c2: field rates: %w" , err )
}
c .Rates = append (c .Rates , value )
}
}
return nil
}
func (c *PaymentsCurrencyRates ) GetRates () (value []CurrencyRate ) {
if c == nil {
return
}
return c .Rates
}
The pages are generated with Golds v0.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .