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

// PaymentsGetSavedStarGiftRequest represents TL type `payments.getSavedStarGift#b455a106`.
// Fetch info about specific gifts¹ owned by a peer we control.
// Note that unlike what the name suggests, the method can be used to fetch both "saved"
// and "unsaved" gifts (aka gifts both pinned and not pinned to the profile).
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/method/payments.getSavedStarGift for reference.
type PaymentsGetSavedStarGiftRequest struct {
	// List of gifts to fetch info about.
	Stargift []InputSavedStarGiftClass
}

// PaymentsGetSavedStarGiftRequestTypeID is TL type id of PaymentsGetSavedStarGiftRequest.
const PaymentsGetSavedStarGiftRequestTypeID = 0xb455a106

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsGetSavedStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getSavedStarGift#b455a106 as nil")
	}
	.PutID(PaymentsGetSavedStarGiftRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetSavedStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getSavedStarGift#b455a106 as nil")
	}
	.PutVectorHeader(len(.Stargift))
	for ,  := range .Stargift {
		if  == nil {
			return fmt.Errorf("unable to encode payments.getSavedStarGift#b455a106: field stargift element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.getSavedStarGift#b455a106: field stargift element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetSavedStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getSavedStarGift#b455a106 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGift#b455a106: field stargift: %w", )
		}

		if  > 0 {
			.Stargift = make([]InputSavedStarGiftClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputSavedStarGift()
			if  != nil {
				return fmt.Errorf("unable to decode payments.getSavedStarGift#b455a106: field stargift: %w", )
			}
			.Stargift = append(.Stargift, )
		}
	}
	return nil
}

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

// MapStargift returns field Stargift wrapped in InputSavedStarGiftClassArray helper.
func ( *PaymentsGetSavedStarGiftRequest) () ( InputSavedStarGiftClassArray) {
	return InputSavedStarGiftClassArray(.Stargift)
}

// PaymentsGetSavedStarGift invokes method payments.getSavedStarGift#b455a106 returning error if any.
// Fetch info about specific gifts¹ owned by a peer we control.
// Note that unlike what the name suggests, the method can be used to fetch both "saved"
// and "unsaved" gifts (aka gifts both pinned and not pinned to the profile).
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// Possible errors:
//
//	400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
//	400 STARGIFT_OWNER_INVALID: You cannot transfer or sell a gift owned by another user.
//	400 STARGIFT_SLUG_INVALID: The specified gift slug is invalid.
//
// See https://core.telegram.org/method/payments.getSavedStarGift for reference.
func ( *Client) ( context.Context,  []InputSavedStarGiftClass) (*PaymentsSavedStarGifts, error) {
	var  PaymentsSavedStarGifts

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