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

// PaymentsGetStarGiftWithdrawalURLRequest represents TL type `payments.getStarGiftWithdrawalUrl#d06e93a8`.
// Convert a collectible gift »¹ to an NFT on the TON blockchain.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/method/payments.getStarGiftWithdrawalUrl for reference.
type PaymentsGetStarGiftWithdrawalURLRequest struct {
	// The collectible gift to export.
	Stargift InputSavedStarGiftClass
	// The current user's 2FA password, passed as specified here »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	Password InputCheckPasswordSRPClass
}

// PaymentsGetStarGiftWithdrawalURLRequestTypeID is TL type id of PaymentsGetStarGiftWithdrawalURLRequest.
const PaymentsGetStarGiftWithdrawalURLRequestTypeID = 0xd06e93a8

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

func ( *PaymentsGetStarGiftWithdrawalURLRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Stargift == nil) {
		return false
	}
	if !(.Password == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarGiftWithdrawalURLRequest from given interface.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) ( interface {
	() ( InputSavedStarGiftClass)
	() ( InputCheckPasswordSRPClass)
}) {
	.Stargift = .()
	.Password = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarGiftWithdrawalUrl",
		ID:   PaymentsGetStarGiftWithdrawalURLRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Stargift",
			SchemaName: "stargift",
		},
		{
			Name:       "Password",
			SchemaName: "password",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftWithdrawalUrl#d06e93a8 as nil")
	}
	.PutID(PaymentsGetStarGiftWithdrawalURLRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftWithdrawalUrl#d06e93a8 as nil")
	}
	if .Stargift == nil {
		return fmt.Errorf("unable to encode payments.getStarGiftWithdrawalUrl#d06e93a8: field stargift is nil")
	}
	if  := .Stargift.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarGiftWithdrawalUrl#d06e93a8: field stargift: %w", )
	}
	if .Password == nil {
		return fmt.Errorf("unable to encode payments.getStarGiftWithdrawalUrl#d06e93a8: field password is nil")
	}
	if  := .Password.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarGiftWithdrawalUrl#d06e93a8: field password: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarGiftWithdrawalUrl#d06e93a8 to nil")
	}
	{
		,  := DecodeInputSavedStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftWithdrawalUrl#d06e93a8: field stargift: %w", )
		}
		.Stargift = 
	}
	{
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftWithdrawalUrl#d06e93a8: field password: %w", )
		}
		.Password = 
	}
	return nil
}

// GetStargift returns value of Stargift field.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) () ( InputSavedStarGiftClass) {
	if  == nil {
		return
	}
	return .Stargift
}

// GetPassword returns value of Password field.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) () ( InputCheckPasswordSRPClass) {
	if  == nil {
		return
	}
	return .Password
}

// GetPasswordAsNotEmpty returns mapped value of Password field.
func ( *PaymentsGetStarGiftWithdrawalURLRequest) () (*InputCheckPasswordSRP, bool) {
	return .Password.AsNotEmpty()
}

// PaymentsGetStarGiftWithdrawalURL invokes method payments.getStarGiftWithdrawalUrl#d06e93a8 returning error if any.
// Convert a collectible gift »¹ to an NFT on the TON blockchain.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// Possible errors:
//
//	400 PASSWORD_HASH_INVALID: The provided password hash is invalid.
//	400 PASSWORD_TOO_FRESH_%d: The password was modified less than 24 hours ago, try again in %d seconds.
//	400 SESSION_TOO_FRESH_%d: This session was created less than 24 hours ago, try again in %d seconds.
//
// See https://core.telegram.org/method/payments.getStarGiftWithdrawalUrl for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarGiftWithdrawalURLRequest) (*PaymentsStarGiftWithdrawalURL, error) {
	var  PaymentsStarGiftWithdrawalURL

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