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

// PaymentsConvertStarGiftRequest represents TL type `payments.convertStarGift#74bf076b`.
// Convert a received gift »¹ into Telegram Stars: this will permanently destroy the
// gift, converting it into starGift².convert_stars Telegram Stars³, added to the
// user's balance.
// Note that starGift¹.convert_stars will be less than the buying price (starGift²
// stars) of the gift if it was originally bought using Telegram Stars bought a long time
// ago.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/constructor/starGift
//  3. https://core.telegram.org/api/stars
//  4. https://core.telegram.org/constructor/starGift
//  5. https://core.telegram.org/constructor/starGift
//
// See https://core.telegram.org/method/payments.convertStarGift for reference.
type PaymentsConvertStarGiftRequest struct {
	// The gift to convert.
	Stargift InputSavedStarGiftClass
}

// PaymentsConvertStarGiftRequestTypeID is TL type id of PaymentsConvertStarGiftRequest.
const PaymentsConvertStarGiftRequestTypeID = 0x74bf076b

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsConvertStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.convertStarGift#74bf076b as nil")
	}
	.PutID(PaymentsConvertStarGiftRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsConvertStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.convertStarGift#74bf076b to nil")
	}
	{
		,  := DecodeInputSavedStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode payments.convertStarGift#74bf076b: field stargift: %w", )
		}
		.Stargift = 
	}
	return nil
}

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

// PaymentsConvertStarGift invokes method payments.convertStarGift#74bf076b returning error if any.
// Convert a received gift »¹ into Telegram Stars: this will permanently destroy the
// gift, converting it into starGift².convert_stars Telegram Stars³, added to the
// user's balance.
// Note that starGift¹.convert_stars will be less than the buying price (starGift²
// stars) of the gift if it was originally bought using Telegram Stars bought a long time
// ago.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/constructor/starGift
//  3. https://core.telegram.org/api/stars
//  4. https://core.telegram.org/constructor/starGift
//  5. https://core.telegram.org/constructor/starGift
//
// Possible errors:
//
//	400 BUSINESS_CONNECTION_INVALID: The connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
//	400 STARGIFT_PEER_INVALID: The specified inputSavedStarGiftChat.peer is invalid.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/payments.convertStarGift for reference.
func ( *Client) ( context.Context,  InputSavedStarGiftClass) (bool, error) {
	var  BoolBox

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