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

// PaymentsGetStarsTopupOptionsRequest represents TL type `payments.getStarsTopupOptions#c00ec7d3`.
// Obtain a list of Telegram Stars topup options »¹ as starsTopupOption² constructors.
//
// Links:
//  1. https://core.telegram.org/api/stars#buying-or-gifting-stars
//  2. https://core.telegram.org/constructor/starsTopupOption
//
// See https://core.telegram.org/method/payments.getStarsTopupOptions for reference.
type PaymentsGetStarsTopupOptionsRequest struct {
}

// PaymentsGetStarsTopupOptionsRequestTypeID is TL type id of PaymentsGetStarsTopupOptionsRequest.
const PaymentsGetStarsTopupOptionsRequestTypeID = 0xc00ec7d3

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *PaymentsGetStarsTopupOptionsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode payments.getStarsTopupOptions#c00ec7d3 as nil")
	}
	b.PutID(PaymentsGetStarsTopupOptionsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *PaymentsGetStarsTopupOptionsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode payments.getStarsTopupOptions#c00ec7d3 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *PaymentsGetStarsTopupOptionsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode payments.getStarsTopupOptions#c00ec7d3 to nil")
	}
	if err := b.ConsumeID(PaymentsGetStarsTopupOptionsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode payments.getStarsTopupOptions#c00ec7d3: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *PaymentsGetStarsTopupOptionsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode payments.getStarsTopupOptions#c00ec7d3 to nil")
	}
	return nil
}

// PaymentsGetStarsTopupOptions invokes method payments.getStarsTopupOptions#c00ec7d3 returning error if any.
// Obtain a list of Telegram Stars topup options »¹ as starsTopupOption² constructors.
//
// Links:
//  1. https://core.telegram.org/api/stars#buying-or-gifting-stars
//  2. https://core.telegram.org/constructor/starsTopupOption
//
// See https://core.telegram.org/method/payments.getStarsTopupOptions for reference.
func (c *Client) PaymentsGetStarsTopupOptions(ctx context.Context) ([]StarsTopupOption, error) {
	var result StarsTopupOptionVector

	request := &PaymentsGetStarsTopupOptionsRequest{}
	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return nil, err
	}
	return []StarsTopupOption(result.Elems), nil
}
