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 CurrencyRate struct {
Currency string
Rate float64
}
const CurrencyRateTypeID = 0x30d9743c
var (
_ bin .Encoder = &CurrencyRate {}
_ bin .Decoder = &CurrencyRate {}
_ bin .BareEncoder = &CurrencyRate {}
_ bin .BareDecoder = &CurrencyRate {}
)
func (c *CurrencyRate ) Zero () bool {
if c == nil {
return true
}
if !(c .Currency == "" ) {
return false
}
if !(c .Rate == 0 ) {
return false
}
return true
}
func (c *CurrencyRate ) String () string {
if c == nil {
return "CurrencyRate(nil)"
}
type Alias CurrencyRate
return fmt .Sprintf ("CurrencyRate%+v" , Alias (*c ))
}
func (c *CurrencyRate ) FillFrom (from interface {
GetCurrency () (value string )
GetRate () (value float64 )
}) {
c .Currency = from .GetCurrency ()
c .Rate = from .GetRate ()
}
func (*CurrencyRate ) TypeID () uint32 {
return CurrencyRateTypeID
}
func (*CurrencyRate ) TypeName () string {
return "currencyRate"
}
func (c *CurrencyRate ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "currencyRate" ,
ID : CurrencyRateTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Currency" ,
SchemaName : "currency" ,
},
{
Name : "Rate" ,
SchemaName : "rate" ,
},
}
return typ
}
func (c *CurrencyRate ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode currencyRate#30d9743c as nil" )
}
b .PutID (CurrencyRateTypeID )
return c .EncodeBare (b )
}
func (c *CurrencyRate ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode currencyRate#30d9743c as nil" )
}
b .PutString (c .Currency )
b .PutDouble (c .Rate )
return nil
}
func (c *CurrencyRate ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode currencyRate#30d9743c to nil" )
}
if err := b .ConsumeID (CurrencyRateTypeID ); err != nil {
return fmt .Errorf ("unable to decode currencyRate#30d9743c: %w" , err )
}
return c .DecodeBare (b )
}
func (c *CurrencyRate ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode currencyRate#30d9743c to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode currencyRate#30d9743c: field currency: %w" , err )
}
c .Currency = value
}
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode currencyRate#30d9743c: field rate: %w" , err )
}
c .Rate = value
}
return nil
}
func (c *CurrencyRate ) GetCurrency () (value string ) {
if c == nil {
return
}
return c .Currency
}
func (c *CurrencyRate ) GetRate () (value float64 ) {
if c == nil {
return
}
return c .Rate
}
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 .