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

// PaymentsWithdrawStarGiftRequest represents TL type `payments.withdrawStarGift#ec2030ae`.
//
// See https://core.telegram.org/method/payments.withdrawStarGift for reference.
type PaymentsWithdrawStarGiftRequest struct {
	// Flags field of PaymentsWithdrawStarGiftRequest.
	Flags bin.Fields
	// KeepOnProfile field of PaymentsWithdrawStarGiftRequest.
	KeepOnProfile bool
	// Stargift field of PaymentsWithdrawStarGiftRequest.
	Stargift InputSavedStarGiftClass
	// TmpPassword field of PaymentsWithdrawStarGiftRequest.
	TmpPassword []byte
}

// PaymentsWithdrawStarGiftRequestTypeID is TL type id of PaymentsWithdrawStarGiftRequest.
const PaymentsWithdrawStarGiftRequestTypeID = 0xec2030ae

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

func ( *PaymentsWithdrawStarGiftRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.KeepOnProfile == false) {
		return false
	}
	if !(.Stargift == nil) {
		return false
	}
	if !(.TmpPassword == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsWithdrawStarGiftRequest from given interface.
func ( *PaymentsWithdrawStarGiftRequest) ( interface {
	() ( bool)
	() ( InputSavedStarGiftClass)
	() ( []byte)
}) {
	.KeepOnProfile = .()
	.Stargift = .()
	.TmpPassword = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsWithdrawStarGiftRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.withdrawStarGift",
		ID:   PaymentsWithdrawStarGiftRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "KeepOnProfile",
			SchemaName: "keep_on_profile",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Stargift",
			SchemaName: "stargift",
		},
		{
			Name:       "TmpPassword",
			SchemaName: "tmp_password",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsWithdrawStarGiftRequest) () {
	if !(.KeepOnProfile == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsWithdrawStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.withdrawStarGift#ec2030ae as nil")
	}
	.PutID(PaymentsWithdrawStarGiftRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsWithdrawStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.withdrawStarGift#ec2030ae as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.withdrawStarGift#ec2030ae: field flags: %w", )
	}
	if .Stargift == nil {
		return fmt.Errorf("unable to encode payments.withdrawStarGift#ec2030ae: field stargift is nil")
	}
	if  := .Stargift.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.withdrawStarGift#ec2030ae: field stargift: %w", )
	}
	.PutBytes(.TmpPassword)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsWithdrawStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.withdrawStarGift#ec2030ae to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.withdrawStarGift#ec2030ae: field flags: %w", )
		}
	}
	.KeepOnProfile = .Flags.Has(0)
	{
		,  := DecodeInputSavedStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode payments.withdrawStarGift#ec2030ae: field stargift: %w", )
		}
		.Stargift = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode payments.withdrawStarGift#ec2030ae: field tmp_password: %w", )
		}
		.TmpPassword = 
	}
	return nil
}

// SetKeepOnProfile sets value of KeepOnProfile conditional field.
func ( *PaymentsWithdrawStarGiftRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.KeepOnProfile = true
	} else {
		.Flags.Unset(0)
		.KeepOnProfile = false
	}
}

// GetKeepOnProfile returns value of KeepOnProfile conditional field.
func ( *PaymentsWithdrawStarGiftRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetTmpPassword returns value of TmpPassword field.
func ( *PaymentsWithdrawStarGiftRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .TmpPassword
}

// PaymentsWithdrawStarGift invokes method payments.withdrawStarGift#ec2030ae returning error if any.
//
// See https://core.telegram.org/method/payments.withdrawStarGift for reference.
func ( *Client) ( context.Context,  *PaymentsWithdrawStarGiftRequest) (bool, error) {
	var  BoolBox

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