// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// PremiumGetMyBoostsRequest represents TL type `premium.getMyBoosts#be77b4a`.
// Obtain which peers are we currently boosting¹, and how many boost slots² we have
// left.
//
// Links:
//  1. https://core.telegram.org/api/boost
//  2. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/method/premium.getMyBoosts for reference.
type PremiumGetMyBoostsRequest struct {
}

// PremiumGetMyBoostsRequestTypeID is TL type id of PremiumGetMyBoostsRequest.
const PremiumGetMyBoostsRequestTypeID = 0xbe77b4a

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

func (g *PremiumGetMyBoostsRequest) Zero() bool {
	if g == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (g *PremiumGetMyBoostsRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premium.getMyBoosts",
		ID:   PremiumGetMyBoostsRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (g *PremiumGetMyBoostsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode premium.getMyBoosts#be77b4a as nil")
	}
	b.PutID(PremiumGetMyBoostsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *PremiumGetMyBoostsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode premium.getMyBoosts#be77b4a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *PremiumGetMyBoostsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode premium.getMyBoosts#be77b4a to nil")
	}
	if err := b.ConsumeID(PremiumGetMyBoostsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode premium.getMyBoosts#be77b4a: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *PremiumGetMyBoostsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode premium.getMyBoosts#be77b4a to nil")
	}
	return nil
}

// PremiumGetMyBoosts invokes method premium.getMyBoosts#be77b4a returning error if any.
// Obtain which peers are we currently boosting¹, and how many boost slots² we have
// left.
//
// Links:
//  1. https://core.telegram.org/api/boost
//  2. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/method/premium.getMyBoosts for reference.
func (c *Client) PremiumGetMyBoosts(ctx context.Context) (*PremiumMyBoosts, error) {
	var result PremiumMyBoosts

	request := &PremiumGetMyBoostsRequest{}
	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return nil, err
	}
	return &result, nil
}
