// 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{}
)

// PaymentsGetOnrampAvailabilityRequest represents TL type `payments.getOnrampAvailability#2ec29951`.
//
// See https://core.telegram.org/method/payments.getOnrampAvailability for reference.
type PaymentsGetOnrampAvailabilityRequest struct {
	// Flags field of PaymentsGetOnrampAvailabilityRequest.
	Flags bin.Fields
	// Provider field of PaymentsGetOnrampAvailabilityRequest.
	Provider string
	// CryptoCurrency field of PaymentsGetOnrampAvailabilityRequest.
	CryptoCurrency string
	// BaseCurrency field of PaymentsGetOnrampAvailabilityRequest.
	//
	// Use SetBaseCurrency and GetBaseCurrency helpers.
	BaseCurrency string
}

// PaymentsGetOnrampAvailabilityRequestTypeID is TL type id of PaymentsGetOnrampAvailabilityRequest.
const PaymentsGetOnrampAvailabilityRequestTypeID = 0x2ec29951

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

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

	return true
}

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetOnrampAvailabilityRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getOnrampAvailability",
		ID:   PaymentsGetOnrampAvailabilityRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Provider",
			SchemaName: "provider",
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
		},
		{
			Name:       "BaseCurrency",
			SchemaName: "base_currency",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetOnrampAvailabilityRequest) () {
	if !(.BaseCurrency == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetOnrampAvailabilityRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getOnrampAvailability#2ec29951 as nil")
	}
	.PutID(PaymentsGetOnrampAvailabilityRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetOnrampAvailabilityRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getOnrampAvailability#2ec29951 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampAvailability#2ec29951: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampAvailability#2ec29951: field provider: %w", )
		}
		.Provider = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampAvailability#2ec29951: field crypto_currency: %w", )
		}
		.CryptoCurrency = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getOnrampAvailability#2ec29951: field base_currency: %w", )
		}
		.BaseCurrency = 
	}
	return nil
}

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

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

// SetBaseCurrency sets value of BaseCurrency conditional field.
func ( *PaymentsGetOnrampAvailabilityRequest) ( string) {
	.Flags.Set(0)
	.BaseCurrency = 
}

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

// PaymentsGetOnrampAvailability invokes method payments.getOnrampAvailability#2ec29951 returning error if any.
//
// See https://core.telegram.org/method/payments.getOnrampAvailability for reference.
func ( *Client) ( context.Context,  *PaymentsGetOnrampAvailabilityRequest) (*OnrampAvailability, error) {
	var  OnrampAvailability

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