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

// PaymentsCraftStarGiftRequest represents TL type `payments.craftStarGift#b0f9684f`.
// Craft a new collectible gift »¹ by combining 1 to 4 owned collectible gifts of the
// same base gift type.
// The passed gifts must all have the same starGiftUnique¹.gift_id, must be usable for
// crafting, and must not be blocked by a future can_craft_at timestamp.
// The first passed gift must not be located on the TON blockchain.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//  2. https://core.telegram.org/constructor/starGiftUnique
//
// See https://core.telegram.org/method/payments.craftStarGift for reference.
type PaymentsCraftStarGiftRequest struct {
	// 1 to 4 owned collectible gifts of the same type to use for crafting »¹. The first
	// gift's ID is reused if crafting succeeds.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#crafting-collectible-gifts
	Stargift []InputSavedStarGiftClass
}

// PaymentsCraftStarGiftRequestTypeID is TL type id of PaymentsCraftStarGiftRequest.
const PaymentsCraftStarGiftRequestTypeID = 0xb0f9684f

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsCraftStarGiftRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.craftStarGift#b0f9684f as nil")
	}
	.PutID(PaymentsCraftStarGiftRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// PaymentsCraftStarGift invokes method payments.craftStarGift#b0f9684f returning error if any.
// Craft a new collectible gift »¹ by combining 1 to 4 owned collectible gifts of the
// same base gift type.
// The passed gifts must all have the same starGiftUnique¹.gift_id, must be usable for
// crafting, and must not be blocked by a future can_craft_at timestamp.
// The first passed gift must not be located on the TON blockchain.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//  2. https://core.telegram.org/constructor/starGiftUnique
//
// Possible errors:
//
//	400 SAVED_ID_EMPTY: The passed inputSavedStarGiftChat.saved_id is empty.
//
// See https://core.telegram.org/method/payments.craftStarGift for reference.
func ( *Client) ( context.Context,  []InputSavedStarGiftClass) (UpdatesClass, error) {
	var  UpdatesBox

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