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

// PaymentsTransferStarGiftRequest represents TL type `payments.transferStarGift#7f18176a`.
// Transfer a collectible gift¹ to another user or channel: can only be used if transfer
// is free (i.e. messageActionStarGiftUnique².transfer_stars is not set); see here »³
// for more info on the full flow (including the different flow to use in case the
// transfer isn't free).
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//  2. https://core.telegram.org/constructor/messageActionStarGiftUnique
//  3. https://core.telegram.org/api/gifts#transferring-collectible-gifts
//
// See https://core.telegram.org/method/payments.transferStarGift for reference.
type PaymentsTransferStarGiftRequest struct {
	// The gift to transfer.
	Stargift InputSavedStarGiftClass
	// Destination peer.
	ToID InputPeerClass
}

// PaymentsTransferStarGiftRequestTypeID is TL type id of PaymentsTransferStarGiftRequest.
const PaymentsTransferStarGiftRequestTypeID = 0x7f18176a

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsTransferStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.transferStarGift#7f18176a as nil")
	}
	.PutID(PaymentsTransferStarGiftRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsTransferStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.transferStarGift#7f18176a to nil")
	}
	{
		,  := DecodeInputSavedStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode payments.transferStarGift#7f18176a: field stargift: %w", )
		}
		.Stargift = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.transferStarGift#7f18176a: field to_id: %w", )
		}
		.ToID = 
	}
	return nil
}

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

// GetToID returns value of ToID field.
func ( *PaymentsTransferStarGiftRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .ToID
}

// PaymentsTransferStarGift invokes method payments.transferStarGift#7f18176a returning error if any.
// Transfer a collectible gift¹ to another user or channel: can only be used if transfer
// is free (i.e. messageActionStarGiftUnique².transfer_stars is not set); see here »³
// for more info on the full flow (including the different flow to use in case the
// transfer isn't free).
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//  2. https://core.telegram.org/constructor/messageActionStarGiftUnique
//  3. https://core.telegram.org/api/gifts#transferring-collectible-gifts
//
// 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 PAYMENT_REQUIRED: Payment is required for this action, see here » for more info.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
//	400 STARGIFT_NOT_FOUND: The specified gift was not found.
//	400 STARGIFT_NOT_OWNER:
//	400 STARGIFT_NOT_UNIQUE:
//	400 STARGIFT_OWNER_INVALID: You cannot transfer or sell a gift owned by another user.
//	400 STARGIFT_PEER_INVALID: The specified inputSavedStarGiftChat.peer is invalid.
//	400 STARGIFT_TRANSFER_TOO_EARLY_%d: You cannot transfer this gift yet, wait %d seconds.
//
// See https://core.telegram.org/method/payments.transferStarGift for reference.
func ( *Client) ( context.Context,  *PaymentsTransferStarGiftRequest) (UpdatesClass, error) {
	var  UpdatesBox

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