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

// PaymentsCreateStarGiftCollectionRequest represents TL type `payments.createStarGiftCollection#1f4a0e87`.
// Create a star gift collection »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// See https://core.telegram.org/method/payments.createStarGiftCollection for reference.
type PaymentsCreateStarGiftCollectionRequest struct {
	// Peer where to create the collection.
	Peer InputPeerClass
	// Title of the collection.
	Title string
	// Gifts added to the collection.
	Stargift []InputSavedStarGiftClass
}

// PaymentsCreateStarGiftCollectionRequestTypeID is TL type id of PaymentsCreateStarGiftCollectionRequest.
const PaymentsCreateStarGiftCollectionRequestTypeID = 0x1f4a0e87

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

func ( *PaymentsCreateStarGiftCollectionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Stargift == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsCreateStarGiftCollectionRequest from given interface.
func ( *PaymentsCreateStarGiftCollectionRequest) ( interface {
	() ( InputPeerClass)
	() ( string)
	() ( []InputSavedStarGiftClass)
}) {
	.Peer = .()
	.Title = .()
	.Stargift = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsCreateStarGiftCollectionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.createStarGiftCollection",
		ID:   PaymentsCreateStarGiftCollectionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Stargift",
			SchemaName: "stargift",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsCreateStarGiftCollectionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.createStarGiftCollection#1f4a0e87 as nil")
	}
	.PutID(PaymentsCreateStarGiftCollectionRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsCreateStarGiftCollectionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.createStarGiftCollection#1f4a0e87 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.createStarGiftCollection#1f4a0e87: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.createStarGiftCollection#1f4a0e87: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.createStarGiftCollection#1f4a0e87: field stargift: %w", )
		}

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

// GetPeer returns value of Peer field.
func ( *PaymentsCreateStarGiftCollectionRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetTitle returns value of Title field.
func ( *PaymentsCreateStarGiftCollectionRequest) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

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

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

// PaymentsCreateStarGiftCollection invokes method payments.createStarGiftCollection#1f4a0e87 returning error if any.
// Create a star gift collection »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.createStarGiftCollection for reference.
func ( *Client) ( context.Context,  *PaymentsCreateStarGiftCollectionRequest) (*StarGiftCollection, error) {
	var  StarGiftCollection

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