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

// PaymentsToggleStarGiftsPinnedToTopRequest represents TL type `payments.toggleStarGiftsPinnedToTop#1513e7b0`.
// Pins a received gift on top of the profile of the user or owned channels by using
// payments.toggleStarGiftsPinnedToTop¹.
//
// Links:
//  1. https://core.telegram.org/method/payments.toggleStarGiftsPinnedToTop
//
// See https://core.telegram.org/method/payments.toggleStarGiftsPinnedToTop for reference.
type PaymentsToggleStarGiftsPinnedToTopRequest struct {
	// The peer where to pin the gift.
	Peer InputPeerClass
	// The gift to pin.
	Stargift []InputSavedStarGiftClass
}

// PaymentsToggleStarGiftsPinnedToTopRequestTypeID is TL type id of PaymentsToggleStarGiftsPinnedToTopRequest.
const PaymentsToggleStarGiftsPinnedToTopRequestTypeID = 0x1513e7b0

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsToggleStarGiftsPinnedToTopRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.toggleStarGiftsPinnedToTop#1513e7b0 as nil")
	}
	.PutID(PaymentsToggleStarGiftsPinnedToTopRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsToggleStarGiftsPinnedToTopRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.toggleStarGiftsPinnedToTop#1513e7b0 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.toggleStarGiftsPinnedToTop#1513e7b0: field stargift: %w", )
		}

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

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

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

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

// PaymentsToggleStarGiftsPinnedToTop invokes method payments.toggleStarGiftsPinnedToTop#1513e7b0 returning error if any.
// Pins a received gift on top of the profile of the user or owned channels by using
// payments.toggleStarGiftsPinnedToTop¹.
//
// Links:
//  1. https://core.telegram.org/method/payments.toggleStarGiftsPinnedToTop
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.toggleStarGiftsPinnedToTop for reference.
func ( *Client) ( context.Context,  *PaymentsToggleStarGiftsPinnedToTopRequest) (bool, error) {
	var  BoolBox

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