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 PaymentsGetOnrampQuoteRequest struct {
Flags bin .Fields
Provider string
CryptoCurrency string
BaseCurrency string
BaseAmount string
CryptoAmount string
PaymentMethod string
}
const PaymentsGetOnrampQuoteRequestTypeID = 0xe06645fa
var (
_ bin .Encoder = &PaymentsGetOnrampQuoteRequest {}
_ bin .Decoder = &PaymentsGetOnrampQuoteRequest {}
_ bin .BareEncoder = &PaymentsGetOnrampQuoteRequest {}
_ bin .BareDecoder = &PaymentsGetOnrampQuoteRequest {}
)
func (g *PaymentsGetOnrampQuoteRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Provider == "" ) {
return false
}
if !(g .CryptoCurrency == "" ) {
return false
}
if !(g .BaseCurrency == "" ) {
return false
}
if !(g .BaseAmount == "" ) {
return false
}
if !(g .CryptoAmount == "" ) {
return false
}
if !(g .PaymentMethod == "" ) {
return false
}
return true
}
func (g *PaymentsGetOnrampQuoteRequest ) String () string {
if g == nil {
return "PaymentsGetOnrampQuoteRequest(nil)"
}
type Alias PaymentsGetOnrampQuoteRequest
return fmt .Sprintf ("PaymentsGetOnrampQuoteRequest%+v" , Alias (*g ))
}
func (g *PaymentsGetOnrampQuoteRequest ) FillFrom (from interface {
GetProvider () (value string )
GetCryptoCurrency () (value string )
GetBaseCurrency () (value string )
GetBaseAmount () (value string , ok bool )
GetCryptoAmount () (value string , ok bool )
GetPaymentMethod () (value string , ok bool )
}) {
g .Provider = from .GetProvider ()
g .CryptoCurrency = from .GetCryptoCurrency ()
g .BaseCurrency = from .GetBaseCurrency ()
if val , ok := from .GetBaseAmount (); ok {
g .BaseAmount = val
}
if val , ok := from .GetCryptoAmount (); ok {
g .CryptoAmount = val
}
if val , ok := from .GetPaymentMethod (); ok {
g .PaymentMethod = val
}
}
func (*PaymentsGetOnrampQuoteRequest ) TypeID () uint32 {
return PaymentsGetOnrampQuoteRequestTypeID
}
func (*PaymentsGetOnrampQuoteRequest ) TypeName () string {
return "payments.getOnrampQuote"
}
func (g *PaymentsGetOnrampQuoteRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.getOnrampQuote" ,
ID : PaymentsGetOnrampQuoteRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Provider" ,
SchemaName : "provider" ,
},
{
Name : "CryptoCurrency" ,
SchemaName : "crypto_currency" ,
},
{
Name : "BaseCurrency" ,
SchemaName : "base_currency" ,
},
{
Name : "BaseAmount" ,
SchemaName : "base_amount" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "CryptoAmount" ,
SchemaName : "crypto_amount" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "PaymentMethod" ,
SchemaName : "payment_method" ,
Null : !g .Flags .Has (2 ),
},
}
return typ
}
func (g *PaymentsGetOnrampQuoteRequest ) SetFlags () {
if !(g .BaseAmount == "" ) {
g .Flags .Set (0 )
}
if !(g .CryptoAmount == "" ) {
g .Flags .Set (1 )
}
if !(g .PaymentMethod == "" ) {
g .Flags .Set (2 )
}
}
func (g *PaymentsGetOnrampQuoteRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getOnrampQuote#e06645fa as nil" )
}
b .PutID (PaymentsGetOnrampQuoteRequestTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGetOnrampQuoteRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.getOnrampQuote#e06645fa as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.getOnrampQuote#e06645fa: field flags: %w" , err )
}
b .PutString (g .Provider )
b .PutString (g .CryptoCurrency )
b .PutString (g .BaseCurrency )
if g .Flags .Has (0 ) {
b .PutString (g .BaseAmount )
}
if g .Flags .Has (1 ) {
b .PutString (g .CryptoAmount )
}
if g .Flags .Has (2 ) {
b .PutString (g .PaymentMethod )
}
return nil
}
func (g *PaymentsGetOnrampQuoteRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getOnrampQuote#e06645fa to nil" )
}
if err := b .ConsumeID (PaymentsGetOnrampQuoteRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGetOnrampQuoteRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.getOnrampQuote#e06645fa to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field provider: %w" , err )
}
g .Provider = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field crypto_currency: %w" , err )
}
g .CryptoCurrency = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field base_currency: %w" , err )
}
g .BaseCurrency = value
}
if g .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field base_amount: %w" , err )
}
g .BaseAmount = value
}
if g .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field crypto_amount: %w" , err )
}
g .CryptoAmount = value
}
if g .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.getOnrampQuote#e06645fa: field payment_method: %w" , err )
}
g .PaymentMethod = value
}
return nil
}
func (g *PaymentsGetOnrampQuoteRequest ) GetProvider () (value string ) {
if g == nil {
return
}
return g .Provider
}
func (g *PaymentsGetOnrampQuoteRequest ) GetCryptoCurrency () (value string ) {
if g == nil {
return
}
return g .CryptoCurrency
}
func (g *PaymentsGetOnrampQuoteRequest ) GetBaseCurrency () (value string ) {
if g == nil {
return
}
return g .BaseCurrency
}
func (g *PaymentsGetOnrampQuoteRequest ) SetBaseAmount (value string ) {
g .Flags .Set (0 )
g .BaseAmount = value
}
func (g *PaymentsGetOnrampQuoteRequest ) GetBaseAmount () (value string , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .BaseAmount , true
}
func (g *PaymentsGetOnrampQuoteRequest ) SetCryptoAmount (value string ) {
g .Flags .Set (1 )
g .CryptoAmount = value
}
func (g *PaymentsGetOnrampQuoteRequest ) GetCryptoAmount () (value string , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (1 ) {
return value , false
}
return g .CryptoAmount , true
}
func (g *PaymentsGetOnrampQuoteRequest ) SetPaymentMethod (value string ) {
g .Flags .Set (2 )
g .PaymentMethod = value
}
func (g *PaymentsGetOnrampQuoteRequest ) GetPaymentMethod () (value string , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (2 ) {
return value , false
}
return g .PaymentMethod , true
}
func (c *Client ) PaymentsGetOnrampQuote (ctx context .Context , request *PaymentsGetOnrampQuoteRequest ) (*OnrampQuote , error ) {
var result OnrampQuote
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , nil
}
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 .