// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PaymentsGetOnrampQuoteRequest represents TL type `payments.getOnrampQuote#e06645fa`.
//
// See https://core.telegram.org/method/payments.getOnrampQuote for reference.
type PaymentsGetOnrampQuoteRequest struct {
	// Flags field of PaymentsGetOnrampQuoteRequest.
	Flags bin.Fields
	// Provider field of PaymentsGetOnrampQuoteRequest.
	Provider string
	// CryptoCurrency field of PaymentsGetOnrampQuoteRequest.
	CryptoCurrency string
	// BaseCurrency field of PaymentsGetOnrampQuoteRequest.
	BaseCurrency string
	// BaseAmount field of PaymentsGetOnrampQuoteRequest.
	//
	// Use SetBaseAmount and GetBaseAmount helpers.
	BaseAmount string
	// CryptoAmount field of PaymentsGetOnrampQuoteRequest.
	//
	// Use SetCryptoAmount and GetCryptoAmount helpers.
	CryptoAmount string
	// PaymentMethod field of PaymentsGetOnrampQuoteRequest.
	//
	// Use SetPaymentMethod and GetPaymentMethod helpers.
	PaymentMethod string
}

// PaymentsGetOnrampQuoteRequestTypeID is TL type id of PaymentsGetOnrampQuoteRequest.
const PaymentsGetOnrampQuoteRequestTypeID = 0xe06645fa

// Ensuring interfaces in compile-time for PaymentsGetOnrampQuoteRequest.
var (
	_ bin.Encoder     = &PaymentsGetOnrampQuoteRequest{}
	_ bin.Decoder     = &PaymentsGetOnrampQuoteRequest{}
	_ bin.BareEncoder = &PaymentsGetOnrampQuoteRequest{}
	_ bin.BareDecoder = &PaymentsGetOnrampQuoteRequest{}
)

func ( *PaymentsGetOnrampQuoteRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Provider == "") {
		return false
	}
	if !(.CryptoCurrency == "") {
		return false
	}
	if !(.BaseCurrency == "") {
		return false
	}
	if !(.BaseAmount == "") {
		return false
	}
	if !(.CryptoAmount == "") {
		return false
	}
	if !(.PaymentMethod == "") {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PaymentsGetOnrampQuoteRequest) () string {
	if  == nil {
		return "PaymentsGetOnrampQuoteRequest(nil)"
	}
	type  PaymentsGetOnrampQuoteRequest
	return fmt.Sprintf("PaymentsGetOnrampQuoteRequest%+v", (*))
}

// FillFrom fills PaymentsGetOnrampQuoteRequest from given interface.
func ( *PaymentsGetOnrampQuoteRequest) ( interface {
	() ( string)
	() ( string)
	() ( string)
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
}) {
	.Provider = .()
	.CryptoCurrency = .()
	.BaseCurrency = .()
	if ,  := .();  {
		.BaseAmount = 
	}

	if ,  := .();  {
		.CryptoAmount = 
	}

	if ,  := .();  {
		.PaymentMethod = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PaymentsGetOnrampQuoteRequest) () uint32 {
	return PaymentsGetOnrampQuoteRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*PaymentsGetOnrampQuoteRequest) () string {
	return "payments.getOnrampQuote"
}

// TypeInfo returns info about TL type.
func ( *PaymentsGetOnrampQuoteRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getOnrampQuote",
		ID:   PaymentsGetOnrampQuoteRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Provider",
			SchemaName: "provider",
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
		},
		{
			Name:       "BaseCurrency",
			SchemaName: "base_currency",
		},
		{
			Name:       "BaseAmount",
			SchemaName: "base_amount",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "CryptoAmount",
			SchemaName: "crypto_amount",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PaymentMethod",
			SchemaName: "payment_method",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetOnrampQuoteRequest) () {
	if !(.BaseAmount == "") {
		.Flags.Set(0)
	}
	if !(.CryptoAmount == "") {
		.Flags.Set(1)
	}
	if !(.PaymentMethod == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetOnrampQuoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getOnrampQuote#e06645fa as nil")
	}
	.PutID(PaymentsGetOnrampQuoteRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetOnrampQuoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getOnrampQuote#e06645fa as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getOnrampQuote#e06645fa: field flags: %w", )
	}
	.PutString(.Provider)
	.PutString(.CryptoCurrency)
	.PutString(.BaseCurrency)
	if .Flags.Has(0) {
		.PutString(.BaseAmount)
	}
	if .Flags.Has(1) {
		.PutString(.CryptoAmount)
	}
	if .Flags.Has(2) {
		.PutString(.PaymentMethod)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsGetOnrampQuoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getOnrampQuote#e06645fa to nil")
	}
	if  := .ConsumeID(PaymentsGetOnrampQuoteRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetOnrampQuoteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getOnrampQuote#e06645fa to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field provider: %w", )
		}
		.Provider = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field crypto_currency: %w", )
		}
		.CryptoCurrency = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field base_currency: %w", )
		}
		.BaseCurrency = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field base_amount: %w", )
		}
		.BaseAmount = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field crypto_amount: %w", )
		}
		.CryptoAmount = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampQuote#e06645fa: field payment_method: %w", )
		}
		.PaymentMethod = 
	}
	return nil
}

// GetProvider returns value of Provider field.
func ( *PaymentsGetOnrampQuoteRequest) () ( string) {
	if  == nil {
		return
	}
	return .Provider
}

// GetCryptoCurrency returns value of CryptoCurrency field.
func ( *PaymentsGetOnrampQuoteRequest) () ( string) {
	if  == nil {
		return
	}
	return .CryptoCurrency
}

// GetBaseCurrency returns value of BaseCurrency field.
func ( *PaymentsGetOnrampQuoteRequest) () ( string) {
	if  == nil {
		return
	}
	return .BaseCurrency
}

// SetBaseAmount sets value of BaseAmount conditional field.
func ( *PaymentsGetOnrampQuoteRequest) ( string) {
	.Flags.Set(0)
	.BaseAmount = 
}

// GetBaseAmount returns value of BaseAmount conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetOnrampQuoteRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .BaseAmount, true
}

// SetCryptoAmount sets value of CryptoAmount conditional field.
func ( *PaymentsGetOnrampQuoteRequest) ( string) {
	.Flags.Set(1)
	.CryptoAmount = 
}

// GetCryptoAmount returns value of CryptoAmount conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetOnrampQuoteRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .CryptoAmount, true
}

// SetPaymentMethod sets value of PaymentMethod conditional field.
func ( *PaymentsGetOnrampQuoteRequest) ( string) {
	.Flags.Set(2)
	.PaymentMethod = 
}

// GetPaymentMethod returns value of PaymentMethod conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetOnrampQuoteRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .PaymentMethod, true
}

// PaymentsGetOnrampQuote invokes method payments.getOnrampQuote#e06645fa returning error if any.
//
// See https://core.telegram.org/method/payments.getOnrampQuote for reference.
func ( *Client) ( context.Context,  *PaymentsGetOnrampQuoteRequest) (*OnrampQuote, error) {
	var  OnrampQuote

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}