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 PaymentsCreateOnrampSessionRequest struct {
Flags bin .Fields
Provider string
CryptoCurrency string
Address string
PaymentMethod string
BaseCurrency string
BaseAmount string
Memo string
Theme string
SuccessReturnURL string
FailReturnURL string
CryptoAmount string
}
const PaymentsCreateOnrampSessionRequestTypeID = 0xa2197cf6
var (
_ bin .Encoder = &PaymentsCreateOnrampSessionRequest {}
_ bin .Decoder = &PaymentsCreateOnrampSessionRequest {}
_ bin .BareEncoder = &PaymentsCreateOnrampSessionRequest {}
_ bin .BareDecoder = &PaymentsCreateOnrampSessionRequest {}
)
func (c *PaymentsCreateOnrampSessionRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Provider == "" ) {
return false
}
if !(c .CryptoCurrency == "" ) {
return false
}
if !(c .Address == "" ) {
return false
}
if !(c .PaymentMethod == "" ) {
return false
}
if !(c .BaseCurrency == "" ) {
return false
}
if !(c .BaseAmount == "" ) {
return false
}
if !(c .Memo == "" ) {
return false
}
if !(c .Theme == "" ) {
return false
}
if !(c .SuccessReturnURL == "" ) {
return false
}
if !(c .FailReturnURL == "" ) {
return false
}
if !(c .CryptoAmount == "" ) {
return false
}
return true
}
func (c *PaymentsCreateOnrampSessionRequest ) String () string {
if c == nil {
return "PaymentsCreateOnrampSessionRequest(nil)"
}
type Alias PaymentsCreateOnrampSessionRequest
return fmt .Sprintf ("PaymentsCreateOnrampSessionRequest%+v" , Alias (*c ))
}
func (c *PaymentsCreateOnrampSessionRequest ) FillFrom (from interface {
GetProvider () (value string )
GetCryptoCurrency () (value string )
GetAddress () (value string )
GetPaymentMethod () (value string , ok bool )
GetBaseCurrency () (value string , ok bool )
GetBaseAmount () (value string , ok bool )
GetMemo () (value string , ok bool )
GetTheme () (value string , ok bool )
GetSuccessReturnURL () (value string , ok bool )
GetFailReturnURL () (value string , ok bool )
GetCryptoAmount () (value string , ok bool )
}) {
c .Provider = from .GetProvider ()
c .CryptoCurrency = from .GetCryptoCurrency ()
c .Address = from .GetAddress ()
if val , ok := from .GetPaymentMethod (); ok {
c .PaymentMethod = val
}
if val , ok := from .GetBaseCurrency (); ok {
c .BaseCurrency = val
}
if val , ok := from .GetBaseAmount (); ok {
c .BaseAmount = val
}
if val , ok := from .GetMemo (); ok {
c .Memo = val
}
if val , ok := from .GetTheme (); ok {
c .Theme = val
}
if val , ok := from .GetSuccessReturnURL (); ok {
c .SuccessReturnURL = val
}
if val , ok := from .GetFailReturnURL (); ok {
c .FailReturnURL = val
}
if val , ok := from .GetCryptoAmount (); ok {
c .CryptoAmount = val
}
}
func (*PaymentsCreateOnrampSessionRequest ) TypeID () uint32 {
return PaymentsCreateOnrampSessionRequestTypeID
}
func (*PaymentsCreateOnrampSessionRequest ) TypeName () string {
return "payments.createOnrampSession"
}
func (c *PaymentsCreateOnrampSessionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.createOnrampSession" ,
ID : PaymentsCreateOnrampSessionRequestTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Provider" ,
SchemaName : "provider" ,
},
{
Name : "CryptoCurrency" ,
SchemaName : "crypto_currency" ,
},
{
Name : "Address" ,
SchemaName : "address" ,
},
{
Name : "PaymentMethod" ,
SchemaName : "payment_method" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "BaseCurrency" ,
SchemaName : "base_currency" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "BaseAmount" ,
SchemaName : "base_amount" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Memo" ,
SchemaName : "memo" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "Theme" ,
SchemaName : "theme" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "SuccessReturnURL" ,
SchemaName : "success_return_url" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "FailReturnURL" ,
SchemaName : "fail_return_url" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "CryptoAmount" ,
SchemaName : "crypto_amount" ,
Null : !c .Flags .Has (7 ),
},
}
return typ
}
func (c *PaymentsCreateOnrampSessionRequest ) SetFlags () {
if !(c .PaymentMethod == "" ) {
c .Flags .Set (0 )
}
if !(c .BaseCurrency == "" ) {
c .Flags .Set (1 )
}
if !(c .BaseAmount == "" ) {
c .Flags .Set (2 )
}
if !(c .Memo == "" ) {
c .Flags .Set (3 )
}
if !(c .Theme == "" ) {
c .Flags .Set (4 )
}
if !(c .SuccessReturnURL == "" ) {
c .Flags .Set (5 )
}
if !(c .FailReturnURL == "" ) {
c .Flags .Set (6 )
}
if !(c .CryptoAmount == "" ) {
c .Flags .Set (7 )
}
}
func (c *PaymentsCreateOnrampSessionRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.createOnrampSession#a2197cf6 as nil" )
}
b .PutID (PaymentsCreateOnrampSessionRequestTypeID )
return c .EncodeBare (b )
}
func (c *PaymentsCreateOnrampSessionRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode payments.createOnrampSession#a2197cf6 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.createOnrampSession#a2197cf6: field flags: %w" , err )
}
b .PutString (c .Provider )
b .PutString (c .CryptoCurrency )
b .PutString (c .Address )
if c .Flags .Has (0 ) {
b .PutString (c .PaymentMethod )
}
if c .Flags .Has (1 ) {
b .PutString (c .BaseCurrency )
}
if c .Flags .Has (2 ) {
b .PutString (c .BaseAmount )
}
if c .Flags .Has (3 ) {
b .PutString (c .Memo )
}
if c .Flags .Has (4 ) {
b .PutString (c .Theme )
}
if c .Flags .Has (5 ) {
b .PutString (c .SuccessReturnURL )
}
if c .Flags .Has (6 ) {
b .PutString (c .FailReturnURL )
}
if c .Flags .Has (7 ) {
b .PutString (c .CryptoAmount )
}
return nil
}
func (c *PaymentsCreateOnrampSessionRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.createOnrampSession#a2197cf6 to nil" )
}
if err := b .ConsumeID (PaymentsCreateOnrampSessionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: %w" , err )
}
return c .DecodeBare (b )
}
func (c *PaymentsCreateOnrampSessionRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode payments.createOnrampSession#a2197cf6 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field provider: %w" , err )
}
c .Provider = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field crypto_currency: %w" , err )
}
c .CryptoCurrency = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field address: %w" , err )
}
c .Address = value
}
if c .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field payment_method: %w" , err )
}
c .PaymentMethod = value
}
if c .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field base_currency: %w" , err )
}
c .BaseCurrency = value
}
if c .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field base_amount: %w" , err )
}
c .BaseAmount = value
}
if c .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field memo: %w" , err )
}
c .Memo = value
}
if c .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field theme: %w" , err )
}
c .Theme = value
}
if c .Flags .Has (5 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field success_return_url: %w" , err )
}
c .SuccessReturnURL = value
}
if c .Flags .Has (6 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field fail_return_url: %w" , err )
}
c .FailReturnURL = value
}
if c .Flags .Has (7 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.createOnrampSession#a2197cf6: field crypto_amount: %w" , err )
}
c .CryptoAmount = value
}
return nil
}
func (c *PaymentsCreateOnrampSessionRequest ) GetProvider () (value string ) {
if c == nil {
return
}
return c .Provider
}
func (c *PaymentsCreateOnrampSessionRequest ) GetCryptoCurrency () (value string ) {
if c == nil {
return
}
return c .CryptoCurrency
}
func (c *PaymentsCreateOnrampSessionRequest ) GetAddress () (value string ) {
if c == nil {
return
}
return c .Address
}
func (c *PaymentsCreateOnrampSessionRequest ) SetPaymentMethod (value string ) {
c .Flags .Set (0 )
c .PaymentMethod = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetPaymentMethod () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .PaymentMethod , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetBaseCurrency (value string ) {
c .Flags .Set (1 )
c .BaseCurrency = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetBaseCurrency () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .BaseCurrency , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetBaseAmount (value string ) {
c .Flags .Set (2 )
c .BaseAmount = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetBaseAmount () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .BaseAmount , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetMemo (value string ) {
c .Flags .Set (3 )
c .Memo = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetMemo () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .Memo , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetTheme (value string ) {
c .Flags .Set (4 )
c .Theme = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetTheme () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (4 ) {
return value , false
}
return c .Theme , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetSuccessReturnURL (value string ) {
c .Flags .Set (5 )
c .SuccessReturnURL = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetSuccessReturnURL () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (5 ) {
return value , false
}
return c .SuccessReturnURL , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetFailReturnURL (value string ) {
c .Flags .Set (6 )
c .FailReturnURL = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetFailReturnURL () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (6 ) {
return value , false
}
return c .FailReturnURL , true
}
func (c *PaymentsCreateOnrampSessionRequest ) SetCryptoAmount (value string ) {
c .Flags .Set (7 )
c .CryptoAmount = value
}
func (c *PaymentsCreateOnrampSessionRequest ) GetCryptoAmount () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (7 ) {
return value , false
}
return c .CryptoAmount , true
}
func (c *Client ) PaymentsCreateOnrampSession (ctx context .Context , request *PaymentsCreateOnrampSessionRequest ) (*OnrampSession , error ) {
var result OnrampSession
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 .