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

// PremiumApplyBoostRequest represents TL type `premium.applyBoost#6b7da746`.
// Apply one or more boosts »¹ to a peer.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/method/premium.applyBoost for reference.
type PremiumApplyBoostRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Which boost slots¹ to assign to this peer.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//
	// Use SetSlots and GetSlots helpers.
	Slots []int
	// The peer to boost.
	Peer InputPeerClass
}

// PremiumApplyBoostRequestTypeID is TL type id of PremiumApplyBoostRequest.
const PremiumApplyBoostRequestTypeID = 0x6b7da746

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

func ( *PremiumApplyBoostRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Slots == nil) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PremiumApplyBoostRequest from given interface.
func ( *PremiumApplyBoostRequest) ( interface {
	() ( []int,  bool)
	() ( InputPeerClass)
}) {
	if ,  := .();  {
		.Slots = 
	}

	.Peer = .()
}

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

// TypeName returns name of type in TL schema.
func (*PremiumApplyBoostRequest) () string {
	return "premium.applyBoost"
}

// TypeInfo returns info about TL type.
func ( *PremiumApplyBoostRequest) () tdp.Type {
	 := tdp.Type{
		Name: "premium.applyBoost",
		ID:   PremiumApplyBoostRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Slots",
			SchemaName: "slots",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PremiumApplyBoostRequest) () {
	if !(.Slots == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PremiumApplyBoostRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.applyBoost#6b7da746 as nil")
	}
	.PutID(PremiumApplyBoostRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumApplyBoostRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.applyBoost#6b7da746 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutVectorHeader(len(.Slots))
		for ,  := range .Slots {
			.PutInt()
		}
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode premium.applyBoost#6b7da746: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumApplyBoostRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.applyBoost#6b7da746 to nil")
	}
	if  := .ConsumeID(PremiumApplyBoostRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumApplyBoostRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.applyBoost#6b7da746 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field slots: %w", )
		}

		if  > 0 {
			.Slots = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field slots: %w", )
			}
			.Slots = append(.Slots, )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode premium.applyBoost#6b7da746: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// SetSlots sets value of Slots conditional field.
func ( *PremiumApplyBoostRequest) ( []int) {
	.Flags.Set(0)
	.Slots = 
}

// GetSlots returns value of Slots conditional field and
// boolean which is true if field was set.
func ( *PremiumApplyBoostRequest) () ( []int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Slots, true
}

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

// PremiumApplyBoost invokes method premium.applyBoost#6b7da746 returning error if any.
// Apply one or more boosts »¹ to a peer.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// Possible errors:
//
//	400 BOOSTS_EMPTY: No boost slots were specified.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SLOTS_EMPTY: The specified slot list is empty.
//
// See https://core.telegram.org/method/premium.applyBoost for reference.
func ( *Client) ( context.Context,  *PremiumApplyBoostRequest) (*PremiumMyBoosts, error) {
	var  PremiumMyBoosts

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